KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > groboutils > codecoverage > v2 > util > ClassSignatureUtilUTest


1 /*
2  * @(#)ClassSignatureUtilUTest.java
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.codecoverage.v2.util;
28
29 import junit.framework.Test;
30 import junit.framework.TestCase;
31 import junit.framework.TestSuite;
32 import net.sourceforge.groboutils.autodoc.v1.AutoDoc;
33
34
35 /**
36  * Tests the ClassSignatureUtil class.
37  *
38  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
39  * @version $Date: 2004/04/15 05:48:44 $
40  * @since Feb 4, 2002
41  */

42 public class ClassSignatureUtilUTest extends TestCase
43 {
44     //-------------------------------------------------------------------------
45
// Standard JUnit Class-specific declarations
46

47     private static final Class JavaDoc THIS_CLASS = ClassSignatureUtilUTest.class;
48     private static final AutoDoc DOC = new AutoDoc( THIS_CLASS );
49     
50     public ClassSignatureUtilUTest( String JavaDoc name )
51     {
52         super( name );
53     }
54
55
56
57     //-------------------------------------------------------------------------
58
// Tests
59

60     
61     public void testGetInstance1()
62     {
63         assertNotNull(
64             "Returned a null instance.",
65             ClassSignatureUtil.getInstance() );
66     }
67     
68     
69     public void testCreateClassSignature1()
70     {
71         try
72         {
73             ClassSignatureUtil.getInstance().createClassSignature( null, -1 );
74             fail( "Did not throw IllegalArgumentException." );
75         }
76         catch (IllegalArgumentException JavaDoc e)
77         {
78             // test exception
79
}
80     }
81     
82     
83     public void testCreateClassSignature2()
84     {
85         String JavaDoc sig = ClassSignatureUtil.getInstance().
86             createClassSignature( "a.b.C", 1L );
87         assertEquals(
88             "Did not create correct signature.",
89             "a.b.C-1",
90             sig );
91     }
92     
93     
94     public void testCreateClassSignature3()
95     {
96         String JavaDoc sig = ClassSignatureUtil.getInstance().
97             createClassSignature( "", 100L );
98         assertEquals(
99             "Did not create correct signature.",
100             "-100",
101             sig );
102     }
103     
104     
105     public void testGetClassName1()
106     {
107         try
108         {
109             ClassSignatureUtil.getInstance().getClassName( null );
110             fail( "Did not throw IllegalArgumentException." );
111         }
112         catch (IllegalArgumentException JavaDoc e)
113         {
114             // test exception
115
}
116     }
117     
118     
119     public void testGetClassName2()
120     {
121         String JavaDoc name = ClassSignatureUtil.getInstance().
122             getClassName( "" );
123         assertEquals(
124             "Did not return correct class name.",
125             "",
126             name );
127     }
128     
129     
130     public void testGetClassName3()
131     {
132         String JavaDoc name = ClassSignatureUtil.getInstance().
133             getClassName( "a.b.C" );
134         assertEquals(
135             "Did not return correct class name.",
136             "a.b.C",
137             name );
138     }
139     
140     
141     public void testGetClassName4()
142     {
143         String JavaDoc name = ClassSignatureUtil.getInstance().
144             getClassName( "a.b.C--100" );
145         assertEquals(
146             "Did not return correct class name.",
147             "a.b.C",
148             name );
149     }
150     
151     
152     public void testGetClassName5()
153     {
154         String JavaDoc name = ClassSignatureUtil.getInstance().
155             getClassName( "a.b.C D-100" );
156         assertEquals(
157             "Did not return correct class name.",
158             "a.b.C D",
159             name );
160     }
161     
162     
163     
164     //-------------------------------------------------------------------------
165
// Standard JUnit declarations
166

167     
168     public static Test suite()
169     {
170         TestSuite suite = new TestSuite( THIS_CLASS );
171         
172         return suite;
173     }
174     
175     public static void main( String JavaDoc[] args )
176     {
177         String JavaDoc[] name = { THIS_CLASS.getName() };
178         
179         // junit.textui.TestRunner.main( name );
180
// junit.swingui.TestRunner.main( name );
181

182         junit.textui.TestRunner.main( name );
183     }
184     
185     
186     /**
187      *
188      * @exception Exception thrown under any exceptional condition.
189      */

190     protected void setUp() throws Exception JavaDoc
191     {
192         super.setUp();
193         
194         // set ourself up
195
}
196     
197     
198     /**
199      *
200      * @exception Exception thrown under any exceptional condition.
201      */

202     protected void tearDown() throws Exception JavaDoc
203     {
204         // tear ourself down
205

206         
207         super.tearDown();
208     }
209 }
210
211
Popular Tags