craigmcc    01/02/21 13:39:51

  Modified:    tester/src/bin tester.bat tester.sh tester.xml
               tester/web/WEB-INF web.xml
  Added:       tester/src/tester/org/apache/tester ErrorPage01.java
                        ErrorPage02.java ErrorPage03.java ErrorPage04.java
                        TesterException.java
  Log:
  Modify the tester suite execution scripts to reflect the change in JAR
  file locations for the XML parser that is required.
  
  Add unit tests to validate correct processing of <error-page> elements in
  the web application deployment descriptor, and correct handling of
  forwarding to error pages on a particular HTTP status code, as well as
  when a particular exception is thrown.  This set of tests was created to
  validate the behavior of error handling, in response to Bugzilla Bug#644.
  
  Revision  Changes    Path
  1.4       +2 -2      jakarta-tomcat-4.0/tester/src/bin/tester.bat
  
  Index: tester.bat
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/tester/src/bin/tester.bat,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- tester.bat        2001/02/18 02:18:15     1.3
  +++ tester.bat        2001/02/21 21:39:50     1.4
  @@ -14,7 +14,7 @@
   rem
   rem   JAVA_HOME     Must point at your Java Development Kit installation.
   rem
  -rem $Id: tester.bat,v 1.3 2001/02/18 02:18:15 craigmcc Exp $
  +rem $Id: tester.bat,v 1.4 2001/02/21 21:39:50 craigmcc Exp $
   rem ---------------------------------------------------------------------------
   
   
  @@ -59,7 +59,7 @@
   
   rem ----- Set Up The Runtime Classpath ----------------------------------------
   
  -set 
CP=%CATALINA_HOME%\webapps\tester\WEB-INF\lib\tester.jar;%CATALINA_HOME%\server\jaxp.jar;%CATALINA_HOME%\server\crimson.jar;%ANT_HOME%\lib\ant.jar
  +set 
CP=%CATALINA_HOME%\webapps\tester\WEB-INF\lib\tester.jar;%CATALINA_HOME%\server\lib\jaxp.jar;%CATALINA_HOME%\server\lib\crimson.jar;%ANT_HOME%\lib\ant.jar
   set CLASSPATH=%CP%
   echo Using CLASSPATH: %CLASSPATH%
   
  
  
  
  1.3       +2 -2      jakarta-tomcat-4.0/tester/src/bin/tester.sh
  
  Index: tester.sh
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/tester/src/bin/tester.sh,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- tester.sh 2001/02/18 02:18:15     1.2
  +++ tester.sh 2001/02/21 21:39:50     1.3
  @@ -12,7 +12,7 @@
   #
   #   JAVA_HOME     Must point at your Java Development Kit installation.
   #
  -# $Id: tester.sh,v 1.2 2001/02/18 02:18:15 craigmcc Exp $
  +# $Id: tester.sh,v 1.3 2001/02/21 21:39:50 craigmcc Exp $
   # -----------------------------------------------------------------------------
   
   
  @@ -37,7 +37,7 @@
   
   # ----- Set Up The System Classpath -------------------------------------------
   
  
-CP=$CATALINA_HOME/webapps/tester/WEB-INF/lib/tester.jar:$CATALINA_HOME/server/jaxp.jar:$CATALINA_HOME/server/crimson.jar:$ANT_HOME/lib/ant.jar
  
+CP=$CATALINA_HOME/webapps/tester/WEB-INF/lib/tester.jar:$CATALINA_HOME/server/lib/jaxp.jar:$CATALINA_HOME/server/lib/crimson.jar:$ANT_HOME/lib/ant.jar
   
   echo Using CLASSPATH: $CP
   
  
  
  
  1.15      +30 -1     jakarta-tomcat-4.0/tester/src/bin/tester.xml
  
  Index: tester.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/tester/src/bin/tester.xml,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- tester.xml        2001/02/06 17:16:21     1.14
  +++ tester.xml        2001/02/21 21:39:50     1.15
  @@ -12,7 +12,7 @@
     <taskdef  name="tester"     classname="org.apache.tester.TestClient"/>
   
   
  -  <target name="all" 
depends="ROOT,CaseSensitive,RequestDispatcher,Resources,ServletRequest,ServletResponse,HttpSession"/>
  +  <target name="all" 
