KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > groboutils > util > classes > v1 > ClassUtilOnlineUTest


1 /*
2  * @(#)ClassUtilOnlineUTest.java 0.9.0 17-APR-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;
28
29 import junit.framework.Test;
30 import junit.framework.TestCase;
31 import junit.framework.TestSuite;
32
33
34 /**
35  * Tests only the ClassUtil tests that are online.
36  *
37  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
38  * @version $Date: 2003/02/10 22:52:38 $
39  * @since June 28, 2002
40  */

41 public class ClassUtilOnlineUTest extends TestCase
42 {
43     private static final Class JavaDoc THIS_CLASS = ClassUtilOnlineUTest.class;
44     
45     public ClassUtilOnlineUTest( String JavaDoc name )
46     {
47         super( name );
48     }
49     
50     public static Test suite()
51     {
52         TestSuite suite = new TestSuite( THIS_CLASS );
53         
54         return suite;
55     }
56     
57     public static void main( String JavaDoc[] args )
58     {
59         String JavaDoc[] name = { THIS_CLASS.getName() };
60         
61         // junit.textui.TestRunner.main( name );
62
// junit.swingui.TestRunner.main( name );
63

64         junit.textui.TestRunner.main( name );
65     }
66     
67     protected void setUp() throws Exception JavaDoc
68     {
69         super.setUp();
70         
71         // set ourself up
72
}
73     
74     
75     protected void tearDown() throws Exception JavaDoc
76     {
77         // tear ourself down
78

79         super.tearDown();
80     }
81
82     
83     
84     private static final String JavaDoc BELIEF_CLASS = "BeliefOfTheDay";
85     private static final String JavaDoc BELIEF_JAR =
86         "http://groboutils.sourceforge.net/Belief.jar";
87     
88     public static class InnerClass
89     {
90         public InnerClass()
91         {
92             // do nothing
93
}
94     }
95     
96     public void testGetClass1()
97     {
98         ClassUtil util = startTest();
99         
100         Class JavaDoc c = util.getClass( BELIEF_CLASS, BELIEF_JAR );
101         assertNotNull( "getClass( "+BELIEF_CLASS+" ) returned null.", c );
102         assertEquals( "getClass( "+BELIEF_CLASS+" ) returned the wrong class.",
103             BELIEF_CLASS, c.getName() );
104     }
105     
106     
107     public void testCreateObject1()
108     {
109         ClassUtil util = startTest();
110         
111         Object JavaDoc o = util.createObject( BELIEF_CLASS, BELIEF_JAR );
112         assertEquals(
113             "createObject( "+BELIEF_CLASS+", "+BELIEF_JAR+
114             " ) did not instantiate the remote class.",
115             BELIEF_CLASS, o.getClass().getName() );
116     }
117     
118     
119     //---------------------------------
120

121     
122     // we must assert that the ClassUtil is fresh to avoid incorrect
123
// behavior.
124
protected ClassUtil startTest()
125     {
126         ClassUtil util = ClassUtil.getInstance();
127         util.flush();
128         return util;
129     }
130 }
131
Popular Tags