1 package junit.tests.runner; 2 3 import java.lang.reflect.*; 4 import junit.framework.*; 5 import junit.runner.*; 6 import java.net.URL ; 7 8 12 public class TestCaseClassLoaderTest extends TestCase { 13 14 public void testClassLoading() throws Exception { 15 TestCaseClassLoader loader= new TestCaseClassLoader(); 16 Class loadedClass= loader.loadClass("junit.tests.runner.ClassLoaderTest", true); 17 Object o= loadedClass.newInstance(); 18 Method method= loadedClass.getDeclaredMethod("verify", new Class [0]); 25 method.invoke(o, new Class [0]); 26 } 27 28 public void testJarClassLoading() throws Exception { 29 URL url= getClass().getResource("test.jar"); 30 assertNotNull("Cannot find test.jar", url); 31 String path= url.getFile(); 32 TestCaseClassLoader loader= new TestCaseClassLoader(path); 33 Class loadedClass= loader.loadClass("junit.tests.runner.LoadedFromJar", true); 34 Object o= loadedClass.newInstance(); 35 Method method= loadedClass.getDeclaredMethod("verify", new Class [0]); 42 method.invoke(o, new Class [0]); 43 } 44 } | Popular Tags |