commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r179242 - in /jakarta/commons/proper/lang/trunk: build.xml default.properties src/test/org/apache/commons/lang/ClassUtilsTest.java src/test/org/apache/commons/lang/enum/EnumTest.java src/test/org/apache/commons/lang/enums/EnumTest.java
Date Tue, 31 May 2005 17:48:10 GMT
Author: ggregory
Date: Tue May 31 10:48:08 2005
New Revision: 179242

URL: http://svn.apache.org/viewcvs?rev=179242&view=rev
Log:
I've finally worked out the oddball build and class loading issue that only seems to happen
on Windows XP (SP2) since Simon reports that the ant build works fine for him on Linux. 

I can report success with "ant clean dist-build-2.1 test" on Sun Java versions:

1.5.0_03
1.5.0_02
1.4.2_08
1.3.1_14

In order achieve this; the new build.xml depends on Ant 1.6.

Version 1.2.2_017 hangs miserably for me though, as it did before.

Modified:
    jakarta/commons/proper/lang/trunk/build.xml
    jakarta/commons/proper/lang/trunk/default.properties
    jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/ClassUtilsTest.java
    jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/enum/EnumTest.java
    jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/enums/EnumTest.java

Modified: jakarta/commons/proper/lang/trunk/build.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/build.xml?rev=179242&r1=179241&r2=179242&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/build.xml (original)
+++ jakarta/commons/proper/lang/trunk/build.xml Tue May 31 10:48:08 2005
@@ -14,215 +14,165 @@
 limitations under the License.
 -->
 <project name="Lang" default="compile" basedir=".">
-    <!--
+	<!--
         "Lang" component of the Jakarta Commons Subproject
         $Id$
     -->
-    <!-- ========== Initialize Properties ===================================== -->
-    <property file="${user.home}/${component.name}.build.properties"/>
-    <property file="${user.home}/build.properties"/>
-    <property file="${basedir}/build.properties"/>
-    <property file="${basedir}/default.properties"/>
+	<!-- ========== Initialize Properties ===================================== -->
+	<property file="${user.home}/${component.name}.build.properties"/>
+	<property file="${user.home}/build.properties"/>
+	<property file="${basedir}/build.properties"/>
+	<property file="${basedir}/default.properties"/>
 	<!-- The Sun Javadoc for versions prior to 1.3 are off-line. -->
-    <property name="jdk.javadoc" value="http://java.sun.com/j2se/1.3/docs/api/"/>
-         <!-- ========== Construct compile classpath =============================== -->
-    <path id="compile.classpath">
-        <pathelement location="${build.home}/classes"/>
-    </path>
-    <!-- ========== Construct unit test classpath ============================= -->
-    <path id="test.classpath">
-        <pathelement location="${build.home}/classes"/>
-        <pathelement location="${build.home}/tests"/>
-        <pathelement location="${junit.jar}"/>
-    </path>
-    <!-- ========== Executable Targets ======================================== -->
-    <target name="init" description="Initialize and evaluate conditionals">
-        <echo message="-------- ${component.name} ${component.version} --------"/>
-        <filter token="name" value="${component.name}"/>
-        <filter token="package" value="${component.package}"/>
-        <filter token="version" value="${component.version}"/>
-    </target>
-    <target name="prepare" depends="init" description="Prepare build directory">
-        <mkdir dir="${build.home}"/>
-        <mkdir dir="${build.home}/classes"/>
-        <mkdir dir="${build.home}/conf"/>
-        <mkdir dir="${build.home}/tests"/>
-    </target>
-    <target name="static" depends="prepare" description="Copy static files to build directory">
-        <tstamp/>
-        <copy todir="${build.home}/conf" filtering="on">
-            <fileset dir="${conf.home}" includes="*.MF"/>
-        </copy>
-    </target>
-    <target name="compile" depends="static" description="Compile shareable components">
-        <javac srcdir="${source.home}"
-               destdir="${build.home}/classes"
-               debug="${compile.debug}"
-               deprecation="${compile.deprecation}"
-               target="${compile.target}"
-               source="${compile.source}"
-	       excludes="${compile.excludes}"
-               optimize="${compile.optimize}">
-            <classpath refid="compile.classpath"/>
-        </javac>
-        <copy todir="${build.home}/classes" filtering="on">
-            <fileset dir="${source.home}" excludes="**/*.java"/>
-        </copy>
-    </target>
-    <target name="compile.tests" depends="compile" description="Compile unit test cases">
-        <javac srcdir="${test.home}"
-               destdir="${build.home}/tests"
-               debug="${compile.debug}"
-               deprecation="off"
-               target="${compile.target}"
-               source="${compile.source}"
-               optimize="${compile.optimize}">
-            <classpath refid="test.classpath"/>
-        </javac>
-        <copy todir="${build.home}/tests" filtering="on">
-            <fileset dir="${test.home}" excludes="**/*.java"/>
-        </copy>
-    </target>
-    <target name="clean" description="Clean build and distribution directories">
-        <delete dir="${build.home}"/>
-        <delete dir="${dist.home}"/>
-    </target>
-    <target name="all" depends="clean,compile" description="Clean and compile all components"/>
-    <target name="javadoc" depends="compile" description="Create component Javadoc documentation">
-        <mkdir dir="${dist.home}"/>
-        <mkdir dir="${dist.home}/docs"/>
-        <mkdir dir="${dist.home}/docs/api"/>
-        <javadoc sourcepath="${source.home}"
-	        	 destdir="${dist.home}/docs/api"
-	        	 overview="${source.home}/org/apache/commons/lang/overview.html"
-	        	 packagenames="org.apache.commons.*"
-			 excludepackagenames="${javadoc.excludepackagenames}"
-	        	 author="true"
-	        	 version="true"
-	        	 doctitle="&lt;h1&gt;${component.title}&lt;/h1&gt;"
-	        	 windowtitle="${component.title} (Version ${component.version})"
-	        	 bottom="Copyright &amp;copy; 2001-${copyright.end} - Apache Software Foundation"
-	        	 use="true"
-	        	 link="${jdk.javadoc}"
-                 source="${compile.source}">
-            <classpath refid="compile.classpath"/>
-        </javadoc>
-    </target>
-    <target name="dist" depends="compile,javadoc" description="Create binary distribution">
-        <mkdir dir="${dist.home}"/>
-        <copy file="LICENSE.txt" todir="${dist.home}"/>
-        <copy file="NOTICE.txt" todir="${dist.home}"/>
-        <copy file="RELEASE-NOTES.txt" todir="${dist.home}"/>
-        <antcall target="jar"/>
-    </target>
-    <target name="dist-build-2.1" description="Build binary distribution files excluding
the text package">
-        <delete dir="src/java/org/apache/commons/lang/text"/>
-        <delete dir="src/test/org/apache/commons/lang/text"/>
-        <antcall target="dist-build"/>
-    </target>
-    <target name="dist-build" depends="clean,dist" description="Build binary distribution
files">
-        <mkdir dir="${final.name}"/>
-        <move todir="${final.name}/${final.name}">
-            <fileset dir="${dist.home}"/>
-        </move>
-	<tar destfile="${final.name}.tar" basedir="${final.name}"/>
-	<gzip zipfile="${final.name}.tar.gz" src="${final.name}.tar"/>
-	<delete file="${final.name}.tar"/>
-	<fixcrlf srcdir="${final.name}" eol="crlf" includes="**/*.txt"/>
-	<zip destfile="${final.name}.zip" basedir="${final.name}"/>
-	<delete dir="${final.name}"/>
-    </target>
-    <target name="jar" depends="compile" description="Create jar">
-        <mkdir dir="${dist.home}"/>
-        <mkdir dir="${build.home}/classes/META-INF"/>
-        <copy file="LICENSE.txt" tofile="${build.home}/classes/META-INF/LICENSE.txt"/>
-        <copy file="NOTICE.txt" tofile="${build.home}/classes/META-INF/NOTICE.txt"/>
-        <jar jarfile="${dist.home}/${final.name}.jar" basedir="${build.home}/classes"
manifest="${build.home}/conf/MANIFEST.MF" excludes="**/*.html"/>
-    </target>
-    <target name="install-jar" depends="jar" description="--> Installs jar file in
${lib.repo}">
-        <copy todir="${lib.repo}" filtering="no">
-            <fileset dir="${dist.home}">
-                <include name="${final.name}.jar"/>
-            </fileset>
-        </copy>
-    </target>
-    <!-- ========== Unit Test Targets ========================================= -->
-<!-- removed test.text target from the depends list for the 2.1 release. It
+	<property name="jdk.javadoc" value="http://java.sun.com/j2se/1.3/docs/api/"/>
+	<!-- ========== Construct compile classpath =============================== -->
+	<path id="compile.classpath">
+		<pathelement location="${build.home}/classes"/>
+	</path>
+	<!-- ========== Construct unit test classpath ============================= -->
+	<path id="test.classpath">
+		<pathelement location="${build.home}/classes"/>
+		<pathelement location="${build.home}/tests"/>
+		<pathelement location="${junit.jar}"/>
+	</path>
+	<!-- ========== Executable Targets ======================================== -->
+	<target name="init" description="Initialize and evaluate conditionals">
+		<echo message="-------- ${component.name} ${component.version} --------"/>
+		<filter token="name" value="${component.name}"/>
+		<filter token="package" value="${component.package}"/>
+		<filter token="version" value="${component.version}"/>
+	</target>
+	<target name="prepare" depends="init" description="Prepare build directory">
+		<mkdir dir="${build.home}"/>
+		<mkdir dir="${build.home}/classes"/>
+		<mkdir dir="${build.home}/conf"/>
+		<mkdir dir="${build.home}/tests"/>
+	</target>
+	<target name="static" depends="prepare" description="Copy static files to build directory">
+		<tstamp/>
+		<copy todir="${build.home}/conf" filtering="on">
+			<fileset dir="${conf.home}" includes="*.MF"/>
+		</copy>
+	</target>
+	<target name="compile" depends="static" description="Compile shareable components">
+		<javac srcdir="${source.home}" destdir="${build.home}/classes" debug="${compile.debug}"
deprecation="${compile.deprecation}" target="${compile.target}" source="${compile.source}"
excludes="${compile.excludes}" optimize="${compile.optimize}">
+			<classpath refid="compile.classpath"/>
+		</javac>
+		<copy todir="${build.home}/classes" filtering="on">
+			<fileset dir="${source.home}" excludes="**/*.java"/>
+		</copy>
+	</target>
+	<target name="compile.tests" depends="compile" description="Compile unit test cases">
+		<javac srcdir="${test.home}" destdir="${build.home}/tests" debug="${compile.debug}"
deprecation="off" target="${compile.target}" source="${compile.source}" optimize="${compile.optimize}">
+			<classpath refid="test.classpath"/>
+		</javac>
+		<copy todir="${build.home}/tests" filtering="on">
+			<fileset dir="${test.home}" excludes="**/*.java"/>
+		</copy>
+	</target>
+	<target name="clean" description="Clean build and distribution directories">
+		<delete dir="${build.home}"/>
+		<delete dir="${dist.home}"/>
+	</target>
+	<target name="all" depends="clean,compile" description="Clean and compile all components"/>
+	<target name="javadoc" depends="compile" description="Create component Javadoc documentation">
+		<mkdir dir="${dist.home}"/>
+		<mkdir dir="${dist.home}/docs"/>
+		<mkdir dir="${dist.home}/docs/api"/>
+		<javadoc sourcepath="${source.home}" destdir="${dist.home}/docs/api" overview="${source.home}/org/apache/commons/lang/overview.html"
packagenames="org.apache.commons.*" excludepackagenames="${javadoc.excludepackagenames}" author="true"
version="true" doctitle="&lt;h1&gt;${component.title}&lt;/h1&gt;" windowtitle="${component.title}
(Version ${component.version})" bottom="Copyright &amp;copy; 2001-${copyright.end} - Apache
Software Foundation" use="true" link="${jdk.javadoc}" source="${compile.source}">
+			<classpath refid="compile.classpath"/>
+		</javadoc>
+	</target>
+	<target name="dist" depends="compile,javadoc" description="Create binary distribution">
+		<mkdir dir="${dist.home}"/>
+		<copy file="LICENSE.txt" todir="${dist.home}"/>
+		<copy file="NOTICE.txt" todir="${dist.home}"/>
+		<copy file="RELEASE-NOTES.txt" todir="${dist.home}"/>
+		<antcall target="jar"/>
+	</target>
+	<target name="dist-build-2.1" description="Build binary distribution files excluding
the text package">
+		<delete dir="src/java/org/apache/commons/lang/text"/>
+		<delete dir="src/test/org/apache/commons/lang/text"/>
+		<antcall target="dist-build"/>
+	</target>
+	<target name="dist-build" depends="clean,dist" description="Build binary distribution
files">
+		<mkdir dir="${final.name}"/>
+		<move todir="${final.name}/${final.name}">
+			<fileset dir="${dist.home}"/>
+		</move>
+		<tar destfile="${final.name}.tar" basedir="${final.name}"/>
+		<gzip zipfile="${final.name}.tar.gz" src="${final.name}.tar"/>
+		<delete file="${final.name}.tar"/>
+		<fixcrlf srcdir="${final.name}" eol="crlf" includes="**/*.txt"/>
+		<zip destfile="${final.name}.zip" basedir="${final.name}"/>
+		<delete dir="${final.name}"/>
+	</target>
+	<target name="jar" depends="compile" description="Create jar">
+		<mkdir dir="${dist.home}"/>
+		<mkdir dir="${build.home}/classes/META-INF"/>
+		<copy file="LICENSE.txt" tofile="${build.home}/classes/META-INF/LICENSE.txt"/>
+		<copy file="NOTICE.txt" tofile="${build.home}/classes/META-INF/NOTICE.txt"/>
+		<jar jarfile="${dist.home}/${final.name}.jar" basedir="${build.home}/classes" manifest="${build.home}/conf/MANIFEST.MF"
excludes="**/*.html"/>
+	</target>
+	<target name="install-jar" depends="jar" description="--> Installs jar file in ${lib.repo}">
+		<copy todir="${lib.repo}" filtering="no">
+			<fileset dir="${dist.home}">
+				<include name="${final.name}.jar"/>
+			</fileset>
+		</copy>
+	</target>
+	<!-- ========== Unit Test Targets ========================================= -->
+	<!-- removed test.text target from the depends list for the 2.1 release. It
      should be reinstated when the text package is included -->
-    <target name="test" depends="
+	<target name="test" depends="
                                 compile.tests, 
                                 test.lang,
                                 test.builder,
-                                test.enum,
+						        test.enum,
+						        test.enums,
                                 test.exception,
                                 test.math,
                                 test.mutable,
-						        test.time"
-                                description="Run all unit test cases">
-        <echo message="Running tests ..."/>
-    </target>
-    <target name="test.lang" depends="compile.tests">
-        <echo message="Running lang package tests ..."/>
-        <java classname="${test.runner}" fork="${test.fork}" failonerror="${test.failonerror}">
-            <arg value="org.apache.commons.lang.LangTestSuite"/>
-            <classpath refid="test.classpath"/>
-        </java>
-    </target>
-    <target name="test.builder" depends="compile.tests">
-        <echo message="Running builder package tests ..."/>
-        <java classname="${test.runner}" fork="${test.fork}" failonerror="${test.failonerror}">
-            <arg value="org.apache.commons.lang.builder.BuilderTestSuite"/>
-            <classpath refid="test.classpath"/>
-        </java>
-    </target>
-    <target name="test.enum" depends="compile.tests">
-        <echo message="Running enum package tests ..."/>
-        <java classname="${test.runner}" fork="${test.fork}" failonerror="${test.failonerror}">
-            <arg value="org.apache.commons.lang.enums.EnumTestSuite"/>
-            <arg value="org.apache.commons.lang.enum.EnumTestSuite"/>
-            <classpath refid="test.classpath"/>
-        </java>
-    </target>
-    <target name="test.exception" depends="compile.tests">
-        <echo message="Running exception package tests ..."/>
-        <java classname="${test.runner}" fork="${test.fork}" failonerror="${test.failonerror}">
-            <arg value="org.apache.commons.lang.exception.ExceptionTestSuite"/>
-            <classpath refid="test.classpath"/>
-        </java>
-    </target>
-    <target name="test.math" depends="compile.tests">
-        <echo message="Running math package tests ..."/>
-        <java classname="${test.runner}" fork="${test.fork}" failonerror="${test.failonerror}">
-            <arg value="org.apache.commons.lang.math.MathTestSuite"/>
-            <classpath refid="test.classpath"/>
-        </java>
-    </target>
-    <target name="test.mutable" depends="compile.tests">
-        <echo message="Running mutable package tests ..."/>
-        <java classname="${test.runner}" fork="${test.fork}" failonerror="${test.failonerror}">
-            <arg value="org.apache.commons.lang.mutable.MutableTestSuite"/>
-            <classpath refid="test.classpath"/>
-        </java>
-    </target>
-    <target name="test.text" depends="compile.tests">
-        <echo message="Running text package tests ..."/>
-        <java classname="${test.runner}" fork="${test.fork}" failonerror="${test.failonerror}">
-            <arg value="org.apache.commons.lang.text.TextTestSuite"/>
-            <classpath refid="test.classpath"/>
-        </java>
-    </target>
-    <target name="test.time" depends="compile.tests">
-        <echo message="Running time package tests ..."/>
-        <java classname="${test.runner}" fork="${test.fork}" failonerror="${test.failonerror}">
-            <arg value="org.apache.commons.lang.time.TimeTestSuite"/>
-            <classpath refid="test.classpath"/>
-        </java>
-    </target>
-    <target name="test.util" depends="compile.tests">
-        <echo message="Running util package tests ..."/>
-        <java classname="${test.runner}" fork="${test.fork}" failonerror="${test.failonerror}">
-            <arg value="org.apache.commons.lang.util.UtilTestSuite"/>
-            <classpath refid="test.classpath"/>
-        </java>
-    </target>
+						        test.time" description="Run all unit test cases">
+		<echo message="Running tests ..."/>
+	</target>
+	<macrodef name="runTestCase">
+		<attribute name="classname"/>
+		<sequential>
+			<junit printsummary="true" showoutput="true" fork="${junit.fork}" haltonerror="${test.failonerror}">
+				<classpath refid="test.classpath"/>
+				<test name="@{classname}"/>
+			</junit>
+		</sequential>
+	</macrodef>
+	<target name="test.lang" depends="compile.tests">
+		<runTestCase classname="org.apache.commons.lang.LangTestSuite"/>
+	</target>
+	<target name="test.builder" depends="compile.tests">
+		<runTestCase classname="org.apache.commons.lang.builder.BuilderTestSuite"/>
+	</target>
+	<target name="test.enum" depends="compile.tests">
+		<runTestCase classname="org.apache.commons.lang.enum.EnumTestSuite"/>
+	</target>
+	<target name="test.enums" depends="compile.tests">
+		<runTestCase classname="org.apache.commons.lang.enums.EnumTestSuite"/>
+	</target>
+	<target name="test.exception" depends="compile.tests">
+		<runTestCase classname="org.apache.commons.lang.exception.ExceptionTestSuite"/>
+	</target>
+	<target name="test.math" depends="compile.tests">
+		<runTestCase classname="org.apache.commons.lang.math.MathTestSuite"/>
+	</target>
+	<target name="test.mutable" depends="compile.tests">
+		<runTestCase classname="org.apache.commons.lang.mutable.MutableTestSuite"/>
+	</target>
+	<target name="test.text" depends="compile.tests">
+		<runTestCase classname="org.apache.commons.lang.text.TextTestSuite"/>
+	</target>
+	<target name="test.time" depends="compile.tests">
+		<runTestCase classname="org.apache.commons.lang.time.TimeTestSuite"/>
+	</target>
+	<target name="test.util" depends="compile.tests">
+		<runTestCase classname="org.apache.commons.lang.util.UtilTestSuite"/>
+	</target>
 </project>

