⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testcaseclassloadertest.java

📁 最新版Junit
💻 JAVA
字号:
package junit.tests.runner;import java.lang.reflect.*;import junit.framework.*;import junit.runner.*;import java.net.URL;/** * A TestCase for testing the TestCaseClassLoader * */public class TestCaseClassLoaderTest extends TestCase {	public void testClassLoading() throws Exception {		TestCaseClassLoader loader= new TestCaseClassLoader();		Class loadedClass= loader.loadClass("junit.tests.runner.ClassLoaderTest", true);		Object o= loadedClass.newInstance();		//		// Invoke the assertClassLoaders method via reflection.		// We use reflection since the class is loaded by		// another class loader and we can't do a successfull downcast to		// ClassLoaderTestCase.		//		Method method= loadedClass.getDeclaredMethod("verify", new Class[0]);		method.invoke(o, new Class[0]);	}	public void testJarClassLoading() throws Exception {		URL url= getClass().getResource("test.jar");		assertNotNull("Cannot find test.jar", url);		String path= url.getFile();		TestCaseClassLoader loader= new TestCaseClassLoader(path);		Class loadedClass= loader.loadClass("junit.tests.runner.LoadedFromJar", true);		Object o= loadedClass.newInstance();		//		// Invoke the assertClassLoaders method via reflection.		// We use reflection since the class is loaded by		// another class loader and we can't do a successfull downcast to		// ClassLoaderTestCase.		//		Method method= loadedClass.getDeclaredMethod("verify", new Class[0]);		method.invoke(o, new Class[0]);	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -