Java cvprof Coverage Report for
TestCaseClassLoaderTest.java

    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   /**
    9    * A TestCase for testing the TestCaseClassLoader
   10    *
   11    */
   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   		//
   19   		// Invoke the assertClassLoaders method via reflection.
   20   		// We use reflection since the class is loaded by
   21   		// another class loader and we can't do a successfull downcast to
   22   		// ClassLoaderTestCase.
   23   		//
   24 > 		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   		//
   36   		// Invoke the assertClassLoaders method via reflection.
   37   		// We use reflection since the class is loaded by
   38   		// another class loader and we can't do a successfull downcast to
   39   		// ClassLoaderTestCase.
   40   		//
   41   		Method method= loadedClass.getDeclaredMethod("verify", new Class[0]);
   42   		method.invoke(o, new Class[0]);
   43   	}
   44   }