depends="ROOT,CaseSensitive,ErrorPage,RequestDispatcher,Resources,ServletRequest,ServletResponse,HttpSession"/>
   
   
     <target name="ROOT">
  @@ -91,6 +91,35 @@
       <tester host="${host}" port="${port}" protocol="${protocol}"
            request="/Examples/servlet/HelloWorldExample"
             status="404"/>
  +
  +  </target>
  +
  +
  +  <target name="ErrorPage">
  +
  +    <!-- ========== Error Code Mapping ==================================== -->
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/ErrorPage01" debug="${debug}"
  +      outContent="ErrorPage02 PASSED"/>
  +
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/WrappedErrorPage01" debug="${debug}"
  +      outContent="ErrorPage02 PASSED"/>
  +
  +
  +    <!-- ========== Exception Mapping ===================================== -->
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/ErrorPage03" debug="${debug}"
  +      outContent="ErrorPage04 PASSED"/>
  +
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/WrappedErrorPage03" debug="${debug}"
  +      outContent="ErrorPage04 PASSED"/>
  +
   
     </target>
   
  
  
  
  1.1                  
jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/ErrorPage01.java
  
  Index: ErrorPage01.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.*;
  
  /**
   * Part 1 of the ErrorPage Tests.  Returns a response status code of 412
   * (HttpServletResponse.SC_PRECONDITION_FAILED) which is mapped to the
   * ErrorPage02 servlet in the deployment descriptor.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2001/02/21 21:39:51 $
   */
  
  public class ErrorPage01 extends HttpServlet {
  
      public void doGet(HttpServletRequest request, HttpServletResponse response)
          throws IOException, ServletException {
  
          response.setContentType("text/plain");
          PrintWriter writer = response.getWriter();
  
          // Write a FAILED message that should get replaced by the error text
          writer.println("ErrorPage01 FAILED - Original response returned");
  
          // Return the appropriate response code
          response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED,
                             "ErrorPage01 Returned Status Code 412");
  
      }
  
  }
  
  
  
  1.1                  
jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/ErrorPage02.java
  
  Index: ErrorPage02.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.*;
  
  /**
   * Part 2 of the ErrorPage Tests.  Should be mapped by the container when
   * the ErrorPage01 servlet returns the appropriate status code.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2001/02/21 21:39:51 $
   */
  
  public class ErrorPage02 extends HttpServlet {
  
  
      public void doGet(HttpServletRequest request, HttpServletResponse response)
          throws IOException, ServletException {
  
          response.reset();
          response.setContentType("text/plain");
          PrintWriter writer = response.getWriter();
  
          // Accumulate all the reasons this request might fail
          StringBuffer sb = new StringBuffer();
          Object value = null;
  
          value = request.getAttribute("javax.servlet.error.status_code");
          if (value == null)
              sb.append(" status_code is missing/");
          else if (!(value instanceof Integer)) {
              sb.append(" status_code class is ");
              sb.append(value.getClass().getName());
              sb.append("/");
          } else {
              int intValue = ((Integer) value).intValue();
              if (intValue != HttpServletResponse.SC_PRECONDITION_FAILED) {
                  sb.append(" status_code is ");
                  sb.append(value);
                  sb.append("/");
              }
          }
  
          value = request.getAttribute("javax.servlet.error.message");
          if (value == null)
              sb.append(" message is missing/");
          else if (!(value instanceof String)) {
              sb.append(" message class is ");
              sb.append(value.getClass().getName());
              sb.append("/");
          } else {
              String message = (String) value;
              if (!"ErrorPage01 Returned Status Code 412".equals(message)) {
                  sb.append(" message is ");
                  sb.append(message);
                  sb.append("/");
              }
          }
  
          value = request.getAttribute("javax.servlet.error.request_uri");
          if (value == null)
              sb.append(" request_uri is missing/");
          else if (!(value instanceof String)) {
              sb.append(" request_uri class is ");
              sb.append(value.getClass().getName());
              sb.append("/");
          } else {
              String request_uri = (String) value;
              String test1 = request.getContextPath() + "/ErrorPage01";
              String test2 = request.getContextPath() + "/WrappedErrorPage01";
              if (!request_uri.equals(test1) && !request_uri.equals(test2)) {
                  sb.append(" request_uri is ");
                  sb.append(request_uri);
                  sb.append("/");
              }
          }
  
          // Report ultimate success or failure
          if (sb.length() < 1)
              writer.println("ErrorPage02 PASSED");
          else
              writer.println("ErrorPage02 FAILED -" + 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/ErrorPage03.java
  
  Index: ErrorPage03.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.*;
  
  /**
   * Part 3 of the ErrorPage Tests.  Throws an exception of a specified type
   * (wrapped in a servlet exception as required by the throws clause), which
   * is mapped to the ErrorPage04 servlet in the deployment descriptor.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2001/02/21 21:39:51 $
   */
  
  public class ErrorPage03 extends HttpServlet {
  
      public void doGet(HttpServletRequest request, HttpServletResponse response)
          throws IOException, ServletException {
  
          response.setContentType("text/plain");
          PrintWriter writer = response.getWriter();
  
          // Write a FAILED message that should get replaced by the error text
          writer.println("ErrorPage03 FAILED - Original response returned");
  
          // Throw the specified exception
          throw new ServletException
              (new TesterException("ErrorPage03 Threw Exception"));
  
      }
  
  }
  
  
  
  1.1                  
jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/ErrorPage04.java
  
  Index: ErrorPage04.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.*;
  
  /**
   * Part 4 of the ErrorPage Tests.  Should be mapped by the container when
   * the ErrorPage01 servlet returns the appropriate exception.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2001/02/21 21:39:51 $
   */
  
  public class ErrorPage04 extends HttpServlet {
  
  
      public void doGet(HttpServletRequest request, HttpServletResponse response)
          throws IOException, ServletException {
  
          response.reset();
          response.setContentType("text/plain");
          PrintWriter writer = response.getWriter();
  
          // Accumulate all the reasons this request might fail
          StringBuffer sb = new StringBuffer();
          Object value = null;
  
          value = request.getAttribute("javax.servlet.error.exception");
          if (value == null)
              sb.append(" exception is missing/");
          else if (!(value instanceof TesterException)) {
              sb.append(" exception class is ");
              sb.append(value.getClass().getName());
              sb.append("/");
          } else {
              TesterException te = (TesterException) value;
              if (!"ErrorPage03 Threw Exception".equals(te.getMessage())) {
                  sb.append(" exception message is ");
                  sb.append(te.getMessage());
                  sb.append("/");
              }
          }
  
          value = request.getAttribute("javax.servlet.error.exception_type");
          if (value == null)
              sb.append(" exception_type is missing/");
          else if (!(value instanceof Class)) {
              sb.append(" exception_type class is ");
              sb.append(value.getClass().getName());
              sb.append("/");
          } else {
              Class clazz = (Class) value;
              if (!"org.apache.tester.TesterException".equals(clazz.getName())) {
                  sb.append(" exception_type class is ");
                  sb.append(clazz.getName());
                  sb.append("/");
              }
          }
  
          value = request.getAttribute("javax.servlet.error.message");
          if (value == null)
              sb.append(" message is missing/");
          else if (!(value instanceof String)) {
              sb.append(" message class is ");
              sb.append(value.getClass().getName());
              sb.append("/");
          } else {
              String message = (String) value;
              if (!"ErrorPage03 Threw Exception".equals(message)) {
                  sb.append(" message is ");
                  sb.append(message);
                  sb.append("/");
              }
          }
  
          value = request.getAttribute("javax.servlet.error.request_uri");
          if (value == null)
              sb.append(" request_uri is missing/");
          else if (!(value instanceof String)) {
              sb.append(" request_uri class is ");
              sb.append(value.getClass().getName());
              sb.append("/");
          } else {
              String request_uri = (String) value;
              String test1 = request.getContextPath() + "/ErrorPage03";
              String test2 = request.getContextPath() + "/WrappedErrorPage03";
              if (!request_uri.equals(test1) && !request_uri.equals(test2)) {
                  sb.append(" request_uri is ");
                  sb.append(request_uri);
                  sb.append("/");
              }
          }
  
          // Report ultimate success or failure
          if (sb.length() < 1)
              writer.println("ErrorPage04 PASSED");
          else
              writer.println("ErrorPage04 FAILED -" + 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/TesterException.java
  
  Index: TesterException.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.*;
  
  /**
   * Generic exception class to use for testing error page assertions.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2001/02/21 21:39:51 $
   */
  
  public class TesterException extends Exception {
  
  
      /**
       * Construct an exception with no associated message.
       */
      public TesterException() {
  
          super();
  
      }
  
  
      /**
       * Construct an exception with the associated message.
       *
       * @param message The associated message
       */
      public TesterException(String message) {
  
          super(message);
  
      }
  
  
  }
  
  
  
  1.11      +93 -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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- web.xml   2001/02/06 17:16:27     1.10
  +++ web.xml   2001/02/21 21:39:51     1.11
  @@ -52,6 +52,26 @@
   
       <filter-mapping>
           <filter-name>HttpFilter</filter-name>
  +        <url-pattern>/WrappedErrorPage01</url-pattern>
  +    </filter-mapping>
  +
  +    <filter-mapping>
  +        <filter-name>HttpFilter</filter-name>
  +        <url-pattern>/WrappedErrorPage02</url-pattern>
  +    </filter-mapping>
  +
  +    <filter-mapping>
  +        <filter-name>HttpFilter</filter-name>
  +        <url-pattern>/WrappedErrorPage03</url-pattern>
  +    </filter-mapping>
  +
  +    <filter-mapping>
  +        <filter-name>HttpFilter</filter-name>
  +        <url-pattern>/WrappedErrorPage04</url-pattern>
  +    </filter-mapping>
  +
  +    <filter-mapping>
  +        <filter-name>HttpFilter</filter-name>
           <url-pattern>/WrappedForward01</url-pattern>
       </filter-mapping>
   
  @@ -164,6 +184,26 @@
       </servlet>
   
       <servlet>
  +        <servlet-name>ErrorPage01</servlet-name>
  +        <servlet-class>org.apache.tester.ErrorPage01</servlet-class>
  +    </servlet>
  +
  +    <servlet>
  +        <servlet-name>ErrorPage02</servlet-name>
  +        <servlet-class>org.apache.tester.ErrorPage02</servlet-class>
  +    </servlet>
  +
  +    <servlet>
  +        <servlet-name>ErrorPage03</servlet-name>
  +        <servlet-class>org.apache.tester.ErrorPage03</servlet-class>
  +    </servlet>
  +
  +    <servlet>
  +        <servlet-name>ErrorPage04</servlet-name>
  +        <servlet-class>org.apache.tester.ErrorPage04</servlet-class>
  +    </servlet>
  +
  +    <servlet>
           <servlet-name>Forward01</servlet-name>
           <servlet-class>org.apache.tester.Forward01</servlet-class>
       </servlet>
  @@ -292,6 +332,46 @@
       </servlet-mapping>
   
       <servlet-mapping>
  +        <servlet-name>ErrorPage01</servlet-name>
  +        <url-pattern>/ErrorPage01</url-pattern>
  +    </servlet-mapping>
  +
  +    <servlet-mapping>
  +        <servlet-name>ErrorPage01</servlet-name>
  +        <url-pattern>/WrappedErrorPage01</url-pattern>
  +    </servlet-mapping>
  +
  +    <servlet-mapping>
  +        <servlet-name>ErrorPage02</servlet-name>
  +        <url-pattern>/ErrorPage02</url-pattern>
  +    </servlet-mapping>
  +
  +    <servlet-mapping>
  +        <servlet-name>ErrorPage02</servlet-name>
  +        <url-pattern>/WrappedErrorPage02</url-pattern>
  +    </servlet-mapping>
  +
  +    <servlet-mapping>
  +        <servlet-name>ErrorPage03</servlet-name>
  +        <url-pattern>/ErrorPage03</url-pattern>
  +    </servlet-mapping>
  +
  +    <servlet-mapping>
  +        <servlet-name>ErrorPage03</servlet-name>
  +        <url-pattern>/WrappedErrorPage03</url-pattern>
  +    </servlet-mapping>
  +
  +    <servlet-mapping>
  +        <servlet-name>ErrorPage04</servlet-name>
  +        <url-pattern>/ErrorPage04</url-pattern>
  +    </servlet-mapping>
  +
  +    <servlet-mapping>
  +        <servlet-name>ErrorPage04</servlet-name>
  +        <url-pattern>/WrappedErrorPage04</url-pattern>
  +    </servlet-mapping>
  +
  +    <servlet-mapping>
           <servlet-name>Forward01</servlet-name>
           <url-pattern>/Forward01</url-pattern>
       </servlet-mapping>
  @@ -485,6 +565,19 @@
           <servlet-name>SetLocale01</servlet-name>
           <url-pattern>/WrappedSetLocale01</url-pattern>
       </servlet-mapping>
  +
  +
  +    <!-- ========== Error Page Mappings =================================== -->
  +
  +    <error-page>
  +        <error-code>412</error-code>  <!-- SC_PRECONDITION_FAILED -->
  +        <location>/ErrorPage02</location>
  +    </error-page>
  +
  +    <error-page>
  +        <exception-type>org.apache.tester.TesterException</exception-type>
  +        <location>/ErrorPage04</location>
  +    </error-page>
   
   
       <!-- ========== Security Constraints ================================== -->
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to