cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gkossakow...@apache.org
Subject svn commit: r570075 - in /cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl: ./ src/ src/test/ src/test/java/ src/test/java/org/ src/test/java/org/apache/ src/test/java/org/apache/cocoon/ src/test/java/org/apache/cocoon/servletservice/
Date Mon, 27 Aug 2007 11:28:51 GMT
Author: gkossakowski
Date: Mon Aug 27 04:28:50 2007
New Revision: 570075

URL: http://svn.apache.org/viewvc?rev=570075&view=rev
Log:
COCOON-2038: Implemented infrastructure for unit testing of ServletServiceContext and added
basic test.

Added:
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/test/
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/test/java/
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/test/java/org/
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/test/java/org/apache/
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/test/java/org/apache/cocoon/
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/test/java/org/apache/cocoon/servletservice/
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/test/java/org/apache/cocoon/servletservice/ServletServiceContextTest.java
  (with props)
Modified:
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/pom.xml
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/   (props changed)

Modified: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/pom.xml?rev=570075&r1=570074&r2=570075&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/pom.xml (original)
+++ cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/pom.xml Mon Aug 27
04:28:50 2007
@@ -108,6 +108,15 @@
       <groupId>commons-collections</groupId>
       <artifactId>commons-collections</artifactId>
     </dependency>
+    <!-- test -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>easymock</groupId>
+      <artifactId>easymock</artifactId>
+    </dependency>
   </dependencies>
   
   <build>

Propchange: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Aug 27 04:28:50 2007
@@ -1 +1 @@
-site
+site

Added: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/test/java/org/apache/cocoon/servletservice/ServletServiceContextTest.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/test/java/org/apache/cocoon/servletservice/ServletServiceContextTest.java?rev=570075&view=auto
==============================================================================
--- cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/test/java/org/apache/cocoon/servletservice/ServletServiceContextTest.java
(added)
+++ cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/test/java/org/apache/cocoon/servletservice/ServletServiceContextTest.java
Mon Aug 27 04:28:50 2007
@@ -0,0 +1,86 @@
+/*
+* 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.servletservice;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import junit.framework.TestCase;
+
+import org.apache.cocoon.servletservice.util.BlockCallHttpServletRequest;
+import org.apache.cocoon.servletservice.util.BlockCallHttpServletResponse;
+import org.easymock.MockControl;
+
+public class ServletServiceContextTest extends TestCase {
+    
+    private ServletServiceContext mainContext;
+    private Servlet servletA;
+    private Servlet servletB;
+    private MockControl servletAControl;
+    private MockControl servletBControl;
+    
+    private MockControl servletAConfigControl;
+    private ServletConfig servletAConfig;
+    
+    private ServletServiceContext servletAContext;
+    
+    
+    protected void setUp() throws Exception {
+        super.setUp();
+        this.mainContext = new ServletServiceContext();
+        
+        servletAControl = MockControl.createControl(Servlet.class);
+        servletA = (Servlet)servletAControl.getMock();
+        
+        servletAContext = new ServletServiceContext();
+        servletAContext.setServlet(servletA);
+        
+        servletAConfigControl = MockControl.createControl(ServletConfig.class);
+        servletAConfig = (ServletConfig)servletAConfigControl.getMock();
+        servletAConfig.getServletContext();
+        servletAConfigControl.setReturnValue(servletAContext);
+        
+        servletA.getServletConfig();
+        servletAControl.setReturnValue(servletAConfig);
+        
+        Map connections = new HashMap();
+        connections.put("servletA", servletA);
+        mainContext.setConnections(connections);
+    }
+    
+    public void testBasicConnection() throws Exception {
+        ServletRequest request = new BlockCallHttpServletRequest(new URI("dummy"), null);
+        ServletResponse response = new BlockCallHttpServletResponse();
+       
+        servletA.service(request, response);
+        servletAControl.replay();
+        servletAConfigControl.replay();
+        
+        RequestDispatcher dispatcher = mainContext.getNamedDispatcher("servletA");
+        dispatcher.forward(request, response);
+        
+        servletAControl.verify();
+        servletAConfigControl.verify();
+    }
+}

Propchange: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/test/java/org/apache/cocoon/servletservice/ServletServiceContextTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/test/java/org/apache/cocoon/servletservice/ServletServiceContextTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message