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

104
build.xml
View File

@ -55,14 +55,7 @@ limitations under the License.
</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}">
<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">
@ -70,13 +63,7 @@ limitations under the License.
</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}">
<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">
@ -92,19 +79,7 @@ limitations under the License.
<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}">
<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>
@ -147,82 +122,57 @@ limitations under the License.
</copy>
</target>
<!-- ========== Unit Test Targets ========================================= -->
<!-- removed test.text target from the depends list for the 2.1 release. It
<!-- 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="
compile.tests,
test.lang,
test.builder,
test.enum,
test.enums,
test.exception,
test.math,
test.mutable,
test.time"
description="Run all unit test cases">
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"/>
<macrodef name="runTestCase">
<attribute name="classname"/>
<sequential>
<junit printsummary="true" showoutput="true" fork="${junit.fork}" haltonerror="${test.failonerror}">
<classpath refid="test.classpath"/>
</java>
<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">
<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>
<runTestCase classname="org.apache.commons.lang.builder.BuilderTestSuite"/>
</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>
<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">
<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>
<runTestCase classname="org.apache.commons.lang.exception.ExceptionTestSuite"/>
</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>
<runTestCase classname="org.apache.commons.lang.math.MathTestSuite"/>
</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>
<runTestCase classname="org.apache.commons.lang.mutable.MutableTestSuite"/>
</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>
<runTestCase classname="org.apache.commons.lang.text.TextTestSuite"/>
</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>
<runTestCase classname="org.apache.commons.lang.time.TimeTestSuite"/>
</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>
<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,7 +387,7 @@ 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
@ -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()));