1 26 27 package net.sourceforge.groboutils.util.classes.v1.jdk2; 28 29 import net.sourceforge.groboutils.util.classes.v1.*; 30 import net.sourceforge.groboutils.junit.v1.iftc.*; 31 import junit.framework.Test; 32 import junit.framework.TestCase; 33 import junit.framework.TestSuite; 34 35 import java.net.URL ; 36 37 38 49 public class UrlClassLoaderJDK12UTest extends TestCase 50 { 51 private static final Class THIS_CLASS = UrlClassLoaderJDK12UTest.class; 52 53 public UrlClassLoaderJDK12UTest( String name ) 54 { 55 super( name ); 56 } 57 58 public static Test suite() 59 { 60 InterfaceTestSuite suite = IUrlClassLoaderUTestI.suite(); 61 suite.addTestSuite( THIS_CLASS ); 62 suite.addFactory( new CxFactory( "A" ) { 63 public Object createImplObject() { 64 return createLoader(); 65 } 66 } ); 67 68 return suite; 69 } 70 71 public static void main( String [] args ) 72 { 73 String [] name = { THIS_CLASS.getName() }; 74 75 78 junit.textui.TestRunner.main( name ); 79 } 80 81 protected void setUp() throws Exception 82 { 83 super.setUp(); 84 85 } 87 88 89 protected void tearDown() throws Exception 90 { 91 93 super.tearDown(); 94 } 95 96 97 protected static UrlClassLoader createLoader() 98 { 99 return new UrlClassLoader(); 100 } 101 102 103 106 public void testConvertUrl1() 107 { 108 assertNull( 109 "returned URL must be null.", 110 createLoader().convertUrl( null ) ); 111 } 112 113 114 public void testConvertUrl2() 115 { 116 URL url = createLoader().convertUrl( "http://yo.mama" ); 117 assertNotNull( 118 "convertURL returned null.", 119 url ); 120 if (!url.toString().equals( "http://yo.mama" ) 122 && !url.toString().equals( "http://yo.mama/" )) 123 { 124 fail("convertURL did not format right: it returned '"+ 125 url.toString()+"'"); 126 } 127 } 128 129 130 public void testConvertUrl3() 131 { 132 URL url = createLoader().convertUrl( "afile.txt" ); 133 assertNotNull( 134 "convertURL returned null.", 135 url ); 136 assertEquals( 137 "convertURL did not format right.", 138 url.toString(), 139 "file:afile.txt" ); 140 } 141 } 142 | Popular Tags |