1 26 27 package net.sourceforge.groboutils.util.classes.v1; 28 29 import net.sourceforge.groboutils.junit.v1.iftc.*; 30 import junit.framework.Test; 31 import junit.framework.TestCase; 32 import junit.framework.TestSuite; 33 34 35 48 public class IUrlClassLoaderOnlineUTestI extends InterfaceTestCase 49 { 50 private static final Class THIS_CLASS = IUrlClassLoaderOnlineUTestI.class; 51 52 public IUrlClassLoaderOnlineUTestI( String name, ImplFactory f ) 53 { 54 super( name, IUrlClassLoader.class, f ); 55 } 56 57 58 public IUrlClassLoader createLoader() 59 { 60 return (IUrlClassLoader)createImplObject(); 61 } 62 63 64 public static InterfaceTestSuite suite() 65 { 66 InterfaceTestSuite suite = new InterfaceTestSuite( THIS_CLASS ); 67 68 return suite; 69 } 70 71 73 protected void setUp() throws Exception 74 { 75 super.setUp(); 76 77 } 79 80 81 protected void tearDown() throws Exception 82 { 83 85 super.tearDown(); 86 } 87 88 89 public void testInstantiate() 90 { 91 assertNotNull( "Creation should not return null.", 92 createLoader() ); 93 } 94 95 96 public static final String BELIEF_CLASS = "BeliefOfTheDay"; 97 public static final String BELIEF_JAR = 98 "http://groboutils.sourceforge.net/Belief.jar"; 99 100 public static class InnerClass 101 { 102 public InnerClass() 103 { 104 } 106 } 107 108 109 public void testGetClass1() 110 { 111 IUrlClassLoader loader = createLoader(); 112 113 Class c = loader.loadClass( this.getClass().getName(), null ); 114 assertNotNull( "loadClass( "+this.getClass().getName()+ 115 " ) returned null.", 116 c ); 117 assertEquals( "Did not load the class from the default classloader.", 118 this.THIS_CLASS, c ); 119 120 c = loader.loadClass( BELIEF_CLASS, null ); 121 assertEquals( 122 "getClass( Belief ) was found in the default classloader.", 123 null, c ); 124 } 125 126 127 public void testGetClass2() 128 { 129 IUrlClassLoader loader = createLoader(); 130 131 Class c = loader.loadClass( BELIEF_CLASS, BELIEF_JAR ); 132 assertNotNull( "getClass( "+BELIEF_CLASS+" ) returned null.", c ); 133 assertEquals( "getClass( "+BELIEF_CLASS+" ) returned the wrong class.", 134 BELIEF_CLASS, c.getName() ); 135 } 136 137 138 public void testFlush() 139 { 140 IUrlClassLoader loader = createLoader(); 141 142 Class c = loader.loadClass( this.getClass().getName(), null ); 143 loader.flush(); 144 145 } 148 149 } 150 | Popular Tags |