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/webapps build.xml
Date Tue, 22 May 2001 01:59:05 GMT
craigmcc    01/05/21 18:59:05

  Modified:    .        build.xml
               catalina build.xml
               jasper   build.xml
               webapps  build.xml
  Added:       catalina/src/test/org/apache/catalina/util
                        CookieToolsTestCase.java
  Log:
  Equip the build scripts for "catalina", "jasper", and "webapps" to run
  JUnit based unit tests (compiled and executed only if you have junit.jar
  on your CLASSPATH) when you run "ant test".
  
  Added an initial JUnit test suite for org.apache.catalina.util.CookieTools
  to illustrate the concept.  Additional Catalina unit tests should go under
  "src/test/org/apache/catalina/*", and you should modify
  "catalina/build.xml" as needed to execute them.
  
  Revision  Changes    Path
  1.23      +7 -0      jakarta-tomcat-4.0/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/build.xml,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- build.xml	2001/05/21 21:47:12	1.22
  +++ build.xml	2001/05/22 01:59:04	1.23
  @@ -55,6 +55,13 @@
     </target>
   
   
  +  <!-- ======================= COMBO: Test All Components ================= -->
  +  <target name="test">
  +    <ant dir="./catalina" target="test"/>
  +    <ant dir="./jasper"   target="test"/>
  +    <ant dir="./webapps"  target="test"/>
  +  </target>
  +
   
     <!-- ====================== DIST: Create Directories ==================== -->
     <target name="dist-prepare">
  
  
  
  1.41      +51 -1     jakarta-tomcat-4.0/catalina/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/build.xml,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- build.xml	2001/05/21 21:47:17	1.40
  +++ build.xml	2001/05/22 01:59:04	1.41
  @@ -17,6 +17,9 @@
     <property name="servletapi.home"   value="../../jakarta-servletapi-4/dist"/>
     <property name="avalon.dist"       value="../../dist/avalon"/>
   
  +  <property name="test.failonerror"  value="true"/>
  +  <property name="test.runner"       value="junit.textui.TestRunner"/>
  +
     <!-- ================== Derived Property Values ========================= -->
     <property name="jaxp.jar"        value="${catalina.jaxp.home}/jaxp.jar"/>
     <property name="parser.jar"      value="${catalina.jaxp.home}/${catalina.jaxp.parser.jar}"/>
  @@ -28,8 +31,24 @@
     <property name="regexp.jar"      value="${regexp.home}/jakarta-regexp-1.2.jar"/>
     <property name="servlet.jar"     value="${servletapi.home}/lib/servlet.jar"/>
   
  +  <!-- Construct unit tests classpath -->
  +  <path id="test.classpath">
  +    <pathelement location="${parser.jar}"/>
  +    <pathelement location="${jaxp.jar}"/>
  +    <pathelement location="${regexp.jar}"/>
  +    <pathelement location="${servlet.jar}"/>
  +    <pathelement location="${jcert.jar}"/>
  +    <pathelement location="${jnet.jar}"/>
  +    <pathelement location="${jsse.jar}"/>
  +    <pathelement location="${jmxri.jar}"/>
  +    <pathelement location="${junit.jar}"/>
  +    <pathelement location="${catalina.build}/classes"/>
  +    <pathelement location="${catalina.build}/tests"/>
  +  </path>
  +
     <!-- =================== BUILD: Create Directories ====================== -->
     <target name="build-prepare">
  +    <available classname="junit.framework.TestCase" property="junit.present" />
       <available file="${jaxp.jar}" property="jaxp.jar.present" />
       <available property="avalon.present" 
        classname="org.apache.avalon.blocks.Block" />
  @@ -107,7 +126,6 @@
        classname="org.apache.avalon.blocks.Block" />
       <available property="javamail.present"
        classname="javax.mail.internet.MimeMessage" />
  -
       <!-- Compile internal server components -->
       <javac   srcdir="src/share" destdir="${catalina.build}/classes"
                classpath="${parser.jar}:${jaxp.jar}:${regexp.jar}:${servlet.jar}:${jcert.jar}:${jnet.jar}:${jsse.jar}:${jmxri.jar}"
  @@ -156,6 +174,19 @@
     </target>
   
   
  +  <!-- =============== BUILD: Compile Unit Tests ========================== -->
  +
  +  <target name="build-tests" depends="build-main" if="junit.present">
  +    <mkdir      dir="${catalina.build}/tests"/>
  +    <!-- Compile unit test classes -->
  +    <javac   srcdir="src/test" destdir="${catalina.build}/tests"
  +             deprecation="off" debug="on" optimize="off" target="1.2"
  +             excludes="**/CVS/**">
  +      <classpath refid="test.classpath"/>
  +    </javac>
  +  </target>
  +
  +
     <!-- ================ BUILD: Create Catalina Javadocs =================== -->
     <target name="javadoc" depends="build-main">
       <delete dir="${catalina.build}/javadoc"/>
  @@ -197,6 +228,25 @@
   
     <!-- ==================== BUILD: Rebuild Everything ===================== -->
     <target name="all" depends="build-clean,build-main"/>
  +
  +
  +  <!-- ==================== BUILD: Execute Unit Tests ===================== -->
  +  <target name="test" if="junit.present"
  +   description="Run all unit test cases"
  +   depends="build-tests,test-util"
  +>
  +  </target>
  +
  +  <target name="test-util" if="junit.present">
  +
  +    <echo message="Running CookieTools tests"/>
  +    <java classname="${test.runner}" fork="yes"
  +        failonerror="${test.failonerror}">
  +      <arg value="org.apache.catalina.util.CookieToolsTestCase"/>
  +      <classpath refid="test.classpath"/>
  +    </java>
  +
  +  </target>
   
   
     <!-- ====================== DEPLOY: Create Directories ================== -->
  
  
  
  1.1                  jakarta-tomcat-4.0/catalina/src/test/org/apache/catalina/util/CookieToolsTestCase.java
  
  Index: CookieToolsTestCase.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/test/org/apache/catalina/util/CookieToolsTestCase.java,v
