KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > junit > tests > ClassLoaderTest


1 package junit.tests;
2
3 /**
4  * Test class used in TestTestCaseClassLoader
5  */

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 JavaDoc 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 JavaDoc.class.getClassLoader()));
24         assertTrue(!isTestCaseClassLoader(TestCase.class.getClassLoader()));
25     }
26 }
Popular Tags