cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gkossakow...@apache.org
Subject svn commit: r619921 - in /cocoon/whiteboard/micro/misc: cocoon-micro-it-block/src/main/java/org/apache/cocoon/micro/it/ cocoon-micro-it-block/src/main/resources/META-INF/cocoon/spring/ cocoon-webapp/src/test/java/org/apache/cocoon/micro/it/
Date Fri, 08 Feb 2008 15:58:04 GMT
Author: gkossakowski
Date: Fri Feb  8 07:58:03 2008
New Revision: 619921

URL: http://svn.apache.org/viewvc?rev=619921&view=rev
Log:
Created a integration test for servlet Spring scope.

Added:
    cocoon/whiteboard/micro/misc/cocoon-micro-it-block/src/main/java/org/apache/cocoon/micro/it/DemoServlet.java
    cocoon/whiteboard/micro/misc/cocoon-webapp/src/test/java/org/apache/cocoon/micro/it/SerletScopeTest.java
Modified:
    cocoon/whiteboard/micro/misc/cocoon-micro-it-block/src/main/resources/META-INF/cocoon/spring/cocoon-micro-it-servlet-service.xml

Added: cocoon/whiteboard/micro/misc/cocoon-micro-it-block/src/main/java/org/apache/cocoon/micro/it/DemoServlet.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/micro/misc/cocoon-micro-it-block/src/main/java/org/apache/cocoon/micro/it/DemoServlet.java?rev=619921&view=auto
==============================================================================
--- cocoon/whiteboard/micro/misc/cocoon-micro-it-block/src/main/java/org/apache/cocoon/micro/it/DemoServlet.java
(added)
+++ cocoon/whiteboard/micro/misc/cocoon-micro-it-block/src/main/java/org/apache/cocoon/micro/it/DemoServlet.java
Fri Feb  8 07:58:03 2008
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.micro.it;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class DemoServlet extends HttpServlet {
+    
+    private Map<String, String> storage;
+    
+    public void setStorage(Map<String, String> storage) {
+        this.storage = storage;
+    }
+    
+    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+            throws ServletException, IOException {
+        String requestURI = req.getPathInfo();
+        if ("/setCode".equals(requestURI)) {
+            storage.put("code", req.getParameter("code"));
+            resp.setStatus(HttpServletResponse.SC_OK);
+        } else if ("/getCode".equals(requestURI)) {
+            resp.setStatus(Integer.valueOf((String)storage.get("code")));
+        }
+    }
+}

Modified: cocoon/whiteboard/micro/misc/cocoon-micro-it-block/src/main/resources/META-INF/cocoon/spring/cocoon-micro-it-servlet-service.xml
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/micro/misc/cocoon-micro-it-block/src/main/resources/META-INF/cocoon/spring/cocoon-micro-it-servlet-service.xml?rev=619921&r1=619920&r2=619921&view=diff
==============================================================================
--- cocoon/whiteboard/micro/misc/cocoon-micro-it-block/src/main/resources/META-INF/cocoon/spring/cocoon-micro-it-servlet-service.xml
(original)
+++ cocoon/whiteboard/micro/misc/cocoon-micro-it-block/src/main/resources/META-INF/cocoon/spring/cocoon-micro-it-servlet-service.xml
Fri Feb  8 07:58:03 2008
@@ -21,11 +21,26 @@
 <beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:servlet="http://cocoon.apache.org/schema/servlet"
+  xmlns:aop="http://www.springframework.org/schema/aop"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
-  http://cocoon.apache.org/schema/servlet http://cocoon.apache.org/schema/servlet/cocoon-servlet-1.0.xsd">
+  http://cocoon.apache.org/schema/servlet http://cocoon.apache.org/schema/servlet/cocoon-servlet-1.0.xsd
+  http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
 
   <bean id="org.apache.cocoon.micro.cocoon-micro-it.service" class="org.apache.cocoon.sitemap.SitemapServlet">
     <servlet:context mount-path="" context-path="blockcontext:/cocoon-micro-it-block/"/>
   </bean>
+  
+  <bean name="demoStorage" class="java.util.HashMap" scope="servlet" lazy-init="true">
+    <aop:scoped-proxy proxy-target-class="false"/>
+  </bean>
 
+  <bean id="org.apache.cocoon.micro.cocoon-micro-it.Demo1" class="org.apache.cocoon.micro.it.DemoServlet"
lazy-init="true">
+    <servlet:context mount-path="/demo1" context-path="blockcontext:/cocoon-micro-it-block/"/>
+    <property name="storage" ref="demoStorage"/>
+  </bean>
+  
+  <bean id="org.apache.cocoon.micro.cocoon-micro-it.Demo2" class="org.apache.cocoon.micro.it.DemoServlet"
lazy-init="true">
+    <servlet:context mount-path="/demo2" context-path="blockcontext:/cocoon-micro-it-block/"/>
+    <property name="storage" ref="demoStorage"/>
+  </bean>
 </beans>

Added: cocoon/whiteboard/micro/misc/cocoon-webapp/src/test/java/org/apache/cocoon/micro/it/SerletScopeTest.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/micro/misc/cocoon-webapp/src/test/java/org/apache/cocoon/micro/it/SerletScopeTest.java?rev=619921&view=auto
==============================================================================
--- cocoon/whiteboard/micro/misc/cocoon-webapp/src/test/java/org/apache/cocoon/micro/it/SerletScopeTest.java
(added)
+++ cocoon/whiteboard/micro/misc/cocoon-webapp/src/test/java/org/apache/cocoon/micro/it/SerletScopeTest.java
Fri Feb  8 07:58:03 2008
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.micro.it;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.cocoon.tools.it.HtmlUnitTestCase;
+
+public class SerletScopeTest extends HtmlUnitTestCase {
+    
+    public void testServletScope() throws Exception {
+        this.loadResponse("/demo1/setCode?code=300");
+        assertEquals(HttpServletResponse.SC_OK, this.response.getStatusCode());
+        this.loadResponse("/demo2/setCode?code=301");
+        assertEquals(HttpServletResponse.SC_OK, this.response.getStatusCode());
+        
+        this.loadResponse("/demo1/getCode");
+        assertEquals(300, this.response.getStatusCode());
+        this.loadResponse("/demo2/getCode");
+        assertEquals(301, this.response.getStatusCode());
+    }
+}



Mime
View raw message