1.1 2001/05/22 01:59:05 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2001/05/22 01:59:05 $
   *
   * ====================================================================
   *
   * 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.catalina.util;
  
  import javax.servlet.http.Cookie;
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  
  
  /**
   * Unit tests for the <code>CookieTools</code> class.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2001/05/22 01:59:05 $
   */
  
  public class CookieToolsTestCase extends TestCase {
  
  
      public static void main(String args[]) {
          System.out.println("TestCase started");
      }
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * A "version 0" cookie.
       */
      protected Cookie version0 = null;
  
  
      /**
       * A "version 1" cookie.
       */
      protected Cookie version1 = null;
  
  
  
      // ----------------------------------------------------------- Constructors
  
  
      /**
       * Construct a new instance of this test case.
       *
       * @param name Name of the test case
       */
      public CookieToolsTestCase(String name) {
  
          super(name);
  
      }
  
  
      // --------------------------------------------------- Overall Test Methods
  
  
      /**
       * Set up instance variables required by this test case.
       */
      public void setUp() {
  
          version0 = new Cookie("Version 0 Name", "Version 0 Value");
          version0.setComment("Version 0 Comment");
          version0.setDomain("localhost");
          version0.setPath("/version0");
          version0.setVersion(0);
  
          version1 = new Cookie("Version 1 Name", "Version 1 Value");
          version1.setComment("Version 1 Comment");
          version1.setDomain("localhost");
          version1.setPath("/version1");
          version1.setVersion(1);
  
      }
  
  
      /**
       * Return the tests included in this test suite.
       */
      public static Test suite() {
  
          return (new TestSuite(CookieToolsTestCase.class));
  
      }
  
  
      /**
       * Tear down instance variables required by this test case.
       */
      public void tearDown() {
  
          version0 = null;
          version1 = null;
  
      }
  
  
      // ------------------------------------------------ Individual Test Methods
  
  
      /**
       * Check the value returned by <code>getCookieHeaderName()</code>.
       */
      public void testGetCookieHeaderName() {
  
          assertEquals("Version 0 cookie header name", "Set-Cookie",
                       CookieTools.getCookieHeaderName(version0));
          assertEquals("Version 1 cookie header name", "Set-Cookie2",
                       CookieTools.getCookieHeaderName(version1));
  
      }
  
  
      /**
       * Check the value returned by <code>getCookieHeaderValue()</code>
       */
      public void testGetCookieHeaderValue() {
  
          StringBuffer sb = null;
  
          sb = new StringBuffer();
          CookieTools.getCookieHeaderValue(version0, sb);
          assertEquals("Version 0 cookie header value",
                       "Version 0 Name=Version 0 Value;Domain=localhost;Path=/version0",
                       sb.toString());
  
          sb = new StringBuffer();
          CookieTools.getCookieHeaderValue(version1, sb);
          assertEquals("Version 1 cookie header value",
                       "Version 1 Name=\"Version 1 Value\";Version=1;Comment=\"Version 1 Comment\";Domain=localhost;Discard;Path=\"/version1\"",
                       sb.toString());
  
      }
  
  
  }
  
  
  
  1.18      +38 -0     jakarta-tomcat-4.0/jasper/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/build.xml,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- build.xml	2001/05/21 21:47:19	1.17
  +++ build.xml	2001/05/22 01:59:05	1.18
  @@ -15,6 +15,10 @@
     <property name="jasper.jaxp.parser.jar" value="crimson.jar"/>
     <property name="servletapi.home" value="../../jakarta-servletapi-4/dist"/>
   
  +  <property name="test.failonerror"  value="true"/>
  +  <property name="test.runner"       value="junit.textui.TestRunner"/>
  +
  +
     <!-- ================== Derived Property Values ========================= -->
     <property name="jaxp.jar"        value="${jasper.jaxp.home}/jaxp.jar"/>
     <property name="parser.jar"      value="${jasper.jaxp.home}/${jasper.jaxp.parser.jar}"/>
  @@ -22,8 +26,20 @@
     <property name="tools.jar"       value="${java.home}/lib/tools.jar"/>
   
   
  +  <!-- Construct unit tests classpath -->
  +  <path id="test.classpath">
  +    <pathelement location="${parser.jar}"/>
  +    <pathelement location="${jaxp.jar}"/>
  +    <pathelement location="${servlet.jar}"/>
  +    <pathelement location="${junit.jar}"/>
  +    <pathelement location="${jasper.build}/classes"/>
  +    <pathelement location="${jasper.build}/tests"/>
  +  </path>
  +
  +
     <!-- =================== BUILD: Create Directories ====================== -->
     <target name="build-prepare">
  +    <available classname="junit.framework.TestCase" property="junit.present" />
       <available file="${jaxp.jar}" property="jaxp.jar.present" />
       <mkdir dir="${jasper.build}"/>
       <mkdir dir="${jasper.build}/bin"/>
  @@ -76,6 +92,21 @@
     </target>
   
   
  +  <!-- =============== BUILD: Compile Unit Tests ========================== -->
  +
  +  <target name="build-tests" depends="build-main" if="junit.present">
  +    <mkdir      dir="${jasper.build}/tests"/>
  +    <!-- Compile unit test classes -->
  +<!--
  +    <javac   srcdir="src/test" destdir="${jasper.build}/tests"
  +             deprecation="off" debug="on" optimize="off" target="1.2"
  +             excludes="**/CVS/**">
  +      <classpath refid="test.classpath"/>
  +    </javac>
  +-->
  +  </target>
  +
  +
     <!-- ================ BUILD: Create Jasper Javadocs ===================== -->
     <target name="javadoc" depends="build-main">
       <delete dir="${jasper.build}/javadoc"/>
  @@ -102,6 +133,13 @@
     <!-- ==================== BUILD: Rebuild Everything ===================== -->
     <target name="all" depends="build-clean,build-main"/>
   
  +
  +  <!-- ==================== BUILD: Execute Unit Tests ===================== -->
  +  <target name="test" if="junit.present"
  +   description="Run all unit test cases"
  +   depends="build-tests"
  +>
  +  </target>
   
     <!-- ====================== DEPLOY: Create Directories ================== -->
     <target name="deploy-prepare">
  
  
  
  1.14      +8 -0      jakarta-tomcat-4.0/webapps/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/build.xml,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- build.xml	2001/05/21 21:47:25	1.13
  +++ build.xml	2001/05/22 01:59:05	1.14
  @@ -14,12 +14,14 @@
     <property name="servletapi.home" value="../../jakarta-servletapi-4/dist"/>
   
   
  +
     <!-- ================== Derived Property Values ========================= -->
     <property name="servlet.jar"     value="${servletapi.home}/lib/servlet.jar"/>
   
   
     <!-- =================== BUILD: Create Directories ====================== -->
     <target name="build-prepare">
  +    <available classname="junit.framework.TestCase" property="junit.present" />
       <mkdir dir="${webapps.build}"/>
       <mkdir dir="${webapps.dist}"/>
     </target>
  @@ -48,6 +50,12 @@
     <!-- ================= BUILD: Compile Server Components ================= -->
     <!-- Update the depends list for each subproject -->
     <target name="build" depends="build-prepare,ROOT,examples,manager,webdav"/>
  +
  +
  +  <!-- ==================== BUILD: Execute Unit Tests ===================== -->
  +  <target name="test" if="junit.present"
  +   description="Run all unit test cases">
  +  </target>
   
   
     <!-- ======================= BUILD: Clean Directory ===================== -->
  
  
  

Mime
View raw message