KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openejb > loader > SystemClassPathTest


1 package org.openejb.loader;
2 /**
3  * @version $Revision$ $Date$
4  */

5
6 import junit.framework.*;
7 import org.openejb.loader.SystemClassPath;
8
9 import java.net.URL JavaDoc;
10
11 public class SystemClassPathTest extends TestCase {
12     SystemClassPath systemClassPath;
13
14     public void testAddJarToPath() throws Exception JavaDoc {
15         SystemClassPath systemClassPath = new SystemClassPath();
16
17         ClassLoader JavaDoc systemClassLoader = ClassLoader.getSystemClassLoader();
18
19         try {
20             systemClassLoader.loadClass("org.apache.commons.io.HexDump");
21             fail("Class already exists");
22         } catch (ClassNotFoundException JavaDoc e) {
23             // this should fail
24
}
25
26         URL JavaDoc commonsIoJar = new URL JavaDoc("http://www.ibiblio.org/maven/commons-io/jars/commons-io-1.0.jar");
27         systemClassPath.addJarToPath(commonsIoJar);
28
29         try {
30             systemClassLoader.loadClass("org.apache.commons.io.HexDump");
31         } catch (ClassNotFoundException JavaDoc e) {
32             // this should fail pass
33
fail("Class should exist");
34         }
35     }
36 }
Popular Tags