1 package junit.tests; 2 3 6 import junit.framework.*; 7 import junit.runner.*; 8 9 public class ClassLoaderTest extends Assert { 10 public ClassLoaderTest() { 11 } 12 public void verify() { 13 verifyApplicationClassLoadedByTestLoader(); 14 verifySystemClassNotLoadedByTestLoader(); 15 } 16 private boolean isTestCaseClassLoader(ClassLoader cl) { 17 return (cl != null && cl.getClass().getName().equals(junit.runner.TestCaseClassLoader.class.getName())); 18 } 19 private void verifyApplicationClassLoadedByTestLoader() { 20 assertTrue(isTestCaseClassLoader(getClass().getClassLoader())); 21 } 22 private void verifySystemClassNotLoadedByTestLoader() { 23 assertTrue(!isTestCaseClassLoader(Object .class.getClassLoader())); 24 assertTrue(!isTestCaseClassLoader(TestCase.class.getClassLoader())); 25 } 26 } | Popular Tags |