tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/http11/src/test/tests test1.txt
Date Wed, 02 Jan 2002 15:06:36 GMT
remm        02/01/02 07:06:36

  Modified:    http11   build.xml
  Added:       http11/src/test test.bat
               http11/src/test/java/org/apache/coyote/http11
                        FileTester.java TestAdapter.java
               http11/src/test/tests test1.txt
  Log:
  - Add the embryo of testing tools for the WIP HTTP connector.
  
  Revision  Changes    Path
  1.2       +7 -3      jakarta-tomcat-connectors/http11/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/http11/build.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- build.xml	17 Sep 2001 06:04:00 -0000	1.1
  +++ build.xml	2 Jan 2002 15:06:35 -0000	1.2
  @@ -3,7 +3,7 @@
   
   <!--
           "Coyote" connector framework for Jakarta Tomcat
  -        $Id: build.xml,v 1.1 2001/09/17 06:04:00 remm Exp $
  +        $Id: build.xml,v 1.2 2002/01/02 15:06:35 remm Exp $
   -->
   
   
  @@ -158,12 +158,16 @@
       <jar    jarfile="${build.home}/lib/tomcat-${component.name}.jar"
               basedir="${build.home}/classes"
              manifest="${build.home}/conf/MANIFEST.MF"/>
  +    <copy      file="${tomcat-util.jar}" 
  +             tofile="${build.home}/lib/tomcat-util.jar" />
  +    <copy      file="${tomcat-coyote.jar}" 
  +             tofile="${build.home}/lib/tomcat-coyote.jar" />
     </target>
   
   
     <target name="compile.tests" depends="compile"
      description="Compile unit test cases">
  -    <javac  srcdir="${test.home}"
  +    <javac  srcdir="${test.home}/java"
              destdir="${build.home}/tests"
                debug="${compile.debug}"
          deprecation="${compile.deprecation}"
  @@ -183,7 +187,7 @@
     </target>
   
   
  -  <target name="all" depends="clean,compile"
  +  <target name="all" depends="clean,compile,compile.tests"
      description="Clean and compile all components"/>
   
   
  
  
  
  1.1                  jakarta-tomcat-connectors/http11/src/test/test.bat
  
  Index: test.bat
  ===================================================================
  
  
  java -cp .;../lib/tomcat-util.jar;../lib/tomcat-coyote.jar;../lib/tomcat-coyote-http11.jar
org.apache.coyote.http11.FileTester tests/test1.txt tests/test1.out
  
  
  
  
  1.1                  jakarta-tomcat-connectors/http11/src/test/java/org/apache/coyote/http11/FileTester.java
  
  Index: FileTester.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    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 Group.
   *
   * 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
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */ 
  package org.apache.coyote.http11;
  
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileOutputStream;
  import java.io.InputStream;
  import java.io.IOException;
  import java.io.OutputStream;
  import java.util.Locale;
  
  import org.apache.coyote.Adapter;
  import org.apache.coyote.Connector;
  
  /**
   * File tester.
   * <p>
   * This tester is initialized with an adapter (it will use the HTTP/1.1 
   * connector), and will then accept an input file (which will contain the 
   * input data), and an output file, to which the result of the request(s)
   * will be written.
   *
   * @author Remy Maucherat
   */
  public class FileTester {
  
  
      // -------------------------------------------------------------- Constants
  
  
      // ----------------------------------------------------------- Constructors
  
  
      /**
       * Construct a new file tester using the two files specified. The contents
       * of the output file will be overwritten when the test is run.
       * 
       * @param adapter Coyote adapter to use for this test
       * @param connector Coyote connector to use for this test
       * @param inputFile File containing the HTTP requests in plain text
       * @param outputFile File containing the HTTP responses
       */
      public FileTester(Adapter adapter, Connector connector,
                        File inputFile, File outputFile) {
  
          connector.setAdapter(adapter);
  
          this.adapter = adapter;
          this.connector = connector;
          this.inputFile = inputFile;
          this.outputFile = outputFile;
  
      }
  
  
      // --------------------------------------------------------- Static Methods
  
  
      /**
       * Utility main method, which will use the HTTP/1.1 connector with the 
       * test adapter.
       *
       * @param args Command line arguments to be processed
       */
      public static void main(String args[])
          throws Exception {
  
          if (args.length < 2) {
              System.out.println("Incorrect number of arguments");
              return;
          }
  
          // The first argument is the input file
          File inputFile = new File(args[0]);
  
          // The second argument is the output file
          File outputFile = new File(args[1]);
  
          Adapter testAdapter = new TestAdapter();
          Connector http11Connector = new Http11Connector();
  
          FileTester tester = new FileTester(testAdapter, http11Connector,
                                             inputFile, outputFile);
          tester.test();
  
      }
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * File containing the input data.
       */
      protected File inputFile;
  
  
      /**
       * File containing the output data.
       */
      protected File outputFile;
  
  
      /**
       * Coyote adapter to use.
       */
      protected Adapter adapter;
  
  
      /**
       * Coyote connector to use.
       */
      protected Connector connector;
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Process the test.
       */
      public void test()
          throws Exception {
  
          InputStream is = new FileInputStream(inputFile);
          OutputStream os = new FileOutputStream(outputFile);
  
          connector.process(is, os);
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-tomcat-connectors/http11/src/test/java/org/apache/coyote/http11/TestAdapter.java
  
  Index: TestAdapter.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    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 Group.
   *
   * 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
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */ 
  package org.apache.coyote.http11;
  
  import org.apache.tomcat.util.buf.MessageBytes;
  import org.apache.tomcat.util.http.MimeHeaders;
  
  import org.apache.coyote.Adapter;
  import org.apache.coyote.Request;
  import org.apache.coyote.Response;
  
  /**
   * Adapter which will generate content.
   *
   * @author Remy Maucherat
   */
  public class TestAdapter
      implements Adapter {
  
  
      public static final String CRLF = "\r\n";
  
  
      /** 
       * Service method, which dumps the request to the console.
       */
      public void service(Request req, Response res)
  	throws Exception {
          
          StringBuffer buf = new StringBuffer();
          buf.append(req.method());
          buf.append(" ");
          buf.append(req.unparsedURI());
          buf.append(" ");
          buf.append(req.protocol());
          buf.append(CRLF);
          
          
          
      }
  
  
  }
  
  
  
  1.1                  jakarta-tomcat-connectors/http11/src/test/tests/test1.txt
  
  Index: test1.txt
  ===================================================================
  GET /foo HTTP/1.1
  Host: localhost
  
  
  GET /bar HTTP/1.1
  Host:foobar
  
  
  
  

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


Mime
View raw message