craigmcc    01/12/13 21:24:02

  Modified:    tester/src/bin tester.xml
               tester/src/tester/org/apache/tester Include00.java
  Added:       tester/web JspForward01.jsp JspForward01a.jsp
                        JspInclude01.jsp JspInclude01a.jsp JspInclude02.jsp
                        JspInclude02a.jsp
               tester/web/golden JspInclude01.txt JspInclude01a.txt
                        JspInclude02.txt JspInclude02a.txt
  Log:
  Add unit tests for RequestDispatcher.include() for all combinations of:
  * Servlet or JSP includer
  * Servlet or JSP includee
  * Flush or no-flush before include
  
  Currently, the RequestDispatcher implementation has a bug (no output in
  the response for the include or anything after it returns) whenever an
  include is performed after a flush (either because an including servlet
  called response.flushBuffer(), or because an including JSP page is
  exectuing a <jsp:include ... flush="true"/>).  This manifests itself as
  failures on the corresponding tests in the "Jsp" and "RequestDispatcher"
  targets.
  
  I suspect this bug was introduced during the recent refactorings for error
  page handling -- alas, our unit tests did not catch it :-(  I've looked
  for a while and can't find it yet.  Any ideas?
  
  Revision  Changes    Path
  1.76      +79 -11    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.75
  retrieving revision 1.76
  diff -u -r1.75 -r1.76
  --- tester.xml        2001/12/12 22:34:20     1.75
  +++ tester.xml        2001/12/14 05:24:02     1.76
  @@ -610,6 +610,30 @@
            request="${context.path}/JspDoc01.jsp" debug="${debug}"
             golden="${golden.path}/JspDoc01.txt"/>
   
  +    <!-- ========== JSP Forwards and Includes ============================= -->
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/JspForward01.jsp" debug="${debug}"
  +      outContent="JspForward01a PASSED"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/JspInclude01.jsp?path=/JspInclude01a.jsp" 
debug="${debug}"
  +          golden="${golden.path}/JspInclude01.txt"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/JspInclude02.jsp?path=/JspInclude02a.jsp" 
debug="${debug}"
  +          golden="${golden.path}/JspInclude02.txt"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/JspInclude01.jsp?path=/Include00a"
  +           debug="${debug}"
  +          golden="${golden.path}/JspInclude01a.txt"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/JspInclude02.jsp?path=/Include00a"
  +           debug="${debug}"
  +          golden="${golden.path}/JspInclude02a.txt"/>
  +
     </target>
   
   
  @@ -655,7 +679,7 @@
   
     <target name="RequestDispatcher">
   
  -    <!-- ========== Basic Forward and Include Functionality =============== -->
  +    <!-- ========== Basic Forward Functionality =========================== -->
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
            request="${context.path}/Forward00?path=/Forward00a"
  @@ -697,44 +721,88 @@
            request="${context.path}/WrappedForward00?path=!Forward00e"
         outContent="Forward00e PASSED" debug="${debug}"/>
   
  +    <!-- ========== Basic Include Functionality (flush=false) ============= -->
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/Include00?path=/Include00a&amp;flush=false"
  +      outContent="Include00a PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/WrappedInclude00?path=/Include00a&amp;flush=false"
  +      outContent="Include00a PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/Include00?path=/Include00b&amp;flush=false"
  +      outContent="Include00b PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/WrappedInclude00?path=/Include00b&amp;flush=false"
  +      outContent="Include00b PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/Include00?path=/Include00c.jsp&amp;flush=false"
  +      outContent="Include00c PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         
request="${context.path}/WrappedInclude00?path=/Include00c.jsp&amp;flush=false"
  +      outContent="Include00c PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/Include00?path=!Include00d&amp;flush=false"
  +      outContent="Include00d PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/WrappedInclude00?path=!Include00d&amp;flush=false"
  +      outContent="Include00d PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/Include00?path=!Include00e&amp;flush=false"
  +      outContent="Include00e PASSED" debug="${debug}"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/WrappedInclude00?path=!Include00e&amp;flush=false"
  +      outContent="Include00e PASSED" debug="${debug}"/>
  +
  +    <!-- ========== Basic Include Functionality (flush=true) ============== -->
  +
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="${context.path}/Include00?path=/Include00a"
  +         request="${context.path}/Include00?path=/Include00a&amp;flush=true"
         outContent="Include00a PASSED" debug="${debug}"/>
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="${context.path}/WrappedInclude00?path=/Include00a"
  +         request="${context.path}/WrappedInclude00?path=/Include00a&amp;flush=true"
         outContent="Include00a PASSED" debug="${debug}"/>
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="${context.path}/Include00?path=/Include00b"
  +         request="${context.path}/Include00?path=/Include00b&amp;flush=true"
         outContent="Include00b PASSED" debug="${debug}"/>
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="${context.path}/WrappedInclude00?path=/Include00b"
  +         request="${context.path}/WrappedInclude00?path=/Include00b&amp;flush=true"
         outContent="Include00b PASSED" debug="${debug}"/>
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="${context.path}/Include00?path=/Include00c.jsp"
  +         request="${context.path}/Include00?path=/Include00c.jsp&amp;flush=true"
         outContent="Include00c PASSED" debug="${debug}"/>
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="${context.path}/WrappedInclude00?path=/Include00c.jsp"
  +         
request="${context.path}/WrappedInclude00?path=/Include00c.jsp&amp;flush=true"
         outContent="Include00c PASSED" debug="${debug}"/>
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="${context.path}/Include00?path=!Include00d"
  +         request="${context.path}/Include00?path=!Include00d&amp;flush=true"
         outContent="Include00d PASSED" debug="${debug}"/>
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="${context.path}/WrappedInclude00?path=!Include00d"
  +         request="${context.path}/WrappedInclude00?path=!Include00d&amp;flush=true"
         outContent="Include00d PASSED" debug="${debug}"/>
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="${context.path}/Include00?path=!Include00e"
  +         request="${context.path}/Include00?path=!Include00e&amp;flush=true"
         outContent="Include00e PASSED" debug="${debug}"/>
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="${context.path}/WrappedInclude00?path=!Include00e"
  +         request="${context.path}/WrappedInclude00?path=!Include00e&amp;flush=true"
         outContent="Include00e PASSED" debug="${debug}"/>
   
       <!-- ========== Forward and Include to Static Resource ================ -->
  
  
  
  1.2       +11 -1     
jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/Include00.java
  
  Index: Include00.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/Include00.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Include00.java    2001/05/03 23:06:31     1.1
  +++ Include00.java    2001/12/14 05:24:02     1.2
  @@ -66,7 +66,7 @@
    * Exercise basic including functionality.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2001/05/03 23:06:31 $
  + * @version $Revision: 1.2 $ $Date: 2001/12/14 05:24:02 $
    */
   
   public class Include00 extends HttpServlet {
  @@ -85,6 +85,9 @@
           if (path == null)
               path = "/Include00a";
   
  +        // Acquire the flush flag
  +        boolean flush = "true".equals(request.getParameter("flush"));
  +
           // Create a request dispatcher and call include() on it
           RequestDispatcher rd = null;
           if (path.startsWith("!"))
  @@ -94,6 +97,13 @@
           if (rd == null) {
               sb.append(" No RequestDispatcher returned/");
           } else {
  +            if (flush) {
  +                try {
  +                    response.flushBuffer();
  +                } catch (IOException e) {
  +                    sb.append(" Flush threw IOException/");
  +                }
  +            }
               if (sb.length() < 1)
                   rd.include(request, response);
           }
  
  
  
  1.1                  jakarta-tomcat-4.0/tester/web/JspForward01.jsp
  
  Index: JspForward01.jsp
  ===================================================================
  <%@ page contentType="text/plain" %><jsp:forward page="JspForward01a.jsp"/>
  JspForward01 FAILED - Content from forwarded-to page not included
  
  
  
  1.1                  jakarta-tomcat-4.0/tester/web/JspForward01a.jsp
  
  Index: JspForward01a.jsp
  ===================================================================
  <%@ page contentType="text/plain" %>JspForward01a PASSED
  
  
  
  1.1                  jakarta-tomcat-4.0/tester/web/JspInclude01.jsp
  
  Index: JspInclude01.jsp
  ===================================================================
  <%@ page contentType="text/plain" %>This is before the include
  <jsp:include page="<%= request.getParameter(\"path\") %>" flush="true"/>
  This is after the include
  
  
  
  
  1.1                  jakarta-tomcat-4.0/tester/web/JspInclude01a.jsp
  
  Index: JspInclude01a.jsp
  ===================================================================
  <%@ page contentType="text/plain" %>This is the include
  
  
  
  1.1                  jakarta-tomcat-4.0/tester/web/JspInclude02.jsp
  
  Index: JspInclude02.jsp
  ===================================================================
  <%@ page contentType="text/plain" %>This is before the include
  <jsp:include page="<%= request.getParameter(\"path\") %>" flush="false"/>
  This is after the include
  
  
  
  
  1.1                  jakarta-tomcat-4.0/tester/web/JspInclude02a.jsp
  
  Index: JspInclude02a.jsp
  ===================================================================
  <%@ page contentType="text/plain" %>This is the include
  
  
  
  1.1                  jakarta-tomcat-4.0/tester/web/golden/JspInclude01.txt
  
  Index: JspInclude01.txt
  ===================================================================
  This is before the include
  This is the include
  
  This is after the include
  
  
  
  
  1.1                  jakarta-tomcat-4.0/tester/web/golden/JspInclude01a.txt
  
  Index: JspInclude01a.txt
  ===================================================================
  This is before the include
  Include00a PASSED
  
  This is after the include
  
  
  
  
  1.1                  jakarta-tomcat-4.0/tester/web/golden/JspInclude02.txt
  
  Index: JspInclude02.txt
  ===================================================================
  This is before the include
  This is the include
  
  This is after the include
  
  
  
  
  1.1                  jakarta-tomcat-4.0/tester/web/golden/JspInclude02a.txt
  
  Index: JspInclude02a.txt
  ===================================================================
  This is before the include
  Include00a PASSEDSessionListener01: sessionCreated()
  SessionListener02: sessionCreated()
  
  This is after the include
  
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to