tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@apache.org
Subject cvs commit: jakarta-tomcat-4.0/tester/web/WEB-INF web.xml
Date Tue, 13 Mar 2001 19:06:24 GMT
craigmcc    01/03/13 11:06:23

  Modified:    tester   build.bat build.sh build.xml
               tester/src/bin tester.xml
               tester/web/WEB-INF web.xml
  Added:       tester/src/tester/org/apache/tester Xerces01.java
                        Xerces01Parser.java
               tester/web Xerces01.xml
  Log:
  Add a test to prove that we can run a web application using Xerces (which
  is installed under WEB-INF/lib) in a Tomcat 4.0 environment.
  
  Also, added debugging attributes on all remaining tests that did not
  include it.
  
  Submitted by:  Amy Roh <amyroh@eng.sun.com>
  
  Revision  Changes    Path
  1.3       +12 -2     jakarta-tomcat-4.0/tester/build.bat
  
  Index: build.bat
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/tester/build.bat,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- build.bat	2001/02/01 16:52:59	1.2
  +++ build.bat	2001/03/13 19:06:06	1.3
  @@ -11,7 +11,10 @@
   rem
   rem   JAVA_HOME        Must point at your Java Development Kit [REQUIRED]
   rem
  -rem $Id: build.bat,v 1.2 2001/02/01 16:52:59 craigmcc Exp $
  +rem   XERCES_HOME      Must point at your Xerces installation
  +rem                    [../../xerces-1_3_0]
  +rem
  +rem $Id: build.bat,v 1.3 2001/03/13 19:06:06 craigmcc Exp $
   rem ---------------------------------------------------------------------------
   
   
  @@ -19,6 +22,7 @@
   
   set _CLASSPATH=%CLASSPATH%
   set _ANT_HOME=%ANT_HOME%
  +set _XERCES_HOME=%XERCES_HOME%
   
   
   rem ----- Verify and Set Required Environment Variables -----------------------
  @@ -33,7 +37,11 @@
   set ANT_HOME=../../jakarta-ant
   :gotAntHome
   
  +if not "%XERCES_HOME%" == "" goto gotXercesHome
  +set XERCES_HOME=../../xerces-1_3_0
  +:gotXercesHome
   
  +
   rem ----- Set Up The Runtime Classpath ----------------------------------------
   
   if not "%CLASSPATH%" == "" set CLASSPATH=%CLASSPATH%;
  @@ -42,7 +50,7 @@
   
   rem ----- Execute The Requested Build -----------------------------------------
   
  -%JAVA_HOME%\bin\java %ANT_OPTS% org.apache.tools.ant.Main -Dant.home="%ANT_HOME%" -Djava.home="%JAVA_HOME%"
%1 %2 %3 %4 %5 %6 %7 %8 %9
  +%JAVA_HOME%\bin\java %ANT_OPTS% org.apache.tools.ant.Main -Dant.home="%ANT_HOME%" -Djava.home="%JAVA_HOME%"
