1 package junit.tests; 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 TestCaseClassLoaderTest(String name) { 15 super(name); 16 } 17 public void testClassLoading() throws Exception { 18 TestCaseClassLoader loader= new TestCaseClassLoader(); 19 Class loadedClass= loader.loadClass("junit.tests.ClassLoaderTest", true); 20 Object o= loadedClass.newInstance(); 21 Method method= loadedClass.getDeclaredMethod("verify", new Class [0]); 28 method.invoke(o, new Class [0]); 29 } 30 31 public void testJarClassLoading() throws Exception { 32 URL url= getClass().getResource("test.jar"); 33 String path= url.getFile(); 34 TestCaseClassLoader loader= new TestCaseClassLoader(path); 35 Class loadedClass= loader.loadClass("junit.tests.LoadedFromJar", true); 36 Object o= loadedClass.newInstance(); 37 Method method= loadedClass.getDeclaredMethod("verify", new Class [0]); 44 method.invoke(o, new Class [0]); 45 } 46 } | Popular Tags |