Modified: jakarta/commons/proper/lang/trunk/default.properties
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/default.properties?rev=179242&r1=179241&r2=179242&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/default.properties (original)
+++ jakarta/commons/proper/lang/trunk/default.properties Tue May 31 10:48:08 2005
@@ -19,6 +19,9 @@
 # The pathname of the "junit.jar" JAR file
 junit.jar = ${junit.home}/junit-3.8.1.jar
 
+# Whether or not to fork tests
+junit.fork = true
+
 # The name of this component
 component.name = commons-lang
 
@@ -51,9 +54,6 @@
 
 # The base directory for unit test sources
 test.home = src/test
-
-# Whether or not to fork tests
-test.fork = true
 
 # Should Java compilations set the 'debug' compiler option?
 compile.debug = true

Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/ClassUtilsTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/ClassUtilsTest.java?rev=179242&r1=179241&r2=179242&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/ClassUtilsTest.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/ClassUtilsTest.java
Tue May 31 10:48:08 2005
@@ -399,11 +399,18 @@
      * @return the resulting class loader
      */
     public static ClassLoader newSystemClassLoader() throws SecurityException, IllegalArgumentException
{
-        ClassLoader scl = ClassLoader.getSystemClassLoader();
-        if (!(scl instanceof URLClassLoader)) {
+        ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
+        ClassLoader myClassLoader = ClassUtilsTest.class.getClassLoader();
+        if (!(myClassLoader instanceof URLClassLoader)) {
             fail("Need a better test set up.");
         }
-        URLClassLoader urlScl = (URLClassLoader) scl;
+        if (!(systemClassLoader instanceof URLClassLoader)) {
+            fail("Need a better test set up.");
+        }
+        if (!myClassLoader.equals(systemClassLoader)) {
+            fail("Need a better test set up?");            
+        }
+        URLClassLoader urlScl = (URLClassLoader) myClassLoader;
         return URLClassLoader.newInstance(urlScl.getURLs(), null);
     }
 

Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/enum/EnumTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/enum/EnumTest.java?rev=179242&r1=179241&r2=179242&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/enum/EnumTest.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/enum/EnumTest.java
Tue May 31 10:48:08 2005
@@ -13,10 +13,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.apache.commons.lang.enum;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -27,12 +30,13 @@
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
+
 import org.apache.commons.lang.ClassUtilsTest;
 import org.apache.commons.lang.SerializationUtils;
 
 /**
  * Test cases for the {@link Enum} class.
- *
+ * 
  * @author Stephen Colebourne
  * @author Gary D. Gregory
  * @version $Id$
@@ -40,6 +44,8 @@
 
 public final class EnumTest extends TestCase {
 
+    private static final String ENUM_CLASS_NAME = "org.apache.commons.lang.enum.ColorEnum";
+
     public EnumTest(String name) {
         super(name);
     }
@@ -66,11 +72,13 @@
         try {
             ColorEnum.RED.compareTo(null);
             fail();
-        } catch (NullPointerException ex) {}
+        } catch (NullPointerException ex) {
+        }
         try {
             ColorEnum.RED.compareTo(new Object());
             fail();
-        } catch (ClassCastException ex) {}
+        } catch (ClassCastException ex) {
+        }
     }
 
     public void testEquals() {
@@ -101,12 +109,11 @@
 
     public void testList() {
         List list = new ArrayList(ColorEnum.getEnumList());
-        
+
         assertNotNull(list);
-        
-        assertEquals( list.size(),
-                        ColorEnum.getEnumMap().keySet().size());
-        
+
+        assertEquals(list.size(), ColorEnum.getEnumMap().keySet().size());
+
         Iterator it = list.iterator();
         assertSame(ColorEnum.RED, it.next());
         assertSame(ColorEnum.GREEN, it.next());
@@ -115,7 +122,7 @@
 
     public void testMap() {
         Map map = new HashMap(ColorEnum.getEnumMap());
-        
+
         assertNotNull(map);
         assertTrue(map.containsValue(ColorEnum.RED));
         assertTrue(map.containsValue(ColorEnum.GREEN));
@@ -123,8 +130,7 @@
         assertSame(ColorEnum.RED, map.get("Red"));
         assertSame(ColorEnum.GREEN, map.get("Green"));
         assertSame(ColorEnum.BLUE, map.get("Blue"));
-        assertEquals( map.keySet().size(),
-                        ColorEnum.getEnumList().size());
+        assertEquals(map.keySet().size(), ColorEnum.getEnumList().size());
     }
 
     public void testGet() {
@@ -234,7 +240,7 @@
         assertNotNull(list);
         assertEquals(2, list.size());
         assertEquals(list.size(), OperationEnum.getEnumMap().keySet().size());
-        
+
         Iterator it = list.iterator();
         assertSame(OperationEnum.PLUS, it.next());
         assertSame(OperationEnum.MINUS, it.next());
@@ -244,7 +250,7 @@
         Map map = OperationEnum.getEnumMap();
         assertNotNull(map);
         assertEquals(map.keySet().size(), OperationEnum.getEnumList().size());
-        
+
         assertTrue(map.containsValue(OperationEnum.PLUS));
         assertTrue(map.containsValue(OperationEnum.MINUS));
         assertSame(OperationEnum.PLUS, map.get("Plus"));
@@ -255,19 +261,19 @@
         assertEquals(3, OperationEnum.PLUS.eval(1, 2));
         assertEquals(-1, OperationEnum.MINUS.eval(1, 2));
     }
-    
-    //-----------------------------------------------------------------------
+
+    // -----------------------------------------------------------------------
     public void testExtended1Get() {
         assertSame(Extended1Enum.ALPHA, Extended1Enum.getEnum("Alpha"));
         assertSame(Extended1Enum.BETA, Extended1Enum.getEnum("Beta"));
         assertSame(null, Extended1Enum.getEnum("Gamma"));
         assertSame(null, Extended1Enum.getEnum("Delta"));
     }
-            
+
     public void testExtended2Get() {
         assertSame(Extended1Enum.ALPHA, Extended2Enum.ALPHA);
         assertSame(Extended1Enum.BETA, Extended2Enum.BETA);
-        
+
         assertSame(Extended2Enum.ALPHA, Extended2Enum.getEnum("Alpha"));
         assertSame(Extended2Enum.BETA, Extended2Enum.getEnum("Beta"));
         assertSame(Extended2Enum.GAMMA, Extended2Enum.getEnum("Gamma"));
@@ -278,7 +284,7 @@
         assertSame(Extended2Enum.ALPHA, Extended3Enum.ALPHA);
         assertSame(Extended2Enum.BETA, Extended3Enum.BETA);
         assertSame(Extended2Enum.GAMMA, Extended3Enum.GAMMA);
-        
+
         assertSame(Extended3Enum.ALPHA, Extended3Enum.getEnum("Alpha"));
         assertSame(Extended3Enum.BETA, Extended3Enum.getEnum("Beta"));
         assertSame(Extended3Enum.GAMMA, Extended3Enum.getEnum("Gamma"));
@@ -295,11 +301,11 @@
     public void testExtendedToString() {
         assertEquals("Extended1Enum[Alpha]", Extended1Enum.ALPHA.toString());
         assertEquals("Extended1Enum[Beta]", Extended1Enum.BETA.toString());
-        
+
         assertEquals("Extended1Enum[Alpha]", Extended2Enum.ALPHA.toString());
         assertEquals("Extended1Enum[Beta]", Extended2Enum.BETA.toString());
         assertEquals("Extended2Enum[Gamma]", Extended2Enum.GAMMA.toString());
-        
+
         assertEquals("Extended1Enum[Alpha]", Extended3Enum.ALPHA.toString());
         assertEquals("Extended1Enum[Beta]", Extended3Enum.BETA.toString());
         assertEquals("Extended2Enum[Gamma]", Extended3Enum.GAMMA.toString());
@@ -311,7 +317,7 @@
         assertNotNull(list);
         assertEquals(2, list.size());
         assertEquals(list.size(), Extended1Enum.getEnumMap().keySet().size());
-        
+
         Iterator it = list.iterator();
         assertSame(Extended1Enum.ALPHA, it.next());
         assertSame(Extended1Enum.BETA, it.next());
@@ -322,7 +328,7 @@
         assertNotNull(list);
         assertEquals(3, list.size());
         assertEquals(list.size(), Extended2Enum.getEnumMap().keySet().size());
-        
+
         Iterator it = list.iterator();
         assertSame(Extended2Enum.ALPHA, it.next());
         assertSame(Extended2Enum.BETA, it.next());
@@ -334,7 +340,7 @@
         assertNotNull(list);
         assertEquals(4, list.size());
         assertEquals(list.size(), Extended3Enum.getEnumMap().keySet().size());
-        
+
         Iterator it = list.iterator();
         assertSame(Extended3Enum.ALPHA, it.next());
         assertSame(Extended3Enum.BETA, it.next());
@@ -346,7 +352,7 @@
         Map map = Extended1Enum.getEnumMap();
         assertNotNull(map);
         assertEquals(map.keySet().size(), Extended1Enum.getEnumList().size());
-        
+
         assertTrue(map.containsValue(Extended1Enum.ALPHA));
         assertTrue(map.containsValue(Extended1Enum.BETA));
         assertSame(Extended1Enum.ALPHA, map.get("Alpha"));
@@ -357,7 +363,7 @@
         Map map = Extended2Enum.getEnumMap();
         assertNotNull(map);
         assertEquals(map.keySet().size(), Extended2Enum.getEnumList().size());
-        
+
         assertTrue(map.containsValue(Extended2Enum.ALPHA));
         assertTrue(map.containsValue(Extended2Enum.BETA));
         assertTrue(map.containsValue(Extended2Enum.GAMMA));
@@ -370,7 +376,7 @@
         Map map = Extended3Enum.getEnumMap();
         assertNotNull(map);
         assertEquals(map.keySet().size(), Extended3Enum.getEnumList().size());
-        
+
         assertTrue(map.containsValue(Extended3Enum.ALPHA));
         assertTrue(map.containsValue(Extended3Enum.BETA));
         assertTrue(map.containsValue(Extended3Enum.GAMMA));
@@ -381,10 +387,10 @@
         assertSame(Extended3Enum.DELTA, map.get("Delta"));
     }
 
-    //-----------------------------------------------------------------------
+    // -----------------------------------------------------------------------
     public void testNested() {
         List list = new ArrayList(Nest.ColorEnum.getEnumList());
-        assertEquals(3, list.size());  // all is well
+        assertEquals(3, list.size()); // all is well
         Iterator it = list.iterator();
         assertSame(Nest.ColorEnum.RED, it.next());
         assertSame(Nest.ColorEnum.GREEN, it.next());
@@ -396,7 +402,7 @@
     public void testNestedBroken() {
         List list = new ArrayList(NestBroken.ColorEnum.getEnumList());
         try {
-            assertEquals(0, list.size());  // no enums!!! 
+            assertEquals(0, list.size()); // no enums!!!
             // this is BROKEN because the enum constants are defined in a DIFFERENT
             // class from getEnumList(). Once NestBroken class is referenced,
             // and thus class loaded with its enum constants, the getEnumList works:
@@ -406,7 +412,7 @@
         }
         new NestBroken();
         list = new ArrayList(NestBroken.ColorEnum.getEnumList());
-        assertEquals(3, list.size());  // all is well!!!
+        assertEquals(3, list.size()); // all is well!!!
         Iterator it = list.iterator();
         assertSame(NestBroken.RED, it.next());
         assertSame(NestBroken.GREEN, it.next());
@@ -415,7 +421,7 @@
 
     public void testNestedLinked() {
         List list = new ArrayList(NestLinked.ColorEnum.getEnumList());
-        assertEquals(3, list.size());  // all is well
+        assertEquals(3, list.size()); // all is well
         Iterator it = list.iterator();
         assertSame(NestLinked.RED, it.next());
         assertSame(NestLinked.GREEN, it.next());
@@ -426,7 +432,7 @@
 
     public void testNestedReferenced() {
         List list = new ArrayList(NestReferenced.ColorEnum.getEnumList());
-        assertEquals(3, list.size());  // all is well
+        assertEquals(3, list.size()); // all is well
         Iterator it = list.iterator();
         assertSame(NestReferenced.RED, it.next());
         assertSame(NestReferenced.GREEN, it.next());
@@ -435,7 +441,7 @@
         // the SAME class as the getEnumList(). The references in the outer class
         // are just extra references.
     }
-    
+
     public void testColorEnumEqualsWithDifferentClassLoaders() throws SecurityException,
IllegalArgumentException,
             ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException
{
         this.testEqualsTrueWithDifferentClassLoaders(ColorEnum.BLUE);
@@ -481,7 +487,21 @@
         // set up:
         assertNotNull(classLoader);
         assertFalse(classLoader.equals(ColorEnum.class.getClassLoader()));
-        Class otherColorEnumClass = classLoader.loadClass("org.apache.commons.lang.enum.ColorEnum");
+        Class otherColorEnumClass = null;
+        try {
+            otherColorEnumClass = classLoader.loadClass(ENUM_CLASS_NAME);
+        } catch (ClassNotFoundException e) {
+            // Dump some information to help debug class loader issues under different JREs,
Ant, Eclipse.
+            System.err.println("Could not load " + ENUM_CLASS_NAME + " from the class loader
" + classLoader);
+            URLClassLoader urlCl = (URLClassLoader) classLoader;
+            URL[] urls = urlCl.getURLs();
+            System.err.println("Class loader has " + urls.length + " URLs:");
+            for (int i = 0; i < urls.length; i++) {
+                System.err.println("URL[" + i + "] = " + urls[i]);
+            }
+            e.printStackTrace();
+            throw e;
+        }
         assertNotNull(otherColorEnumClass);
         assertNotNull(otherColorEnumClass.getClassLoader());
         assertTrue(classLoader.equals(otherColorEnumClass.getClassLoader()));

Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/enums/EnumTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/enums/EnumTest.java?rev=179242&r1=179241&r2=179242&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/enums/EnumTest.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/enums/EnumTest.java
Tue May 31 10:48:08 2005
@@ -17,6 +17,8 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -29,6 +31,7 @@
 import junit.framework.TestSuite;
 import org.apache.commons.lang.ClassUtilsTest;
 import org.apache.commons.lang.SerializationUtils;
+import org.apache.commons.lang.enum.ColorEnum;
 
 /**
  * Test cases for the {@link Enum} class.
@@ -40,6 +43,8 @@
 
 public final class EnumTest extends TestCase {
 
+    private static final String ENUMS_CLASS_NAME = "org.apache.commons.lang.enums.ColorEnum";
+
     public EnumTest(String name) {
         super(name);
     }
@@ -481,7 +486,21 @@
         // set up:
         assertNotNull(classLoader);
         assertFalse(classLoader.equals(ColorEnum.class.getClassLoader()));
-        Class otherColorEnumClass = classLoader.loadClass("org.apache.commons.lang.enums.ColorEnum");
+        Class otherColorEnumClass = null;
+        try {
+            otherColorEnumClass = classLoader.loadClass(ENUMS_CLASS_NAME);
+        } catch (ClassNotFoundException e) {
+            // Dump some information to help debug class loader issues under different JREs,
Ant, Eclipse.
+            System.err.println("Could not load " + ENUMS_CLASS_NAME + " from the class loader
" + classLoader);
+            URLClassLoader urlCl = (URLClassLoader) classLoader;
+            URL[] urls = urlCl.getURLs();
+            System.err.println("Class loader has " + urls.length + " URLs:");
+            for (int i = 0; i < urls.length; i++) {
+                System.err.println("URL[" + i + "] = " + urls[i]);
+            }
+            e.printStackTrace();
+            throw e;
+        }
         assertNotNull(otherColorEnumClass);
         assertNotNull(otherColorEnumClass.getClassLoader());
         assertTrue(classLoader.equals(otherColorEnumClass.getClassLoader()));



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


Mime
View raw message