craigmcc    01/08/15 16:44:24

  Modified:    tester/src/bin tester.xml
               tester/web/WEB-INF web.xml
  Added:       tester/src/tester/org/apache/tester Forward09.java
                        Include09.java
  Log:
  Add unit tests for ServletRequest.getRequestDispatcher(), with both
  relative and absolute paths, doing both forwards and includes.
  
  Revision  Changes    Path
  1.65      +98 -0     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.64
  retrieving revision 1.65
  diff -u -r1.64 -r1.65
  --- tester.xml        2001/08/15 00:57:08     1.64
  +++ tester.xml        2001/08/15 23:44:23     1.65
  @@ -823,6 +823,104 @@
            request="${context.path}/servlet/Forward08"
         outContent="Forward08b PASSED" debug="${debug}"/>
   
  +    <!-- ========== ServletRequest.getRequestDispatcher() ================= -->
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/Forward09?path=/Forward00a"
  +      outContent="Forward00a PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/WrappedForward09?path=/Forward00a"
  +      outContent="Forward00a PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/Forward09?path=/Forward00b"
  +      outContent="Forward00b PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/WrappedForward09?path=/Forward00b"
  +      outContent="Forward00b PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/Forward09?path=/Forward00c.jsp"
  +      outContent="Forward00c PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/WrappedForward09?path=/Forward00c.jsp"
  +      outContent="Forward00c PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/Forward09?path=Forward00a"
  +      outContent="Forward00a PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/WrappedForward09?path=Forward00a"
  +      outContent="Forward00a PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/Forward09?path=Forward00b"
  +      outContent="Forward00b PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/WrappedForward09?path=Forward00b"
  +      outContent="Forward00b PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/Forward09?path=Forward00c.jsp"
  +      outContent="Forward00c PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/WrappedForward09?path=Forward00c.jsp"
  +      outContent="Forward00c PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/Include09?path=/Include00a"
  +      outContent="Include00a PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/WrappedInclude09?path=/Include00a"
  +      outContent="Include00a PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/Include09?path=/Include00b"
  +      outContent="Include00b PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/WrappedInclude09?path=/Include00b"
  +      outContent="Include00b PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/Include09?path=/Include00c.jsp"
  +      outContent="Include00c PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/WrappedInclude09?path=/Include00c.jsp"
  +      outContent="Include00c PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/Include09?path=Include00a"
  +      outContent="Include00a PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/WrappedInclude09?path=Include00a"
  +      outContent="Include00a PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/Include09?path=Include00b"
  +      outContent="Include00b PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/WrappedInclude09?path=Include00b"
  +      outContent="Include00b PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/Include09?path=Include00c.jsp"
  +      outContent="Include00c PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/WrappedInclude09?path=Include00c.jsp"
  +      outContent="Include00c PASSED" debug="${debug}"/>
  +
       <!-- ========== Response Wrapping ===================================== -->
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
  
  
  
  1.1                  
jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/Forward09.java
  
  Index: Forward09.java
  ===================================================================
  /* ========================================================================= *
   *                                                                           *
   *                 The Apache Software License,  Version 1.1                 *
   *                                                                           *
   *      Copyright (c) 1999, 2000, 2001  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 javax.servlet.*;
  import javax.servlet.http.*;
  
  /**
   * Exercise basic forwarding functionality using
   * <code>request.getRequestDispatcher()</code>.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2001/08/15 23:44:24 $
   */
  
  public class Forward09 extends HttpServlet {
  
  
      public void doGet(HttpServletRequest request, HttpServletResponse response)
          throws IOException, ServletException {
  
          // Prepare this response
          StringBuffer sb = new StringBuffer();
          response.setContentType("text/plain");
        PrintWriter writer = response.getWriter();
  
          // Acquire the path to which we will issue a forward
          String path = request.getParameter("path");
          if (path == null)
              path = "/Forward00a";
  
          // Create a request dispatcher and call forward() on it
          RequestDispatcher rd = request.getRequestDispatcher(path);
          if (rd == null) {
              sb.append(" No RequestDispatcher returned/");
          } else {
              if (sb.length() < 1)
                  rd.forward(request, response);
          }
  
          // Write our response if an error occurred
          if (sb.length() >= 1) {
              writer.print("Forward09 FAILED -");
              writer.println(sb.toString());
              while (true) {
                  String message = StaticLogger.read();
                  if (message == null)
                      break;
                  writer.println(message);
              }
          }
          StaticLogger.reset();
  
      }
  
  }
  
  
  
  1.1                  
jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/Include09.java
  
  Index: Include09.java
  ===================================================================
  /* ========================================================================= *
   *                                                                           *
   *                 The Apache Software License,  Version 1.1                 *
   *                                                                           *
   *      Copyright (c) 1999, 2000, 2001  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 javax.servlet.*;
  import javax.servlet.http.*;
  
  /**
   * Exercise basic including functionality using
   * <code>request.getRequestDispatcher()</code>.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2001/08/15 23:44:24 $
   */
  
  public class Include09 extends HttpServlet {
  
  
      public void doGet(HttpServletRequest request, HttpServletResponse response)
          throws IOException, ServletException {
  
          // Prepare this response
          StringBuffer sb = new StringBuffer();
          response.setContentType("text/plain");
        PrintWriter writer = response.getWriter();
  
          // Acquire the path to which we will issue a include
          String path = request.getParameter("path");
          if (path == null)
              path = "/Include00a";
  
          // Create a request dispatcher and call include() on it
          RequestDispatcher rd = request.getRequestDispatcher(path);
          if (rd == null) {
              sb.append(" No RequestDispatcher returned/");
          } else {
              if (sb.length() < 1)
                  rd.include(request, response);
          }
  
          // Write our response if an error occurred
          if (sb.length() >= 1) {
              writer.print("Include00 FAILED -");
              writer.println(sb.toString());
              while (true) {
                  String message = StaticLogger.read();
                  if (message == null)
                      break;
                  writer.println(message);
              }
          }
          StaticLogger.reset();
  
      }
  
  }
  
  
  
  1.46      +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.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- web.xml   2001/07/25 04:27:11     1.45
  +++ web.xml   2001/08/15 23:44:24     1.46
  @@ -220,6 +220,11 @@
   
       <filter-mapping>
           <filter-name>HttpFilter</filter-name>
  +        <url-pattern>/WrappedForward09</url-pattern>
  +    </filter-mapping>
  +
  +    <filter-mapping>
  +        <filter-name>HttpFilter</filter-name>
           <url-pattern>/WrappedGetHeaders01</url-pattern>
       </filter-mapping>
   
  @@ -285,6 +290,11 @@
   
       <filter-mapping>
           <filter-name>HttpFilter</filter-name>
  +        <url-pattern>/WrappedInclude09</url-pattern>
  +    </filter-mapping>
  +
  +    <filter-mapping>
  +        <filter-name>HttpFilter</filter-name>
           <url-pattern>/WrappedJndi01</url-pattern>
       </filter-mapping>
   
  @@ -657,6 +667,11 @@
       </servlet>
   
       <servlet>
  +        <servlet-name>Forward09</servlet-name>
  +        <servlet-class>org.apache.tester.Forward09</servlet-class>
  +    </servlet>
  +
  +    <servlet>
           <servlet-name>GetHeaders01</servlet-name>
           <servlet-class>org.apache.tester.GetHeaders01</servlet-class>
       </servlet>
  @@ -787,6 +802,11 @@
       </servlet>
   
       <servlet>
  +        <servlet-name>Include09</servlet-name>
  +        <servlet-class>org.apache.tester.Include09</servlet-class>
  +    </servlet>
  +
  +    <servlet>
           <servlet-name>Jndi01</servlet-name>
           <servlet-class>org.apache.tester.Jndi01</servlet-class>
           <load-on-startup>1</load-on-startup>
  @@ -1243,6 +1263,16 @@
       </servlet-mapping>
   
       <servlet-mapping>
  +        <servlet-name>Forward09</servlet-name>
  +        <url-pattern>/Forward09</url-pattern>
  +    </servlet-mapping>
  +
  +    <servlet-mapping>
  +        <servlet-name>Forward09</servlet-name>
  +        <url-pattern>/WrappedForward09</url-pattern>
  +    </servlet-mapping>
  +
  +    <servlet-mapping>
           <servlet-name>GetHeaders01</servlet-name>
           <url-pattern>/GetHeaders01</url-pattern>
       </servlet-mapping>
  @@ -1435,6 +1465,16 @@
       <servlet-mapping>
           <servlet-name>Include07c</servlet-name>
           <url-pattern>/Include07c</url-pattern>
  +    </servlet-mapping>
  +
  +    <servlet-mapping>
  +        <servlet-name>Include09</servlet-name>
  +        <url-pattern>/Include09</url-pattern>
  +    </servlet-mapping>
  +
  +    <servlet-mapping>
  +        <servlet-name>Include09</servlet-name>
  +        <url-pattern>/WrappedInclude09</url-pattern>
       </servlet-mapping>
   
       <servlet-mapping>
  
  
  

Reply via email to