You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Ryan Eccles <re...@oculusinfo.com> on 2006/11/21 16:55:54 UTC
Surefire and ClassLoading with URLS SystemClassLoader
I've noticed a lot of discussion on ClassLoading with respect to
resources, but little on loading classes themselves. Of the following
tests, only the test useObjectClassLoader() works in surefire. In normal
TestNG both tests will pass. I've noticed a test using URLClassloader
(ie plugin system loading jars) also fails with the same problem. Is
there a different URL required for system classloader when running
surefire?, or is there a configuration setting I need to get surefire to
treat the URLs as it does at the command line? Thanks.
@Test
public void useObjectClassLoader() throws ClassNotFoundException {
Class type = getClass().getClassLoader().loadClass(
"com.oculus.test.TestObject");
// works
Assert.assertEquals(type, TestObject.class);
}
@Test
public void useSystemClassLoader() throws ClassNotFoundException {
// thows exeception here
Class type = ClassLoader.getSystemClassLoader().loadClass(
"com.oculus.test.TestObject");
Assert.assertEquals(type, TestObject.class);
}
Oh and "TestObject" is in the same package as the tests. Here is the
exception:
java.lang.ClassNotFoundException: TestObject
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.oculus.test.Runner.useSystemClassLoader(Runner.java:20)
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org