craigmcc    00/12/22 14:13:09

  Modified:    tester/src/bin tester.xml
               tester/src/tester/org/apache/tester GetInputStream01.java
                        GetParameter01.java GetParameterMap00.java
                        GetQueryString01.java TestClient.java
               tester/web/WEB-INF web.xml
  Added:       tester/src/tester/org/apache/tester SetBufferSize01.java
                        StaticLogger.java
                        TesterHttpServletResponseWrapper.java
                        TesterServletRequestWrapper.java
                        TesterServletResponseWrapper.java
                        WrapperFilter.java
  Log:
  Extend the unit testing framework with wrappers for the request and
  response objects that can be configurably added with a Filter defined
  in the web.xml file.  Now, where it makes sense, we can run the wrapped
  and unwrapped version of the same test, to ensure that introducing
  wrappers does not cause any functional problems.
  
  In addition, a logger that uses static methods has been added to allow
  messages from various components of a test (such as filters and wrappers)
  to be accumulated and added to the response message.
  
  TODO:  TesterHttpServletRequestWrapper needs to be written, and
  WrapperFilter needs to use it if so configured.  This will allow the
  wrapped version of the GetQueryString01 test to be uncommented.
  
  TODO:  Golden file support needs to be added to the test client, so that
  the entire response can be validated (not just the first line, as is done
  on "outContent".  This will be needed to validate information added to the
  response from the static logger.
  
  Revision  Changes    Path
  1.2       +37 -3     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- tester.xml        2000/12/18 05:06:12     1.1
  +++ tester.xml        2000/12/22 22:13:06     1.2
  @@ -8,7 +8,7 @@
     <taskdef  name="tester"     classname="org.apache.tester.TestClient"/>
   
   
  -  <target name="all" depends="ROOT,CaseSensitive,ServletRequest"/>
  +  <target name="all" depends="ROOT,CaseSensitive,ServletRequest,ServletResponse"/>
   
   
     <target name="ROOT">
  @@ -99,10 +99,27 @@
            request="${context.path}/GetParameter01?foo=1"
         outContent="GetParameter01 PASSED"/>
   
  +    <tester host="${host}" port="${port}" debug="0"
  +         request="${context.path}/WrappedGetParameter01?foo=1"
  +      outContent="GetParameter01 PASSED"/>
  +
       <tester host="${host}" port="${port}"
  +         
request="${context.path}/GetParameterMap00?BestLanguage=Java&amp;BestJSP=Java2"
  +      outContent="GetParameterMap00 PASSED"/>
  +
  +    <tester host="${host}" port="${port}" debug="0"
  +         
request="${context.path}/WrappedGetParameterMap00?BestLanguage=Java&amp;BestJSP=Java2"
  +      outContent="GetParameterMap00 PASSED"/>
  +
  +    <tester host="${host}" port="${port}"
            request="${context.path}/GetQueryString01?foo=1"
         outContent="GetQueryString01 PASSED"/>
   
  +<!--
  +    <tester host="${host}" port="${port}" debug="0"
  +         request="${context.path}/WrappedGetQueryString01?foo=1"
  +      outContent="GetQueryString01 PASSED"/>
  +-->
   
       <!-- ========== Other ServletRequest Tests ============================ -->
   
  @@ -114,8 +131,8 @@
         outContent="GetInputStream01 PASSED"/>
   
       <tester host="${host}" port="${port}"
  -         
request="${context.path}/GetParameterMap00?BestLanguage=Java&amp;BestJSP=Java2"
  -      outContent="GetParameterMap00 PASSED"/>
  +         request="${context.path}/WrappedGetInputStream01"
  +      outContent="GetInputStream01 PASSED"/>
   
   
       <!-- ========== Authentication ======================================== -->
  @@ -135,6 +152,23 @@
            request="${context.path}/protected/Authentication02"
          inHeaders="Authorization:Basic dG9tY2F0OnRvbWNhdA=="
         outContent="Authentication02 PASSED"/>
  +
  +
  +  </target>
  +
  +
  +  <target name="ServletResponse">
  +
  +
  +    <!-- ========== Other ServletResponse Tests =========================== -->
  +
  +    <tester host="${host}" port="${port}"
  +         request="${context.path}/SetBufferSize01"
  +      outContent="SetBufferSize01 PASSED"/>
  +
  +    <tester host="${host}" port="${port}" debug="0"
  +         request="${context.path}/WrappedSetBufferSize01"
  +      outContent="SetBufferSize01 PASSED"/>
   
   
     </target>
  
  
  
  1.2       +10 -3     
jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/GetInputStream01.java
  
  Index: GetInputStream01.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/GetInputStream01.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GetInputStream01.java     2000/12/18 05:06:13     1.1
  +++ GetInputStream01.java     2000/12/22 22:13:06     1.2
  @@ -67,12 +67,12 @@
    * This should throw an IllegalStateException.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/12/18 05:06:13 $
  + * @version $Revision: 1.2 $ $Date: 2000/12/22 22:13:06 $
    */
   
  -public class GetInputStream01 extends HttpServlet {
  +public class GetInputStream01 extends GenericServlet {
   
  -    public void doGet(HttpServletRequest request, HttpServletResponse response)
  +    public void service(ServletRequest request, ServletResponse response)
           throws IOException, ServletException {
   
           response.setContentType("text/plain");
  @@ -85,6 +85,13 @@
           } catch (IllegalStateException e) {
               writer.println("GetInputStream01 PASSED");
           }
  +        while (true) {
  +            String message = StaticLogger.read();
  +            if (message == null)
  +                break;
  +            writer.println(message);
  +        }
  +        StaticLogger.reset();
   
       }
   
  
  
  
  1.2       +10 -3     
jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/GetParameter01.java
  
  Index: GetParameter01.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/GetParameter01.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GetParameter01.java       2000/12/18 05:06:13     1.1
  +++ GetParameter01.java       2000/12/22 22:13:06     1.2
  @@ -67,12 +67,12 @@
    * URI like "/tester/GetParameter01?foo=1".
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/12/18 05:06:13 $
  + * @version $Revision: 1.2 $ $Date: 2000/12/22 22:13:06 $
    */
   
  -public class GetParameter01 extends HttpServlet {
  +public class GetParameter01 extends GenericServlet {
   
  -    public void doGet(HttpServletRequest request, HttpServletResponse response)
  +    public void service(ServletRequest request, ServletResponse response)
           throws IOException, ServletException {
   
           response.setContentType("text/plain");
  @@ -85,6 +85,13 @@
               writer.println("GetParameter01 FAILED - Received '" + result +
                              "' instead of '" + expected + "'");
           }
  +        while (true) {
  +            String message = StaticLogger.read();
  +            if (message == null)
  +                break;
  +            writer.println(message);
  +        }
  +        StaticLogger.reset();
   
       }
   
  
  
  
  1.2       +10 -3     
jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/GetParameterMap00.java
  
  Index: GetParameterMap00.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/GetParameterMap00.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GetParameterMap00.java    2000/12/18 05:06:13     1.1
  +++ GetParameterMap00.java    2000/12/22 22:13:07     1.2
  @@ -68,12 +68,12 @@
    * This should throw an IllegalStateException.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/12/18 05:06:13 $
  + * @version $Revision: 1.2 $ $Date: 2000/12/22 22:13:07 $
    */
   
  -public class GetParameterMap00 extends HttpServlet {
  +public class GetParameterMap00 extends GenericServlet {
   
  -    public void doGet(HttpServletRequest request, HttpServletResponse response)
  +    public void service(ServletRequest request, ServletResponse response)
           throws IOException, ServletException {
   
           response.setContentType("text/plain");
  @@ -114,6 +114,13 @@
           else {
               writer.println("GetParameterMap00 FAILED:" + errors);
           }
  +        while (true) {
  +            String message = StaticLogger.read();
  +            if (message == null)
  +                break;
  +            writer.println(message);
  +        }
  +        StaticLogger.reset();
   
       }
   
  
  
  
  1.2       +8 -1      
jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/GetQueryString01.java
  
  Index: GetQueryString01.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/GetQueryString01.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GetQueryString01.java     2000/12/18 05:06:13     1.1
  +++ GetQueryString01.java     2000/12/22 22:13:07     1.2
  @@ -67,7 +67,7 @@
    * URI like "/tester/GetQueryString01?foo=1".
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/12/18 05:06:13 $
  + * @version $Revision: 1.2 $ $Date: 2000/12/22 22:13:07 $
    */
   
   public class GetQueryString01 extends HttpServlet {
  @@ -85,6 +85,13 @@
               writer.println("GetQueryString01 FAILED - Received '" + result +
                              "' instead of '" + expected + "'");
           }
  +        while (true) {
  +            String message = StaticLogger.read();
  +            if (message == null)
  +                break;
  +            writer.println(message);
  +        }
  +        StaticLogger.reset();
   
       }
   
  
  
  
  1.2       +6 -1      
jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/TestClient.java
  
  Index: TestClient.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/TestClient.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestClient.java   2000/12/18 05:06:13     1.1
  +++ TestClient.java   2000/12/22 22:13:07     1.2
  @@ -110,7 +110,7 @@
    * </ul>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/12/18 05:06:13 $
  + * @version $Revision: 1.2 $ $Date: 2000/12/22 22:13:07 $
    */
   
   public class TestClient extends Task {
  @@ -342,6 +342,7 @@
   
               // Acquire the response data, if there is any
               String outData = "";
  +            String outText = "";
               boolean eol = false;
               InputStream is = conn.getInputStream();
               if (is != null) {
  @@ -354,6 +355,8 @@
                           eol = true;
                       if (!eol)
                           outData += ch;
  +                    else
  +                        outText += ch;
                   }
                   is.close();
               }
  @@ -370,6 +373,8 @@
                       System.out.println("HEAD: " + name + ": " + value);
                   }
                   System.out.println("DATA: " + outData);
  +                if (outText.length() > 2)
  +                    System.out.println("TEXT: " + outText);
               }
   
               // Validate the response against our criteria
  
  
  
  1.1                  
jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/SetBufferSize01.java
  
  Index: SetBufferSize01.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.util.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  
  
  /**
   * Negative test for ServletResponse.setBufferSize().
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/12/22 22:13:07 $
   */
  
  public class SetBufferSize01 extends GenericServlet {
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Process a servlet request and create the corresponding response.
       *
       * @param request The request we are processing
       * @param response The response we are creating
       *
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet error occurs
       */
      public void service(ServletRequest request, ServletResponse response)
          throws IOException, ServletException {
  
          response.setContentType("text/plain");
          PrintWriter writer = response.getWriter();
          try {
              writer.println("TEST");
              response.setBufferSize(100);
              response.reset();
              writer.println("SetBufferSize01 FAILED - Did not throw 
IllegalStateException");
          } catch (IllegalStateException e) {
              response.reset();
              writer.println("SetBufferSize01 PASSED");
          }
          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/StaticLogger.java
  
  Index: StaticLogger.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.util.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  
  
  /**
   * Logger that uses a static message buffer to facilitate intra-web-app
   * recording and retrieval of log messages.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/12/22 22:13:07 $
   */
  
  public class StaticLogger {
  
  
      // ----------------------------------------------------------- Constructors
  
  
      // ------------------------------------------------------- Static Variables
  
  
      /**
       * The set of messages that have been logged.
       */
      protected static ArrayList messages = new ArrayList();
  
  
      /**
       * The index of the next message that will be retrieved by a read() call.
       */
      protected static int position = 0;
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Return the next message that has been logged, or <code>null</code>
       * if there are no more messages.
       */
      public static String read() {
  
          synchronized (messages) {
              if (position < messages.size())
                  return ((String) messages.get(position++));
              else
                  return (null);
          }
  
      }
  
  
      /**
       * Reset the messages buffer and position.
       */
      public static void reset() {
  
          synchronized (messages) {
              messages.clear();
              position = 0;
          }
  
      }
  
  
      /**
       * Write a new message to the end of the messages buffer.
       *
       * @param message The message to be added
       */
      public static void write(String message) {
  
          synchronized (messages) {
              messages.add(message);
          }
  
      }
  
  
  }
  
  
  
  1.1                  
jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/TesterHttpServletResponseWrapper.java
  
  Index: TesterHttpServletResponseWrapper.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.util.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  
  /**
   * Tester response wrapper that logs all calls to the configured logger,
   * before passing them on to the underlying response.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/12/22 22:13:07 $
   */
  
  public class TesterHttpServletResponseWrapper
      extends HttpServletResponseWrapper {
  
  
      // ------------------------------------------------------------ Constructor
  
  
      /**
       * Configure a new response wrapper.
       *
       * @param response The response we are wrapping
       */
      public TesterHttpServletResponseWrapper(HttpServletResponse response) {
  
          super(response);
  
      }
  
  
      // --------------------------------------------------------- Public Methods
  
  
      // For each public method, log the call and pass it to the wrapped response
  
  
      public void addCookie(Cookie cookie) {
          StaticLogger.write("TesterHttpServletResponseWrapper.addCookie()");
          ((HttpServletResponse) getResponse()).addCookie(cookie);
      }
  
  
      public void addDateHeader(String name, long value) {
          StaticLogger.write("TesterHttpServletResponseWrapper.addDateHeader()");
          ((HttpServletResponse) getResponse()).addDateHeader(name, value);
      }
  
  
      public void addHeader(String name, String value) {
          StaticLogger.write("TesterHttpServletResponseWrapper.addHeader()");
          ((HttpServletResponse) getResponse()).addHeader(name, value);
      }
  
  
      public void addIntHeader(String name, int value) {
          StaticLogger.write("TesterHttpServletResponseWrapper.addIntHeader()");
          ((HttpServletResponse) getResponse()).addIntHeader(name, value);
      }
  
  
      public boolean containsHeader(String name) {
          StaticLogger.write("TesterHttpServletResponseWrapper.containsHeader()");
          return (((HttpServletResponse) getResponse()).containsHeader(name));
      }
  
  
      public String encodeURL(String url) {
          StaticLogger.write("TesterHttpServletResponseWrapper.encodeURL()");
          return (((HttpServletResponse) getResponse()).encodeURL(url));
      }
  
  
      public String encodeUrl(String url) {
          StaticLogger.write("TesterHttpServletResponseWrapper.encodeUrl()");
          return (((HttpServletResponse) getResponse()).encodeUrl(url));
      }
  
  
      public String encodeRedirectURL(String url) {
          StaticLogger.write("TesterHttpServletResponseWrapper.encodeRedirectURL()");
          return (((HttpServletResponse) getResponse()).encodeRedirectURL(url));
      }
  
  
      public String encodeRedirectUrl(String url) {
          StaticLogger.write("TesterHttpServletResponseWrapper.encodeRedirectUrl()");
          return (((HttpServletResponse) getResponse()).encodeRedirectUrl(url));
      }
  
  
      public void flushBuffer() throws IOException {
          StaticLogger.write("TesterHttpServletResponseWrapper.flushBuffer()");
          getResponse().flushBuffer();
      }
  
  
      public int getBufferSize() {
          StaticLogger.write("TesterHttpServletResponseWrapper.getBufferSize()");
          return (getResponse().getBufferSize());
      }
  
  
      public String getCharacterEncoding() {
          
StaticLogger.write("TesterHttpServletResponseWrapper.getCharacterEncoding()");
          return (getResponse().getCharacterEncoding());
      }
  
  
      public Locale getLocale() {
          StaticLogger.write("TesterHttpServletResponseWrapper.getLocale()");
          return (getResponse().getLocale());
      }
  
  
      public ServletOutputStream getOutputStream() throws IOException {
          StaticLogger.write("TesterHttpServletResponseWrapper.getOutputStream()");
          return (getResponse().getOutputStream());
      }
  
  
      public PrintWriter getWriter() throws IOException {
          StaticLogger.write("TesterHttpServletResponseWrapper.getWriter()");
          return (getResponse().getWriter());
      }
  
  
      public boolean isCommitted() {
          StaticLogger.write("TesterHttpServletResponseWrapper.isCommitted()");
          return (getResponse().isCommitted());
      }
  
  
      public void reset() {
          StaticLogger.write("TesterHttpServletResponseWrapper.reset()");
          getResponse().reset();
      }
  
  
      public void resetBuffer() {
          StaticLogger.write("TesterHttpServletResponseWrapper.resetBuffer()");
          getResponse().resetBuffer();
      }
  
  
      public void sendError(int sc) throws IOException {
          StaticLogger.write("TesterHttpServletResponseWrapper.sendError(i)");
          ((HttpServletResponse) getResponse()).sendError(sc);
      }
  
  
      public void sendError(int sc, String msg) throws IOException {
          StaticLogger.write("TesterHttpServletResponseWrapper.sendError(i,s)");
          ((HttpServletResponse) getResponse()).sendError(sc, msg);
      }
  
  
      public void sendRedirect(String location) throws IOException {
          StaticLogger.write("TesterHttpServletResponseWrapper.sendRedirect()");
          ((HttpServletResponse) getResponse()).sendRedirect(location);
      }
  
  
      public void setBufferSize(int size) {
          StaticLogger.write("TesterHttpServletResponseWrapper.setBufferSize()");
          getResponse().setBufferSize(size);
      }
  
  
      public void setContentLength(int len) {
          StaticLogger.write("TesterHttpServletResponseWrapper.setContentLength()");
          getResponse().setContentLength(len);
      }
  
  
      public void setContentType(String type) {
          StaticLogger.write("TesterHttpServletResponseWrapper.setContentType()");
          getResponse().setContentType(type);
      }
  
  
      public void setDateHeader(String name, long value) {
          StaticLogger.write("TesterHttpServletResponseWrapper.setDateHeader()");
          ((HttpServletResponse) getResponse()).setDateHeader(name, value);
      }
  
  
      public void setHeader(String name, String value) {
          StaticLogger.write("TesterHttpServletResponseWrapper.setHeader()");
          ((HttpServletResponse) getResponse()).setHeader(name, value);
      }
  
  
      public void setIntHeader(String name, int value) {
          StaticLogger.write("TesterHttpServletResponseWrapper.setIntHeader()");
          ((HttpServletResponse) getResponse()).setIntHeader(name, value);
      }
  
  
      public void setLocale(Locale locale) {
          StaticLogger.write("TesterHttpServletResponseWrapper.setLocale()");
          getResponse().setLocale(locale);
      }
  
  
      public void setStatus(int sc) {
          StaticLogger.write("TesterHttpServletResponseWrapper.setStatus(i)");
          ((HttpServletResponse) getResponse()).setStatus(sc);
      }
  
  
      public void setStatus(int sc, String msg) {
          StaticLogger.write("TesterHttpServletResponseWrapper.setStatus(i,s)");
          ((HttpServletResponse) getResponse()).setStatus(sc, msg);
      }
  
  
  }
  
  
  
  1.1                  
jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/TesterServletRequestWrapper.java
  
  Index: TesterServletRequestWrapper.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.util.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  
  /**
   * Tester request wrapper that logs all calls to the configured logger,
   * before passing them on to the underlying request.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/12/22 22:13:07 $
   */
  
  public class TesterServletRequestWrapper extends ServletRequestWrapper {
  
  
      // ------------------------------------------------------------ Constructor
  
  
      /**
       * Configure a new request wrapper.
       *
       * @param request The request we are wrapping
       */
      public TesterServletRequestWrapper(ServletRequest request) {
  
          super(request);
  
      }
  
  
      // --------------------------------------------------------- Public Methods
  
  
      // For each public method, log the call and pass it to the wrapped response
  
  
      public Object getAttribute(String name) {
          StaticLogger.write("TesterServletRequestWrapper.getAttribute()");
          return (getRequest().getAttribute(name));
      }
  
  
      public Enumeration getAttributeNames() {
          StaticLogger.write("TesterServletRequestWrapper.getAttributeNames()");
          return (getRequest().getAttributeNames());
      }
  
  
      public String getCharacterEncoding() {
          StaticLogger.write("TesterServletRequestWrapper.getCharacterEncoding()");
          return (getRequest().getCharacterEncoding());
      }
  
  
      public int getContentLength() {
          StaticLogger.write("TesterServletRequestWrapper.getContentLength()");
          return (getRequest().getContentLength());
      }
  
  
      public String getContentType() {
          StaticLogger.write("TesterServletRequestWrapper.getContentType()");
          return (getRequest().getContentType());
      }
  
  
      public ServletInputStream getInputStream() throws IOException {
          StaticLogger.write("TesterServletRequestWrapper.getInputStream()");
          return (getRequest().getInputStream());
      }
  
  
      public Locale getLocale() {
          StaticLogger.write("TesterServletRequestWrapper.getLocale()");
          return (getRequest().getLocale());
      }
  
  
      public Enumeration getLocales() {
          StaticLogger.write("TesterServletRequestWrapper.getLocales()");
          return (getRequest().getLocales());
      }
  
  
      public String getParameter(String name) {
          StaticLogger.write("TesterServletRequestWrapper.getParameter()");
          return (getRequest().getParameter(name));
      }
  
  
      public Map getParameterMap() {
          StaticLogger.write("TesterServletRequestWrapper.getParameterMap()");
          return (getRequest().getParameterMap());
      }
  
  
      public Enumeration getParameterNames() {
          StaticLogger.write("TesterServletRequestWrapper.getParameterNames()");
          return (getRequest().getParameterNames());
      }
  
  
      public String[] getParameterValues(String name) {
          StaticLogger.write("TesterServletRequestWrapper.getParameterValues()");
          return (getRequest().getParameterValues(name));
      }
  
  
      public String getProtocol() {
          StaticLogger.write("TesterServletRequestWrapper.getProtocol()");
          return (getRequest().getProtocol());
      }
  
  
      public BufferedReader getReader() throws IOException {
          StaticLogger.write("TesterServletRequestWrapper.getReader()");
          return (getRequest().getReader());
      }
  
  
      public String getRealPath(String path) {
          StaticLogger.write("TesterServletRequestWrapper.getRealPath()");
          return (getRequest().getRealPath(path));
      }
  
  
      public String getRemoteAddr() {
          StaticLogger.write("TesterServletRequestWrapper.getRemoteAddr()");
          return (getRequest().getRemoteAddr());
      }
  
  
      public String getRemoteHost() {
          StaticLogger.write("TesterServletRequestWrapper.getRemoteHost()");
          return (getRequest().getRemoteHost());
      }
  
  
      public RequestDispatcher getRequestDispatcher(String path) {
          StaticLogger.write("TesterServletRequestWrapper.getRequestDispatcher()");
          return (getRequest().getRequestDispatcher(path));
      }
  
  
      public String getScheme() {
          StaticLogger.write("TesterServletRequestWrapper.getScheme()");
          return (getRequest().getScheme());
      }
  
  
      public String getServerName() {
          StaticLogger.write("TesterServletRequestWrapper.getServerName()");
          return (getRequest().getServerName());
      }
  
  
      public int getServerPort() {
          StaticLogger.write("TesterServletRequestWrapper.getServerPort()");
          return (getRequest().getServerPort());
      }
  
  
      public boolean isSecure() {
          StaticLogger.write("TesterServletRequestWrapper.isSecure()");
          return (getRequest().isSecure());
      }
  
  
      public void removeAttribute(String name) {
          StaticLogger.write("TesterServletRequestWrapper.removeAttribute()");
          getRequest().removeAttribute(name);
      }
  
  
      public void setAttribute(String name, Object value) {
          StaticLogger.write("TesterServletRequestWrapper.setAttribute()");
          getRequest().setAttribute(name, value);
      }
  
  
      public void setCharacterEncoding(String enc)
          throws UnsupportedEncodingException {
          StaticLogger.write("TesterServletRequestWrapper.setCharacterEncoding()");
          getRequest().setCharacterEncoding(enc);
      }
  
  
  
  
  
  }
  
  
  
  1.1                  
jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/TesterServletResponseWrapper.java
  
  Index: TesterServletResponseWrapper.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.util.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  
  /**
   * Tester response wrapper that logs all calls to the configured logger,
   * before passing them on to the underlying response.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/12/22 22:13:07 $
   */
  
  public class TesterServletResponseWrapper extends ServletResponseWrapper {
  
  
      // ------------------------------------------------------------ Constructor
  
  
      /**
       * Configure a new response wrapper.
       *
       * @param response The response we are wrapping
       */
      public TesterServletResponseWrapper(ServletResponse response) {
  
          super(response);
  
      }
  
  
      // --------------------------------------------------------- Public Methods
  
  
      // For each public method, log the call and pass it to the wrapped response
  
  
      public void flushBuffer() throws IOException {
          StaticLogger.write("TesterServletResponseWrapper.flushBuffer()");
          getResponse().flushBuffer();
      }
  
  
      public int getBufferSize() {
          StaticLogger.write("TesterServletResponseWrapper.getBufferSize()");
          return (getResponse().getBufferSize());
      }
  
  
      public String getCharacterEncoding() {
          StaticLogger.write("TesterServletResponseWrapper.getCharacterEncoding()");
          return (getResponse().getCharacterEncoding());
      }
  
  
      public Locale getLocale() {
          StaticLogger.write("TesterServletResponseWrapper.getLocale()");
          return (getResponse().getLocale());
      }
  
  
      public ServletOutputStream getOutputStream() throws IOException {
          StaticLogger.write("TesterServletResponseWrapper.getOutputStream()");
          return (getResponse().getOutputStream());
      }
  
  
      public PrintWriter getWriter() throws IOException {
          StaticLogger.write("TesterServletResponseWrapper.getWriter()");
          return (getResponse().getWriter());
      }
  
  
      public boolean isCommitted() {
          StaticLogger.write("TesterServletResponseWrapper.isCommitted()");
          return (getResponse().isCommitted());
      }
  
  
      public void reset() {
          StaticLogger.write("TesterServletResponseWrapper.reset()");
          getResponse().reset();
      }
  
  
      public void resetBuffer() {
          StaticLogger.write("TesterServletResponseWrapper.resetBuffer()");
          getResponse().resetBuffer();
      }
  
  
      public void setBufferSize(int size) {
          StaticLogger.write("TesterServletResponseWrapper.setBufferSize()");
          getResponse().setBufferSize(size);
      }
  
  
      public void setContentLength(int len) {
          StaticLogger.write("TesterServletResponseWrapper.setContentLength()");
          getResponse().setContentLength(len);
      }
  
  
      public void setContentType(String type) {
          StaticLogger.write("TesterServletResponseWrapper.setContentType()");
          getResponse().setContentType(type);
      }
  
  
      public void setLocale(Locale locale) {
          StaticLogger.write("TesterServletResponseWrapper.setLocale()");
          getResponse().setLocale(locale);
      }
  
  
  }
  
  
  
  1.1                  
jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/WrapperFilter.java
  
  Index: WrapperFilter.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.util.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  
  /**
   * Configurable filter that will wrap the request and/or response objects
   * it passes on with either generic or HTTP-specific wrappers.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/12/22 22:13:07 $
   */
  
  public class WrapperFilter implements Filter {
  
  
      // ----------------------------------------------------------- Constructors
  
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * The filter configuration object for this filter.
       */
      protected FilterConfig config = null;
  
  
      /**
       * The type of wrapper for each request ("none", "generic", "http").
       */
      protected String requestWrapper = "none";
  
  
      /**
       * The type of wrapper for each response ("none", "generic", "http").
       */
      protected String responseWrapper = "none";
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Wrap this request and/or response as configured and pass it on.
       */
      public void doFilter(ServletRequest inRequest, ServletResponse inResponse,
                           FilterChain chain)
          throws IOException, ServletException {
  
          // Create the appropriate wrappers
          ServletRequest outRequest = inRequest;
          ServletResponse outResponse = inResponse;
          if (requestWrapper.equals("generic")) {
              outRequest = new TesterServletRequestWrapper(inRequest);
          } /* else if (requestWrapper.equals("http")) {
              outRequest = new TesterHttpServletRequestWrapper(inRequest);
          }
          */
          if (responseWrapper.equals("generic")) {
              outResponse = new TesterServletResponseWrapper(inResponse);
          } else if (responseWrapper.equals("http")) {
              outResponse = new TesterHttpServletResponseWrapper
                  ((HttpServletResponse) inResponse);
          }
  
          // Reset our logger and perform this request
          StaticLogger.reset();
          chain.doFilter(outRequest, outResponse);
  
      }
  
  
      /**
       * Return the filter configuration object for this filter.
       */
      public FilterConfig getFilterConfig() {
  
          return (this.config);
  
      }
  
  
      /**
       * Set the filter configuration object for this filter.
       *
       * @param config The new filter configuration object
       */
      public void setFilterConfig(FilterConfig config) {
  
          this.config = config;
          if (config == null) {
              requestWrapper = "none";
              responseWrapper = "none";
          } else {
              String value = null;
              value = config.getInitParameter("request");
              if (value != null)
                  requestWrapper = value;
              value = config.getInitParameter("response");
              if (value != null)
                  responseWrapper = value;
          }
  
      }
  
  
  }
  
  
  
  1.2       +97 -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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- web.xml   2000/12/18 05:06:14     1.1
  +++ web.xml   2000/12/22 22:13:08     1.2
  @@ -8,6 +8,64 @@
   
   <web-app>
   
  +    <!-- ========== Filter Definitions ==================================== -->
  +
  +    <filter>
  +        <filter-name>GenericFilter</filter-name>
  +        <filter-class>org.apache.tester.WrapperFilter</filter-class>
  +        <init-param>
  +            <param-name>request</param-name>
  +            <param-value>generic</param-value>
  +        </init-param>
  +        <init-param>
  +            <param-name>response</param-name>
  +            <param-value>generic</param-value>
  +        </init-param>
  +    </filter>
  +
  +
  +    <filter>
  +        <filter-name>HttpFilter</filter-name>
  +        <filter-class>org.apache.tester.WrapperFilter</filter-class>
  +        <init-param>
  +            <param-name>request</param-name>
  +            <param-value>http</param-value>
  +        </init-param>
  +        <init-param>
  +            <param-name>response</param-name>
  +            <param-value>http</param-value>
  +        </init-param>
  +    </filter>
  +
  +
  +    <!-- ========== Filter Mappings ======================================= -->
  +
  +    <filter-mapping>
  +        <filter-name>GenericFilter</filter-name>
  +        <url-pattern>/WrappedGetInputStream01</url-pattern>
  +    </filter-mapping>
  +
  +    <filter-mapping>
  +        <filter-name>GenericFilter</filter-name>
  +        <url-pattern>/WrappedGetParameter01</url-pattern>
  +    </filter-mapping>
  +
  +    <filter-mapping>
  +        <filter-name>GenericFilter</filter-name>
  +        <url-pattern>/WrappedGetParameterMap00</url-pattern>
  +    </filter-mapping>
  +
  +    <filter-mapping>
  +        <filter-name>GenericFilter</filter-name>
  +        <url-pattern>/WrappedSetBufferSize01</url-pattern>
  +    </filter-mapping>
  +
  +    <filter-mapping>
  +        <filter-name>HttpFilter</filter-name>
  +        <url-pattern>/WrappedGetQueryString01</url-pattern>
  +    </filter-mapping>
  +
  +
       <!-- ========== Servlet Definitions =================================== -->
   
       <servlet>
  @@ -40,6 +98,10 @@
           <servlet-class>org.apache.tester.GetQueryString01</servlet-class>
       </servlet>
   
  +    <servlet>
  +        <servlet-name>SetBufferSize01</servlet-name>
  +        <servlet-class>org.apache.tester.SetBufferSize01</servlet-class>
  +    </servlet>
   
       <!-- ========== Servlet Mappings ====================================== -->
   
  @@ -59,18 +121,53 @@
       </servlet-mapping>
   
       <servlet-mapping>
  +        <servlet-name>GetInputStream01</servlet-name>
  +        <url-pattern>/WrappedGetInputStream01</url-pattern>
  +    </servlet-mapping>
  +
  +    <servlet-mapping>
  +        <servlet-name>GetParameter01</servlet-name>
  +        <url-pattern>/WrappedGetParameter01</url-pattern>
  +    </servlet-mapping>
  +
  +    <servlet-mapping>
           <servlet-name>GetParameter01</servlet-name>
           <url-pattern>/GetParameter01</url-pattern>
       </servlet-mapping>
   
       <servlet-mapping>
  +        <servlet-name>GetParameter01</servlet-name>
  +        <url-pattern>/WrappedGetParameter01</url-pattern>
  +    </servlet-mapping>
  +
  +    <servlet-mapping>
           <servlet-name>GetParameterMap00</servlet-name>
           <url-pattern>/GetParameterMap00</url-pattern>
       </servlet-mapping>
   
       <servlet-mapping>
  +        <servlet-name>GetParameterMap00</servlet-name>
  +        <url-pattern>/WrappedGetParameterMap00</url-pattern>
  +    </servlet-mapping>
  +
  +    <servlet-mapping>
           <servlet-name>GetQueryString01</servlet-name>
           <url-pattern>/GetQueryString01</url-pattern>
  +    </servlet-mapping>
  +
  +    <servlet-mapping>
  +        <servlet-name>GetQueryString01</servlet-name>
  +        <url-pattern>/WrappedGetQueryString01</url-pattern>
  +    </servlet-mapping>
  +
  +    <servlet-mapping>
  +        <servlet-name>SetBufferSize01</servlet-name>
  +        <url-pattern>/SetBufferSize01</url-pattern>
  +    </servlet-mapping>
  +
  +    <servlet-mapping>
  +        <servlet-name>SetBufferSize01</servlet-name>
  +        <url-pattern>/WrappedSetBufferSize01</url-pattern>
       </servlet-mapping>
   
   
  
  
  

Reply via email to