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.


git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@179242 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary D. Gregory 2005-05-31 17:48:08 +00:00
parent 46fe76f81a
commit 43f7a149e0
5 changed files with 237 additions and 241 deletions

350
build.xml
View File

@ -14,215 +14,165 @@ See the License for the specific language governing permissions and
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>

View File

@ -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
@ -52,9 +55,6 @@ source.home = src/java
# 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

View File

@ -399,11 +399,18 @@ public void testPrimitivesToWrappers() {
* @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);
}

View File

@ -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,6 +30,7 @@
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.apache.commons.lang.ClassUtilsTest;
import org.apache.commons.lang.SerializationUtils;
@ -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 @@ public void testCompareTo() {
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() {
@ -104,8 +112,7 @@ public void testList() {
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());
@ -123,8 +130,7 @@ public void testMap() {
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() {
@ -256,7 +262,7 @@ public void testOperationCalculation() {
assertEquals(-1, OperationEnum.MINUS.eval(1, 2));
}
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
public void testExtended1Get() {
assertSame(Extended1Enum.ALPHA, Extended1Enum.getEnum("Alpha"));
assertSame(Extended1Enum.BETA, Extended1Enum.getEnum("Beta"));
@ -381,10 +387,10 @@ public void testExtended3Map() {
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 testNested() {
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 @@ public void testNestedBroken() {
}
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 testNestedBroken() {
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 testNestedLinked() {
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());
@ -481,7 +487,21 @@ Object getColorEnum(ClassLoader classLoader, String color) throws ClassNotFoundE
// 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()));

View File

@ -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 @@ Object getColorEnum(ClassLoader classLoader, String color) throws ClassNotFoundE
// 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()));