craigmcc 01/01/05 18:38:13
Modified: tester/src/bin tester.xml
tester/web/WEB-INF web.xml
Added: tester/src/tester/org/apache/tester Forward01.java
Include01.java
tester/web Forward01.txt Include01.txt
Log:
Add unit tests that prove we can do RequestDispatcher.include() and
RequestDispatcher.forward() calls to a static resource (i.e. a file served
by the default file-serving servlet. A bug existed in milestone 4 and has
since been fixed -- adding the unit tests will help ensure that we don't
regress while making changes later.
Revision Changes Path
1.7 +24 -1 jakarta-tomcat-4.0/tester/src/bin/tester.xml
Index: tester.xml
===================================================================
RCS file: /home/cvs/jakarta-tomcat-4.0/tester/src/bin/tester.xml,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- tester.xml 2001/01/03 05:50:45 1.6
+++ tester.xml 2001/01/06 02:38:12 1.7
@@ -10,7 +10,7 @@
<taskdef name="tester" classname="org.apache.tester.TestClient"/>
- <target name="all" depends="ROOT,CaseSensitive,ServletRequest,ServletResponse"/>
+ <target name="all"
depends="ROOT,CaseSensitive,RequestDispatcher,ServletRequest,ServletResponse"/>
<target name="ROOT">
@@ -89,6 +89,29 @@
<tester host="${host}" port="${port}" protocol="${protocol}"
request="/Examples/servlet/HelloWorldExample"
status="404"/>
+
+ </target>
+
+
+ <target name="RequestDispatcher">
+
+ <!-- ========== Forward and Include to Static Resource ================ -->
+
+ <tester host="${host}" port="${port}" protocol="${protocol}"
+ request="${context.path}/Forward01"
+ outContent="Forward01 PASSED"/>
+
+ <tester host="${host}" port="${port}" protocol="${protocol}"
+ request="${context.path}/WrappedForward01"
+ outContent="Forward01 PASSED"/>
+
+ <tester host="${host}" port="${port}" protocol="${protocol}"
+ request="${context.path}/Include01"
+ outContent="Include01 PASSED"/>
+
+ <tester host="${host}" port="${port}" protocol="${protocol}"
+ request="${context.path}/WrappedInclude01"
+ outContent="Include01 PASSED"/>
</target>
1.1
jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/Forward01.java
Index: Forward01.java
===================================================================
/* ========================================================================= *
* *
* The Apache Software License, Version 1.1 *
* *
* Copyright (c) 1999, 2000 The Apache Software Foundation. *
* All rights reserved. *
* *
* ========================================================================= *
* *
* Redistribution and use in source and binary forms, with or without modi- *
* fication, are permitted provided that the following conditions are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice *
* notice, this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. The end-user documentation included with the redistribution, if any, *
* must include the following acknowlegement: *
* *
* "This product includes software developed by the Apache Software *
* Foundation <http://www.apache.org/>." *
* *
* Alternately, this acknowlegement may appear in the software itself, if *
* and wherever such third-party acknowlegements normally appear. *
* *
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software *
* Foundation" must not be used to endorse or promote products derived *
* from this software without prior written permission. For written *
* permission, please contact <[EMAIL PROTECTED]>. *
* *
* 5. Products derived from this software may not be called "Apache" nor may *
* "Apache" appear in their names without prior written permission of the *
* Apache Software Foundation. *
* *
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY *
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY *
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL *
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS *
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, *
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN *
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
* ========================================================================= *
* *
* This software consists of voluntary contributions made by many indivi- *
* duals on behalf of the Apache Software Foundation. For more information *
* on the Apache Software Foundation, please see <http://www.apache.org/>. *
* *
* ========================================================================= */
package org.apache.tester;
import java.io.*;
import java.security.Principal;
import javax.servlet.*;
import javax.servlet.http.*;
/**
* Positive test for forwarding to a static resource.
*
* @author Craig R. McClanahan
* @version $Revision: 1.1 $ $Date: 2001/01/06 02:38:13 $
*/
public class Forward01 extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
response.setContentType("text/plain");
RequestDispatcher rd =
getServletContext().getRequestDispatcher("/Forward01.txt");
if (rd == null) {
PrintWriter writer = response.getWriter();
writer.println("Forward01 FAILED - No RequestDispatcher returned");
return;
}
rd.forward(request, response);
StaticLogger.reset();
}
}
1.1
jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/Include01.java
Index: Include01.java
===================================================================
/* ========================================================================= *
* *
* The Apache Software License, Version 1.1 *
* *
* Copyright (c) 1999, 2000 The Apache Software Foundation. *
* All rights reserved. *
* *
* ========================================================================= *
* *
* Redistribution and use in source and binary forms, with or without modi- *
* fication, are permitted provided that the following conditions are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice *
* notice, this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. The end-user documentation included with the redistribution, if any, *
* must include the following acknowlegement: *
* *
* "This product includes software developed by the Apache Software *
* Foundation <http://www.apache.org/>." *
* *
* Alternately, this acknowlegement may appear in the software itself, if *
* and wherever such third-party acknowlegements normally appear. *
* *
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software *
* Foundation" must not be used to endorse or promote products derived *
* from this software without prior written permission. For written *
* permission, please contact <[EMAIL PROTECTED]>. *
* *
* 5. Products derived from this software may not be called "Apache" nor may *
* "Apache" appear in their names without prior written permission of the *
* Apache Software Foundation. *
* *
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY *
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY *
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL *
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS *
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, *
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN *
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
* ========================================================================= *
* *
* This software consists of voluntary contributions made by many indivi- *
* duals on behalf of the Apache Software Foundation. For more information *
* on the Apache Software Foundation, please see <http://www.apache.org/>. *
* *
* ========================================================================= */
package org.apache.tester;
import java.io.*;
import java.security.Principal;
import javax.servlet.*;
import javax.servlet.http.*;
/**
* Positive test for including a static resource.
*
* @author Craig R. McClanahan
* @version $Revision: 1.1 $ $Date: 2001/01/06 02:38:13 $
*/
public class Include01 extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
response.setContentType("text/plain");
RequestDispatcher rd =
getServletContext().getRequestDispatcher("/Include01.txt");
if (rd == null) {
PrintWriter writer = response.getWriter();
writer.println("Include01 FAILED - No RequestDispatcher returned");
return;
}
rd.include(request, response);
StaticLogger.reset();
}
}
1.1 jakarta-tomcat-4.0/tester/web/Forward01.txt
Index: Forward01.txt
===================================================================
Forward01 PASSED
1.1 jakarta-tomcat-4.0/tester/web/Include01.txt
Index: Include01.txt
===================================================================
Include01 PASSED
1.6 +40 -0 jakarta-tomcat-4.0/tester/web/WEB-INF/web.xml
Index: web.xml
===================================================================
RCS file: /home/cvs/jakarta-tomcat-4.0/tester/web/WEB-INF/web.xml,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- web.xml 2001/01/03 05:50:46 1.5
+++ web.xml 2001/01/06 02:38:13 1.6
@@ -42,6 +42,11 @@
<filter-mapping>
<filter-name>HttpFilter</filter-name>
+ <url-pattern>/WrappedForward01</url-pattern>
+ </filter-mapping>
+
+ <filter-mapping>
+ <filter-name>HttpFilter</filter-name>
<url-pattern>/WrappedGetHeaders01</url-pattern>
</filter-mapping>
@@ -66,6 +71,11 @@
</filter-mapping>
<filter-mapping>
+ <filter-name>HttpFilter</filter-name>
+ <url-pattern>/WrappedInclude01</url-pattern>
+ </filter-mapping>
+
+ <filter-mapping>
<filter-name>GenericFilter</filter-name>
<url-pattern>/WrappedReset01</url-pattern>
</filter-mapping>
@@ -94,6 +104,11 @@
</servlet>
<servlet>
+ <servlet-name>Forward01</servlet-name>
+ <servlet-class>org.apache.tester.Forward01</servlet-class>
+ </servlet>
+
+ <servlet>
<servlet-name>GetHeaders01</servlet-name>
<servlet-class>org.apache.tester.GetHeaders01</servlet-class>
</servlet>
@@ -119,6 +134,11 @@
</servlet>
<servlet>
+ <servlet-name>Include01</servlet-name>
+ <servlet-class>org.apache.tester.Include01</servlet-class>
+ </servlet>
+
+ <servlet>
<servlet-name>Reset01</servlet-name>
<servlet-class>org.apache.tester.Reset01</servlet-class>
</servlet>
@@ -146,6 +166,16 @@
</servlet-mapping>
<servlet-mapping>
+ <servlet-name>Forward01</servlet-name>
+ <url-pattern>/Forward01</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>Forward01</servlet-name>
+ <url-pattern>/WrappedForward01</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
<servlet-name>GetHeaders01</servlet-name>
<url-pattern>/GetHeaders01</url-pattern>
</servlet-mapping>
@@ -198,6 +228,16 @@
<servlet-mapping>
<servlet-name>GetQueryString01</servlet-name>
<url-pattern>/WrappedGetQueryString01</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>Include01</servlet-name>
+ <url-pattern>/Include01</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>Include01</servlet-name>
+ <url-pattern>/WrappedInclude01</url-pattern>
</servlet-mapping>
<servlet-mapping>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]