KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > groboutils > util > classes > v1 > jdk2 > UrlClassLoaderOnlineJDK12UTest


1 /*
2  * @(#)UrlClassLoaderOnlineJDK12UTest.java 0.9.0 23-May-2001 - 14:40
3  *
4  * Copyright (C) 2002-2003 Matt Albrecht
5  * groboclown@users.sourceforge.net
6  * http://groboutils.sourceforge.net
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation
11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12  * and/or sell copies of the Software, and to permit persons to whom the
13  * Software is furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24  * DEALINGS IN THE SOFTWARE.
25  */

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 JavaDoc;
36
37
38 /**
39  * Just like util.http.tests, this uses the Sourceforge account to ensure
40  * that the URLs work correctly. It loads the sample applet "BeliefOfTheDay"
41  * to make sure that this is able to load classes remotely.
42  * As insurance, this also tests to make sure that the same applet is not
43  * in the current classpath.
44  *
45  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
46  * @version $Date: 2003/05/06 05:35:01 $
47  * @since June 28, 2002
48  */

49 public class UrlClassLoaderOnlineJDK12UTest extends TestCase
50 {
51     private static final Class JavaDoc THIS_CLASS = UrlClassLoaderOnlineJDK12UTest.class;
52     
53     public UrlClassLoaderOnlineJDK12UTest( String JavaDoc name )
54     {
55         super( name );
56     }
57     
58     public static Test suite()
59     {
60         InterfaceTestSuite suite = IUrlClassLoaderOnlineUTestI.suite();
61         suite.addTestSuite( THIS_CLASS );
62         suite.addFactory( new CxFactory( "A" ) {
63             public Object JavaDoc createImplObject() {
64                 return createLoader();
65             }
66         } );
67         
68         return suite;
69     }
70     
71     public static void main( String JavaDoc[] args )
72     {
73         String JavaDoc[] name = { THIS_CLASS.getName() };
74         
75         // junit.textui.TestRunner.main( name );
76
// junit.swingui.TestRunner.main( name );
77

78         junit.textui.TestRunner.main( name );
79     }
80     
81     protected void setUp() throws Exception JavaDoc
82     {
83         super.setUp();
84         
85         // set ourself up
86
}
87     
88     
89     protected void tearDown() throws Exception JavaDoc
90     {
91         // tear ourself down
92

93         super.tearDown();
94     }
95
96     
97     protected static UrlClassLoader createLoader()
98     {
99         return new UrlClassLoader();
100     }
101     
102     
103     //---------------------------------------
104
// Super class has many base tests
105

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 JavaDoc url = createLoader().convertUrl( "http://yo.mama" );
117         assertNotNull(
118             "convertURL returned null.",
119             url );
120         assertTrue(
121             "convertURL did not format right (received "+url+").",
122             url.toString().equals( "http://yo.mama" )
123             || url.toString().equals( "http://yo.mama/" ) );
124     }
125     
126     
127     public void testConvertUrl3()
128     {
129         URL JavaDoc url = createLoader().convertUrl( "afile.txt" );
130         assertNotNull(
131             "convertURL returned null.",
132             url );
133         assertEquals(
134             "convertURL did not format right.",
135             url.toString(),
136             "file:afile.txt" );
137     }
138 }
139
Popular Tags