KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > clazzy > JarClassLoaderTest


1 package org.sapia.clazzy;
2
3 import java.io.File JavaDoc;
4
5 import org.sapia.clazzy.test.Printable;
6
7 import junit.framework.TestCase;
8
9 /**
10  * @author Yanick Duchesne
11  *
12  * <dl>
13  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2004 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
14  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
15  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
16  * </dl>
17  */

18 public class JarClassLoaderTest extends TestCase{
19   
20   public JarClassLoaderTest(String JavaDoc name){
21     super(name);
22   }
23   
24   public void testLoadClass() throws Exception JavaDoc{
25     JarClassLoader loader = new JarClassLoader(new File JavaDoc("etc/test/lib/classes.jar"));
26     Printable p = (Printable)loader.loadClass("test.JarClass").newInstance();
27     super.assertTrue(p.getClass().getPackage() != null);
28     try{
29       loader.loadClass("test.None");
30       fail("ClassNotFoundException should have been thrown");
31     }catch(ClassNotFoundException JavaDoc e){
32       //ok
33
}
34   }
35
36 }
37
Popular Tags