Applying my fix from LANG-314
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@501606 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
71f6a5a117
commit
3e718fdb1b
|
@ -501,30 +501,6 @@ public class ClassUtilsTest extends TestCase {
|
|||
assertGetClassThrowsException( className, ClassNotFoundException.class );
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of URLClassLoader with the system class loader's URLs and a <code>null</code> parent
|
||||
* class loader.
|
||||
*
|
||||
* @see ClassLoader#getSystemClassLoader()
|
||||
* @see URLClassLoader#newInstance(URL[], ClassLoader)
|
||||
* @return the resulting class loader
|
||||
*/
|
||||
public static ClassLoader newSystemClassLoader() throws SecurityException, IllegalArgumentException {
|
||||
ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
|
||||
ClassLoader myClassLoader = ClassUtilsTest.class.getClassLoader();
|
||||
if (!(myClassLoader instanceof URLClassLoader)) {
|
||||
fail("ClassUtilsTest ClassLoader = " + (myClassLoader == null ? null : myClassLoader.getClass().getName()));
|
||||
}
|
||||
if (!(systemClassLoader instanceof URLClassLoader)) {
|
||||
fail("System ClassLoader = " + (systemClassLoader == null ? null : systemClassLoader.getClass().getName()));
|
||||
}
|
||||
if (!myClassLoader.equals(systemClassLoader)) {
|
||||
fail("ClassUtilsTest= " + myClassLoader + " System=" + systemClassLoader);
|
||||
}
|
||||
URLClassLoader urlScl = (URLClassLoader) myClassLoader;
|
||||
return URLClassLoader.newInstance(urlScl.getURLs(), null);
|
||||
}
|
||||
|
||||
// Show the Java bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4071957
|
||||
// We may have to delete this if a JDK fixes the bug.
|
||||
public void testShowJavaBug() throws Exception {
|
||||
|
|
|
@ -32,7 +32,6 @@ import junit.framework.Test;
|
|||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.apache.commons.lang.ClassUtilsTest;
|
||||
import org.apache.commons.lang.SerializationUtils;
|
||||
|
||||
/**
|
||||
|
@ -456,7 +455,11 @@ public final class EnumTest extends TestCase {
|
|||
assertTrue(colorEnum.equals(colorEnum));
|
||||
assertNotNull(ColorEnum.class.getClassLoader());
|
||||
// set up:
|
||||
ClassLoader classLoader = ClassUtilsTest.newSystemClassLoader();
|
||||
ClassLoader myClassLoader = EnumTest.class.getClassLoader();
|
||||
if (!(myClassLoader instanceof URLClassLoader)) {
|
||||
fail("EnumTest ClassLoader = " + (myClassLoader == null ? null : myClassLoader.getClass().getName()));
|
||||
}
|
||||
ClassLoader classLoader = URLClassLoader.newInstance( ((URLClassLoader)myClassLoader).getURLs(), null);
|
||||
Object enumObjectFromOtherClassLoader = this.getColorEnum(classLoader, colorEnum.getName());
|
||||
|
||||
// the real test, part 1.
|
||||
|
|
|
@ -30,7 +30,6 @@ import junit.framework.AssertionFailedError;
|
|||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
import org.apache.commons.lang.ClassUtilsTest;
|
||||
import org.apache.commons.lang.SerializationUtils;
|
||||
|
||||
/**
|
||||
|
@ -454,7 +453,11 @@ public final class EnumTest extends TestCase {
|
|||
assertTrue(colorEnum.equals(colorEnum));
|
||||
assertNotNull(ColorEnum.class.getClassLoader());
|
||||
// set up:
|
||||
ClassLoader classLoader = ClassUtilsTest.newSystemClassLoader();
|
||||
ClassLoader myClassLoader = EnumTest.class.getClassLoader();
|
||||
if (!(myClassLoader instanceof URLClassLoader)) {
|
||||
fail("EnumTest ClassLoader = " + (myClassLoader == null ? null : myClassLoader.getClass().getName()));
|
||||
}
|
||||
ClassLoader classLoader = URLClassLoader.newInstance( ((URLClassLoader)myClassLoader).getURLs(), null);
|
||||
Object enumObjectFromOtherClassLoader = this.getColorEnum(classLoader, colorEnum.getName());
|
||||
|
||||
// the real test, part 1.
|
||||
|
|
Loading…
Reference in New Issue