avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/loader/src/test/org/apache/excalibur/loader/test LoaderTestSuite.java
Date Tue, 01 Oct 2002 13:10:28 GMT
donaldp     2002/10/01 06:10:28

  Modified:    loader   build.xml
               loader/src/java/org/apache/excalibur/loader/runtime
                        JoinClassLoader.java
               loader/src/test/org/apache/excalibur/loader/test
                        LoaderTestSuite.java
  Added:       loader/src/test/org/apache/excalibur/loader/runtime/test
                        JoinClassLoaderTestCase.java
  Log:
  Add in unit tests for Join ClassLoader.
  
  Revision  Changes    Path
  1.4       +58 -32    jakarta-avalon-excalibur/loader/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/loader/build.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- build.xml	4 Sep 2002 11:48:02 -0000	1.3
  +++ build.xml	1 Oct 2002 13:10:28 -0000	1.4
  @@ -62,7 +62,7 @@
               optimize="${build.optimize}"
               deprecation="${build.deprecation}"
               target="1.2">
  -            <classpath refid="project.class.path" />
  +            <classpath refid="project.class.path"/>
               <include name="**/*.java"/>
           </javac>
   
  @@ -85,6 +85,9 @@
               <fileset dir="${test.dir}"/>
           </copy>
   
  +        <property name="build.testdata" value="${build.dir}/testdata"/>
  +
  +        <mkdir dir="${build.testdata}"/>
           <mkdir dir="${build.testclasses}"/>
   
           <!-- Compile all test classes. -->
  @@ -94,8 +97,19 @@
               optimize="${build.optimize}"
               deprecation="${build.deprecation}"
               target="1.2">
  -            <classpath refid="test.class.path" />
  +            <classpath refid="test.class.path"/>
               <include name="**/*.java"/>
  +            <exclude name="**/data/**/*.java"/>
  +        </javac>
  +
  +        <javac srcdir="${build.testsrc}"
  +            destdir="${build.testdata}"
  +            debug="${build.debug}"
  +            optimize="${build.optimize}"
  +            deprecation="${build.deprecation}"
  +            target="1.2">
  +            <classpath refid="test.class.path"/>
  +            <include name="**/data/**/*.java"/>
           </javac>
   
           <copy todir="${build.testclasses}">
  @@ -147,8 +161,8 @@
           <javadoc packagenames="org.apache.*"
               sourcepath="${java.dir}"
               destdir="${dist.javadocs}">
  -            <classpath refid="project.class.path" />
  -            <group title="${Name} API" packages="org.apache.excalibur.*" />
  +            <classpath refid="project.class.path"/>
  +            <group title="${Name} API" packages="org.apache.excalibur.*"/>
               <doclet name="com.sun.tools.doclets.standard.Standard">
                   <param name="-author"/>
                   <param name="-version"/>
  @@ -164,9 +178,21 @@
           </javadoc>
       </target>
   
  -    <target name="test" depends="compile-test" description="Perform the unit tests"
unless="skip.tests">
  +    <target name="build-test-data" depends="compile-test" unless="skip.tests">
  +        <mkdir dir="${build.testdata}"/>
  +        <jar jarfile="${build.tests}/cl1.jar"
  +            basedir="${build.testdata}">
  +            <include name="org/apache/excalibur/loader/test/data/cl1/**"/>
  +        </jar>
  +        <jar jarfile="${build.tests}/cl2.jar"
  +            basedir="${build.testdata}">
  +            <include name="org/apache/excalibur/loader/test/data/cl2/**"/>
  +        </jar>
  +    </target>
  +
  +    <target name="test" depends="build-test-data" description="Perform the unit tests"