-Dxerces.home="%XERCES_HOME%" %1 %2 %3 %4 %5 %6 %7 %8 %9
   
   
   rem ----- Restore Environment Variables ---------------------------------------
  @@ -52,5 +60,7 @@
   set _CLASSPATH=
   set ANT_HOME=%_ANT_HOME%
   set _ANT_HOME=
  +set XERCES_HOME=%_XERCES_HOME%
  +set _XERCES_HOME=
   :finish
   
  
  
  
  1.2       +10 -1     jakarta-tomcat-4.0/tester/build.sh
  
  Index: build.sh
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/tester/build.sh,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- build.sh	2000/12/18 05:06:12	1.1
  +++ build.sh	2001/03/13 19:06:07	1.2
  @@ -11,7 +11,10 @@
   #
   #   JAVA_HOME        Must point at your Java Development Kit [REQUIRED]
   #
  -# $Id: build.sh,v 1.1 2000/12/18 05:06:12 craigmcc Exp $
  +#   XERCES_HOME      Must point at your Xerces installation
  +#                    [../../xerces-1_3_0]
  +#
  +# $Id: build.sh,v 1.2 2001/03/13 19:06:07 craigmcc Exp $
   # -----------------------------------------------------------------------------
   
   
  @@ -30,6 +33,11 @@
     ANT_OPTS=""
   fi
   
  +if [ "$XERCES_HOME" = "" ] ; then
  +  XERCES_HOME="../../xerces-1_3_0"
  +fi
  +
  +
   # ----- Set Up The Runtime Classpath ------------------------------------------
   
   CP=$ANT_HOME/lib/ant.jar:$JAVA_HOME/lib/tools.jar
  @@ -43,4 +51,5 @@
   $JAVA_HOME/bin/java $ANT_OPTS -classpath $CP org.apache.tools.ant.Main \
    -Dant.home=$ANT_HOME \
    -Djava.home=$JAVA_HOME \
  + -Dxerces.home=$XERCES_HOME \
    "$@"
  
  
  
  1.6       +8 -1      jakarta-tomcat-4.0/tester/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/tester/build.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- build.xml	2001/02/22 20:28:58	1.5
  +++ build.xml	2001/03/13 19:06:09	1.6
  @@ -7,10 +7,12 @@
     <property name="tester.build"    value="build"/>
     <property name="tester.deploy"   value="../build"/>
     <property name="tester.dist"     value="dist"/>
  +  <property name="xerces.home"     value="../../xerces-1_3_0"/>
   
     <!-- ================== Derived Property Values ========================= -->
     <property name="ant.jar"         value="${ant.home}/lib/ant.jar"/>
     <property name="servlet.jar"     value="${servletapi.home}/lib/servlet.jar"/>
  +  <property name="xerces.jar"      value="${xerces.home}/xerces.jar"/>
   
     <!-- =================== BUILD: Create Directories ====================== -->
     <target name="build-prepare">
  @@ -51,7 +53,7 @@
   
       <!-- Compile tester components and tools -->
       <javac srcdir="src/tester" destdir="${tester.build}/classes"
  -     classpath="${ant.jar}:${servlet.jar}"
  +     classpath="${ant.jar}:${servlet.jar}:${xerces.jar}"
        deprecation="off" debug="on" optimize="off"
        excludes="**/CVS/**"/>
   
  @@ -68,6 +70,11 @@
           tofile="${tester.build}/web/WEB-INF/classes/org/apache/tester/Unpacked01.txt"/>
       <copy file="src/tester/org/apache/tester/Resources03.txt"
           tofile="${tester.build}/web/WEB-INF/classes/org/apache/tester/Unpacked03.txt"/>
  +
  +    <!-- Install Xerces -->
  +    <copy  todir="${tester.build}/web/WEB-INF/lib">
  +        <fileset dir="${xerces.home}" includes="xerces.jar"/>
  +    </copy>
   
       <!-- Create and install tester library -->
       <mkdir   dir="${tester.build}/web/WEB-INF/lib"/>
  
  
  
  1.19      +58 -42    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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- tester.xml	2001/02/26 04:49:06	1.18
  +++ tester.xml	2001/03/13 19:06:14	1.19
  @@ -12,7 +12,7 @@
     <taskdef  name="tester"     classname="org.apache.tester.TestClient"/>
   
   
  -  <target name="all" depends="ROOT,CaseSensitive,ErrorPage,Jndi,RequestDispatcher,Resources,ServletRequest,ServletResponse,HttpSession"/>
  +  <target name="all" depends="ROOT,CaseSensitive,ErrorPage,Jndi,RequestDispatcher,Resources,ServletRequest,ServletResponse,HttpSession,XercesTest"/>
   
   
     <target name="ROOT">
  @@ -21,13 +21,13 @@
   
       <!-- Should be able to see the home page -->
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="/index.html"
  +         request="/index.html" debug="${debug}"
             status="200"/>
   
       <!-- Should be able to use relative path to document root -->
       <tester host="${host}" port="${port}" protocol="${protocol}"
            request="/examples/.." debug="${debug}"
  -          status="200"/>
  +          status="302"/>
   
       <!-- Should not be able to use relative path above document root -->
       <tester host="${host}" port="${port}" protocol="${protocol}"
  @@ -43,63 +43,63 @@
   
       <!-- Make sure that static resources are matched case sensitively -->
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="/index.HTML"
  +         request="/index.HTML" debug="${debug}"
             status="404"/>
   
       <!-- Should be able to execute the Date example -->
       <touch  file="${catalina.home}/webapps/examples/jsp/dates/date.jsp"/>
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="/examples/jsp/dates/date.jsp"
  +         request="/examples/jsp/dates/date.jsp" debug="${debug}"
             status="200"/>
   
       <!-- Should not be able to view the source of the Date example -->
       <touch  file="${catalina.home}/webapps/examples/jsp/dates/date.jsp"/>
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="/examples/jsp/dates/date.Jsp"
  +         request="/examples/jsp/dates/date.Jsp" debug="${debug}"
             status="404"/>
   
       <!-- Should not be able to view the source of the Date example -->
       <touch  file="${catalina.home}/webapps/examples/jsp/dates/date.jsp"/>
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="/examples/jsp/dates/Date.jsp"
  +         request="/examples/jsp/dates/Date.jsp" debug="${debug}"
             status="404"/>
   
       <!-- Should not be able to view the source of the Date example -->
       <touch  file="${catalina.home}/webapps/examples/jsp/dates/date.jsp"/>
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="/examples/jsp/Dates/date.jsp"
  +         request="/examples/jsp/Dates/date.jsp" debug="${debug}"
             status="404"/>
   
       <!-- Should not be able to view the source of the Date example -->
       <touch  file="${catalina.home}/webapps/examples/jsp/dates/date.jsp"/>
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="/examples/Jsp/dates/date.jsp"
  +         request="/examples/Jsp/dates/date.jsp" debug="${debug}"
             status="404"/>
   
       <!-- Should not be able to view the source of the Date example -->
       <touch  file="${catalina.home}/webapps/examples/jsp/dates/date.jsp"/>
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="/Examples/jsp/dates/date.jsp"
  +         request="/Examples/jsp/dates/date.jsp" debug="${debug}"
             status="404"/>
   
       <!-- Should be able to execute the HelloWorld servlet example -->
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="/examples/servlet/HelloWorldExample"
  +         request="/examples/servlet/HelloWorldExample" debug="${debug}"
             status="200"/>
   
       <!-- Should not be able to execute HelloWorld with different cases -->
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="/examples/servlet/helloWorldExample"
  +         request="/examples/servlet/helloWorldExample" debug="${debug}"
             status="404"/>
   
       <!-- Should not be able to execute HelloWorld with different cases -->
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="/examples/Servlet/HelloWorldExample"
  +         request="/examples/Servlet/HelloWorldExample" debug="${debug}"
             status="404"/>
   
       <!-- Should not be able to execute HelloWorld with different cases -->
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="/Examples/servlet/HelloWorldExample"
  +         request="/Examples/servlet/HelloWorldExample" debug="${debug}"
             status="404"/>
   
     </target>
  @@ -162,46 +162,46 @@
       <!-- ========== Forward and Include to Static Resource ================ -->
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="${context.path}/Forward01"
  +         request="${context.path}/Forward01" debug="${debug}"
         outContent="Forward01 PASSED"/>
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="${context.path}/WrappedForward01"
  +         request="${context.path}/WrappedForward01" debug="${debug}"
         outContent="Forward01 PASSED"/>
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="${context.path}/Include01"
  +         request="${context.path}/Include01" debug="${debug}"
         outContent="Include01 PASSED"/>
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="${context.path}/WrappedInclude01"
  +         request="${context.path}/WrappedInclude01" debug="${debug}"
         outContent="Include01 PASSED"/>
   
       <!-- ========== Included Servlet Throwing Exceptions ================== -->
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
            request="${context.path}/Include02?exception=IOException"
  -      outContent="Include02 PASSED"/>
  +      outContent="Include02 PASSED" debug="${debug}"/>
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
            request="${context.path}/Include02?exception=ServletException"
  -      outContent="Include02 PASSED"/>
  +      outContent="Include02 PASSED" debug="${debug}"/>
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
            request="${context.path}/Include02?exception=NullPointerException"
  -      outContent="Include02 PASSED"/>
  +      outContent="Include02 PASSED" debug="${debug}"/>
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
            request="${context.path}/WrappedInclude02?exception=IOException"
  -      outContent="Include02 PASSED"/>
  +      outContent="Include02 PASSED" debug="${debug}"/>
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
            request="${context.path}/WrappedInclude02?exception=ServletException"
  -      outContent="Include02 PASSED"/>
  +      outContent="Include02 PASSED" debug="${debug}"/>
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
            request="${context.path}/WrappedInclude02?exception=NullPointerException"
  -      outContent="Include02 PASSED"/>
  +      outContent="Include02 PASSED" debug="${debug}"/>
   
     </target>
   
  @@ -332,28 +332,28 @@
       <!-- ========== Parameters and Query Strings ========================== -->
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="${context.path}/GetParameter01?foo=1"
  +         request="${context.path}/GetParameter01?foo=1" debug="${debug}"
         outContent="GetParameter01 PASSED"/>
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
  -         request="${context.path}/WrappedGetParameter01?foo=1"
  +         request="${context.path}/WrappedGetParameter01?foo=1" debug="${debug}"
         outContent="GetParameter01 PASSED"/>
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
            request="${context.path}/GetParameterMap00?BestLanguage=Java&amp;BestJSP=Java2"
  -      outContent="GetParameterMap00 PASSED"/>
  +      outContent="GetParameterMap00 PASSED" debug="${debug}"/>
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
            request="${context.path}/WrappedGetParameterMap00?BestLanguage=Java&amp;BestJSP=Java2"
  -      outContent="GetParameterMap00 PASSED"/>
  +      outContent="GetParameterMap00 PASSED" debug="${debug}"/>
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
            request="${context.path}/GetQueryString01?foo=1"
  -      outContent="GetQueryString01 PASSED"/>
  +      outContent="GetQueryString01 PASSED" debug="${debug}"/>
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
            request="${context.path}/WrappedGetQueryString01?foo=1"
  -      outContent="GetQueryString01 PASSED"/>
  +      outContent="GetQueryString01 PASSED" debug="${debug}"/>
   
       <tester host="${host}" port="${port}" protocol="${protocol}"
              debug="${debug}" method="POST"
  @@ -440,29 +440,29 @@
   
       <!-- ========== Other ServletResponse Tests =========================== -->
   
  -    <tester host="${host}" port="${port}" protocol="${protocol}" debug="0"
  -         request="${context.path}/Reset01"
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/Reset01" debug="${debug}"
         outContent="Reset01 PASSED"/>
   
  -    <tester host="${host}" port="${port}" protocol="${protocol}" debug="0"
  -         request="${context.path}/WrappedReset01"
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/WrappedReset01" debug="${debug}"
         outContent="Reset01 PASSED"/>
   
  -    <tester host="${host}" port="${port}" protocol="${protocol}" debug="0"
  -         request="${context.path}/SetBufferSize01"
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/SetBufferSize01" debug="${debug}"
         outContent="SetBufferSize01 PASSED"/>
   
  -    <tester host="${host}" port="${port}" protocol="${protocol}" debug="0"
  -         request="${context.path}/WrappedSetBufferSize01"
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/WrappedSetBufferSize01" debug="${debug}"
         outContent="SetBufferSize01 PASSED"/>
   
  -    <tester host="${host}" port="${port}" protocol="${protocol}" debug="0"
  -         request="${context.path}/SetLocale01"
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/SetLocale01" debug="${debug}"
         outContent="SetLocale01 PASSED"
         outHeaders="Content-Language:en"/>
   
  -    <tester host="${host}" port="${port}" protocol="${protocol}" debug="0"
  -         request="${context.path}/WrappedSetLocale01"
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/WrappedSetLocale01" debug="${debug}"
         outContent="SetLocale01 PASSED"
         outHeaders="Content-Language:en"/>
   
  @@ -515,6 +515,22 @@
            request="${context.path}/WrappedSession03" debug="${debug}"
        joinSession="true"
         outContent="Session03 PASSED"/>
  +
  +  </target>
  +
  +
  +  <target name="XercesTest">
  +
  +    <!-- ========== Xerces Sealing Violation Test ========================= -->
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/Xerces01" debug="${debug}"
  +      outContent="Xerces01 PASSED"/>
  +
  +    <tester host="${host}" port="${port}" protocol="${protocol}"
  +         request="${context.path}/WrappedXerces01" debug="${debug}"
  +      outContent="Xerces01 PASSED"/>
  +
   
     </target>
   
  
  
  
  1.1                  jakarta-tomcat-4.0/tester/src/tester/org/apache/tester/Xerces01.java
  
  Index: Xerces01.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 <apache@apache.org>.                        *
   *                                                                           *
   * 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.IOException;
  import java.io.PrintWriter;
  import java.net.MalformedURLException;
  import java.net.URL;
  import javax.servlet.*;
  import javax.servlet.http.*;
  
  
  /**
   * Ensure that we can use the Xerces parser while included in a web application
   * even though the servlet container might utilize its own parser for internal
   * use.
   *
   * @author Amy Roh
   * @author Craig McClanahan
   * @version $Revision: 1.1 $ $Date: 2001/03/13 19:06:17 $
   */
  
  public class Xerces01 extends HttpServlet {
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Perform a simple SAX parse using Xerces (based on the SAXCount
       * example application).
       *
       * @param request The servlet request we are processing
       * @param response The servlet response we are creating
       *
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet error occurs
       */
      public void service(HttpServletRequest request,
                          HttpServletResponse response)
          throws ServletException, IOException
      {
  
          // Prepare our output stream
          response.setContentType("text/plain");
          PrintWriter writer = response.getWriter();
          boolean ok = true;
  
          // Construct a new instance of our parser driver
          URL url = null;
          try {
              url = getServletContext().getResource("/Xerces01.xml");
          } catch (MalformedURLException e) {
              writer.println("Xerces01 FAILED - " + e);
              e.printStackTrace(writer);
              ok = false;
          }
          Xerces01Parser parser = new Xerces01Parser();
          try {
              if (ok)
                  parser.parse(url);
          } catch (Exception e) {
              writer.println("Xerces01 FAILED - " + e);
              e.printStackTrace(writer);
              ok = false;
          }
  
          // Report successful completion if OK
          if (ok)
              writer.println("Xerces01 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/Xerces01Parser.java
  
  Index: Xerces01Parser.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 <apache@apache.org>.                        *
   *                                                                           *
   * 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.net.URL;
  import org.xml.sax.AttributeList;
  import org.xml.sax.HandlerBase;
  import org.xml.sax.Parser;
  import org.xml.sax.SAXException;
  import org.xml.sax.SAXParseException;
  import org.xml.sax.helpers.ParserFactory;
  
  
  /**
   * SAX parser (based on SAXCount) that exercises the Xerces parser within the
   * environment of a web application.
   *
   * @author Amy Roh
   * @author Craig McClanahan
   * @version $Revision: 1.1 $ $Date: 2001/03/13 19:06:18 $
   */
  
  public class Xerces01Parser extends HandlerBase {
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * The number of XML attributes we have encountered.
       */
      protected int attributes = 0;
  
  
      /**
       * The number of characters we have encountered.
       */
      protected int characters = 0;
  
  
      /**
       * The number of XML elements we have encountered.
       */
      protected int elements = 0;
  
  
      /**
       * The amount of ignorable whitespace we have encountered.
       */
      protected int whitespace = 0;
  
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Execute the requested parse.
       *
       * @param url The URL of the XML resource to be parsed
       *
       * @exception Exception if any processing exception occurs
       */
      public void parse(URL url) throws Exception {
  
          // Construct a parser for our use
          Parser parser =
              ParserFactory.makeParser("org.apache.xerces.parsers.SAXParser");
          parser.setDocumentHandler(this);
          parser.setErrorHandler(this);
  
          // Perform the requested parse
          long before = System.currentTimeMillis();
          parser.parse(url.toString());
          long after = System.currentTimeMillis();
  
          // Log the results
          StaticLogger.write("Parsing time = " + (after - before) +
                             " milliseconds");
          StaticLogger.write("Processed " + elements + " elements");
          StaticLogger.write("Processed " + attributes + " attributes");
          StaticLogger.write("Processed " + characters + " characters");
          StaticLogger.write("Processed " + whitespace + " whitespaces");
  
      }
  
  
      // ------------------------------------------------------ SAX Error Methods
  
  
      /**
       * Receive notification of a parser error.
       *
       * @param e The parser exception being reported
       *
       * @exception SAXException if a parsing error occurs
       */
      public void error(SAXParseException e) throws SAXException {
  
          StaticLogger.write("[Error] " +
                             getLocationString(e) + ": " +
                             e.getMessage());
  
      }
  
  
      /**
       * Receive notification of a fatal error.
       *
       * @param e The parser exception being reported
       *
       * @exception SAXException if a parsing error occurs
       */
      public void fatalError(SAXParseException e) throws SAXException {
  
          StaticLogger.write("[Fatal] " +
                             getLocationString(e) + ": " +
                             e.getMessage());
  
      }
  
  
      /**
       * Receive notification of a parser warning.
       *
       * @param e The parser exception being reported
       *
       * @exception SAXException if a parsing error occurs
       */
      public void warning(SAXParseException e) throws SAXException {
  
          StaticLogger.write("[Warning] " +
                             getLocationString(e) + ": " +
                             e.getMessage());
  
      }
  
  
      /**
       * Return the location at which this exception occurred.
       *
       * @param e The SAXParseException we are reporting on
       */
      private String getLocationString(SAXParseException e) {
  
          StringBuffer sb = new StringBuffer();
          String systemId = e.getSystemId();
          if (systemId != null) {
              int index = systemId.lastIndexOf('/');
              if (index != -1)
                  systemId = systemId.substring(index + 1);
              sb.append(systemId);
          }
          sb.append(':');
          sb.append(e.getLineNumber());
          sb.append(':');
          sb.append(e.getColumnNumber());
          return (sb.toString());
  
      }
  
  
      // ------------------------------------------------------ SAX Event Methods
  
  
      /**
       * Character data event handler.
       *
       * @param ch Character array containing the characters
       * @param start Starting position in the array
       * @param length Number of characters to process
       *
       * @exception SAXException if a parsing error occurs
       */
      public void characters(char ch[], int start, int length)
          throws SAXException {
  
          characters += length;
  
      }
  
  
      /**
       * Ignorable whitespace event handler.
       *
       * @param ch Character array containing the characters
       * @param start Starting position in the array
       * @param length Number of characters to process
       *
       * @exception SAXException if a parsing error occurs
       */
      public void ignorableWhitespace(char ch[], int start, int length)
          throws SAXException {
  
          whitespace += length;
  
      }
  
  
      /**
       * Start of element event handler.
       *
       * @param name The element type name
       * @param attrs The specified or defaulted attributes
       *
       * @exception SAXException if a parsing error occurs
       */
      public void startElement(String name, AttributeList attrs) {
  
          elements++;
          if (attrs != null)
              attributes += attrs.getLength();
  
      }
  
  
  
  }
  
  
  
  1.1                  jakarta-tomcat-4.0/tester/web/Xerces01.xml
  
  Index: Xerces01.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <personnel>
  
    <person id="Big.Boss">
      <name><family>Boss</family> <given>Big</given></name>
      <email>chief@foo.com</email>
      <link subordinates="one.worker two.worker three.worker four.worker five.worker"/>
    </person>
  
    <person id="one.worker">
      <name><family>Worker</family> <given>One</given></name>
      <email>one@foo.com</email>
      <link manager="Big.Boss"/>
    </person>
  
    <person id="two.worker">
      <name><family>Worker</family> <given>Two</given></name>
      <email>two@foo.com</email>
      <link manager="Big.Boss"/>
    </person>
  
    <person id="three.worker">
      <name><family>Worker</family> <given>Three</given></name>
      <email>three@foo.com</email>
      <link manager="Big.Boss"/>
    </person>
  
    <person id="four.worker">
      <name><family>Worker</family> <given>Four</given></name>
      <email>four@foo.com</email>
      <link manager="Big.Boss"/>
    </person>
  
    <person id="five.worker">
      <name><family>Worker</family> <given>Five</given></name>
      <email>five@foo.com</email>
      <link manager="Big.Boss"/>
    </person>
  
  </personnel>
  
  
  
  1.13      +20 -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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- web.xml	2001/02/22 01:07:27	1.12
  +++ web.xml	2001/03/13 19:06:22	1.13
  @@ -170,7 +170,12 @@
           <url-pattern>/WrappedSetLocale01</url-pattern>
       </filter-mapping>
   
  +    <filter-mapping>
  +        <filter-name>HttpFilter</filter-name>
  +        <url-pattern>/WrappedXerces01</url-pattern>
  +    </filter-mapping>
   
  +
       <!-- ========== Servlet Definitions =================================== -->
   
       <servlet>
  @@ -318,7 +323,12 @@
           <servlet-class>org.apache.tester.SetLocale01</servlet-class>
       </servlet>
   
  +    <servlet>
  +        <servlet-name>Xerces01</servlet-name>
  +        <servlet-class>org.apache.tester.Xerces01</servlet-class>
  +    </servlet>
   
  +
       <!-- ========== Servlet Mappings ====================================== -->
   
       <servlet-mapping>
  @@ -604,6 +614,16 @@
       <servlet-mapping>
           <servlet-name>SetLocale01</servlet-name>
           <url-pattern>/WrappedSetLocale01</url-pattern>
  +    </servlet-mapping>
  +
  +    <servlet-mapping>
  +        <servlet-name>Xerces01</servlet-name>
  +        <url-pattern>/Xerces01</url-pattern>
  +    </servlet-mapping>
  +
  +    <servlet-mapping>
  +        <servlet-name>Xerces01</servlet-name>
  +        <url-pattern>/WrappedXerces01</url-pattern>
       </servlet-mapping>
   
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, email: tomcat-dev-help@jakarta.apache.org


Mime
View raw message