View Javadoc

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