unless="skip.tests">
   
  -        <echo message="Performing Unit Tests" />
  +        <echo message="Performing Unit Tests"/>
   
           <mkdir dir="${build.tests}"/>
   
  @@ -280,16 +306,16 @@
           </taskdef>
   
           <mkdir dir="gen"/>
  -        <avalon-xinfo force="true" destdir="gen" >
  +        <avalon-xinfo force="true" destdir="gen">
               <fileset dir="${java.dir}">
  -                <include name="**/demo/components/*.java" />
  +                <include name="**/demo/components/*.java"/>
               </fileset>
               <componentinfo/>
           </avalon-xinfo>
   
           <serialize-info destDir="gen">
               <fileset dir="gen">
  -                <include name="**/*.xinfo" />
  +                <include name="**/*.xinfo"/>
               </fileset>
           </serialize-info>
       </target>
  @@ -369,24 +395,24 @@
               velocitypropertiesfile="../site/src/stylesheets/velocity.properties"
               />
   
  -     <copy todir="${docs.dir}" filtering="off">
  -      <fileset dir="../site/src" includes="css/*.css" />
  -      <fileset dir="${xdocs.dir}">
  -        <include name="**/images/**"/>
  -        <include name="**/*.gif"/>
  -        <include name="**/*.jpg"/>
  -        <include name="**/*.png"/>
  -        <include name="**/*.css"/>
  -        <include name="**/*.js"/>
  -      </fileset>
  -    </copy>
  -
  -    <copy todir="${docs.dir}" filtering="off">
  -      <fileset dir="${java.dir}">
  -        <include name="org/apache/excalibur/loader/builder/classloader.dtd"/>
  -      </fileset>
  -      <mapper type="flatten"/>
  -    </copy>
  +        <copy todir="${docs.dir}" filtering="off">
  +            <fileset dir="../site/src" includes="css/*.css"/>
  +            <fileset dir="${xdocs.dir}">
  +                <include name="**/images/**"/>
  +                <include name="**/*.gif"/>
  +                <include name="**/*.jpg"/>
  +                <include name="**/*.png"/>
  +                <include name="**/*.css"/>
  +                <include name="**/*.js"/>
  +            </fileset>
  +        </copy>
  +
  +        <copy todir="${docs.dir}" filtering="off">
  +            <fileset dir="${java.dir}">
  +                <include name="org/apache/excalibur/loader/builder/classloader.dtd"/>
  +            </fileset>
  +            <mapper type="flatten"/>
  +        </copy>
   
       </target>
   
  @@ -404,10 +430,10 @@
       <!-- Cleans up build and distribution directories -->
       <target name="clean" description="Cleans up the project">
           <delete file="checkstyle.cache"/>
  -        <delete dir="${build.dir}" />
  -        <delete dir="${dist.dir}" />
  -        <delete dir="${docs.dir}" />
  -        <delete dir="test" /> <!-- unit testing output directory -->
  +        <delete dir="${build.dir}"/>
  +        <delete dir="${dist.dir}"/>
  +        <delete dir="${docs.dir}"/>
  +        <delete dir="test"/> <!-- unit testing output directory -->
           <delete>
               <fileset dir="." includes="velocity.*"/>
               <fileset dir="." includes="**/*~" defaultexcludes="no"/>
  @@ -415,7 +441,7 @@
       </target>
   
       <target name="real-clean" depends="clean" description="Cleans up the project, including
distributions">
  -        <delete dir="${dist.base}" />
  +        <delete dir="${dist.base}"/>
       </target>
   
   </project>
  
  
  
  1.2       +3 -3      jakarta-avalon-excalibur/loader/src/java/org/apache/excalibur/loader/runtime/JoinClassLoader.java
  
  Index: JoinClassLoader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/loader/src/java/org/apache/excalibur/loader/runtime/JoinClassLoader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JoinClassLoader.java	25 Sep 2002 13:40:17 -0000	1.1
  +++ JoinClassLoader.java	1 Oct 2002 13:10:28 -0000	1.2
  @@ -44,8 +44,8 @@
        * @param parent the parent classloader
        * @param classLoaders the classloaders to search
        */
  -    public JoinClassLoader( final ClassLoader parent,
  -                            final ClassLoader[] classLoaders )
  +    public JoinClassLoader( final ClassLoader[] classLoaders, final ClassLoader parent
  +                            )
       {
           super( parent );
           if( null == classLoaders )
  
  
  
  1.1                  jakarta-avalon-excalibur/loader/src/test/org/apache/excalibur/loader/runtime/test/JoinClassLoaderTestCase.java
  
  Index: JoinClassLoaderTestCase.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.excalibur.loader.runtime.test;
  
  import java.io.File;
  import java.net.MalformedURLException;
  import java.net.URL;
  import java.net.URLClassLoader;
  import junit.framework.TestCase;
  import org.apache.excalibur.loader.runtime.JoinClassLoader;
  
  /**
   * Unit test for join classloader.
   *
   * @author <a href="mailto:peter at apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/10/01 13:10:28 $
   */
  public class JoinClassLoaderTestCase extends TestCase
  {
      private static final String DATA1_CLASS = "org.apache.excalibur.loader.test.data.cl1.Data1";
      private static final String DATA2_CLASS = "org.apache.excalibur.loader.test.data.cl2.CL2Data";
  
      public JoinClassLoaderTestCase( String name )
      {
          super( name );
      }
  
      public void testJoinClassLoader()
          throws Exception
      {
          final URLClassLoader cl1 = createClassLoader( "cl1.jar" );
          final URLClassLoader cl2 = createClassLoader( "cl2.jar" );
          final ClassLoader[] cls = new ClassLoader[]{cl1, cl2};
          final JoinClassLoader join =
              new JoinClassLoader( cls, ClassLoader.getSystemClassLoader() );
          try
          {
              join.loadClass( DATA1_CLASS );
          }
          catch( ClassNotFoundException e )
          {
              fail( "Unable to load Data1 from cl1 classloader" );
          }
          try
          {
              join.loadClass( DATA2_CLASS );
          }
          catch( ClassNotFoundException e )
          {
              fail( "Unable to load CL2Data from cl2 classloader" );
          }
  
          try
          {
              ClassLoader.getSystemClassLoader().loadClass( DATA1_CLASS );
          }
          catch( ClassNotFoundException e )
          {
              return;
          }
          fail( "Able to load Data1 from system classloader" );
      }
  
      private URLClassLoader createClassLoader( final String filename ) throws MalformedURLException
      {
          final File baseDirectory = new File( "." );
          final File file = new File( baseDirectory, filename );
          final URL url = file.toURL();
          final URL[] urls = new URL[]{url};
          return new URLClassLoader( urls, ClassLoader.getSystemClassLoader() );
      }
  }
  
  
  
  1.5       +2 -0      jakarta-avalon-excalibur/loader/src/test/org/apache/excalibur/loader/test/LoaderTestSuite.java
  
  Index: LoaderTestSuite.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/loader/src/test/org/apache/excalibur/loader/test/LoaderTestSuite.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- LoaderTestSuite.java	16 Sep 2002 08:15:17 -0000	1.4
  +++ LoaderTestSuite.java	1 Oct 2002 13:10:28 -0000	1.5
  @@ -11,6 +11,7 @@
   import junit.framework.TestSuite;
   import org.apache.excalibur.loader.reader.test.ReaderTestCase;
   import org.apache.excalibur.loader.verifier.test.VerifierTestCase;
  +import org.apache.excalibur.loader.runtime.test.JoinClassLoaderTestCase;
   
   /**
    * A basic test suite that tests all the Loader package.
  @@ -22,6 +23,7 @@
           final TestSuite suite = new TestSuite( "Loader Utilities" );
           suite.addTest( new TestSuite( ReaderTestCase.class ) );
           suite.addTest( new TestSuite( VerifierTestCase.class ) );
  +        suite.addTest( new TestSuite( JoinClassLoaderTestCase.class ) );
           return suite;
       }
   }
  
  
  

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


Mime
View raw message