KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > groboutils > codecoverage > v2 > report > PackageSorterUTest


1 /*
2  * @(#)PackageSorterUTest.java
3  *
4  * Copyright (C) 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.report;
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 PackageSorter 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:29 $
40  * @since January 22, 2003
41  */

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

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

59     public void testConstructor1()
60     {
61         new PackageSorter();
62     }
63     
64     
65     public void testAddClassSignatures1()
66     {
67         PackageSorter ps = new PackageSorter();
68         try
69         {
70             ps.addClassSignatures( null );
71             fail( "Didn't throw IllegalArgumentException." );
72         }
73         catch (IllegalArgumentException JavaDoc ex)
74         {
75         }
76     }
77     
78     
79     public void testAddClassSignatures2()
80     {
81         PackageSorter ps = new PackageSorter();
82         try
83         {
84             ps.addClassSignatures( new String JavaDoc[2] );
85             fail( "Didn't throw IllegalArgumentException." );
86         }
87         catch (IllegalArgumentException JavaDoc ex)
88         {
89         }
90     }
91     
92     
93     public void testAddClassSignature1()
94     {
95         PackageSorter ps = new PackageSorter();
96         try
97         {
98             ps.addClassSignature( null );
99             fail( "Didn't throw IllegalArgumentException." );
100         }
101         catch (IllegalArgumentException JavaDoc ex)
102         {
103         }
104     }
105     
106     
107     public void testAddClassSignature2()
108     {
109         PackageSorter ps = new PackageSorter();
110         ps.addClassSignature( "a.b" );
111     }
112     
113     
114     public void testAddClassSignature3()
115     {
116         PackageSorter ps = new PackageSorter();
117         ps.addClassSignature( "a" );
118     }
119     
120     
121     public void testAddClassSignature4()
122     {
123         PackageSorter ps = new PackageSorter();
124         ps.addClassSignature( "" );
125     }
126     
127     
128     public void testAddClassSignature5()
129     {
130         PackageSorter ps = new PackageSorter();
131         ps.addClassSignature( "." );
132     }
133     
134     
135     public void testGetPackages1()
136     {
137         PackageSorter ps = new PackageSorter();
138         String JavaDoc s[] = ps.getPackages();
139         assertNotNull(
140             "Got null package list.",
141             s );
142         assertEquals(
143             "Created packages out of nothing.",
144             0,
145             s.length );
146     }
147     
148     
149     public void testClassSignaturesForPackage1()
150     {
151         PackageSorter ps = new PackageSorter();
152         String JavaDoc s[] = ps.getClassSignaturesForPackage( null );
153         assertNotNull(
154             "Got null package list.",
155             s );
156         assertEquals(
157             "Created packages out of nothing.",
158             0,
159             s.length );
160     }
161     
162     
163     public void testClassSignaturesForPackage2()
164     {
165         PackageSorter ps = new PackageSorter();
166         String JavaDoc s[] = ps.getClassSignaturesForPackage( "" );
167         assertNotNull(
168             "Got null package list.",
169             s );
170         assertEquals(
171             "Created packages out of nothing.",
172             0,
173             s.length );
174     }
175     
176     
177     public void testGetPackageName1()
178     {
179         assertEquals(
180             "a",
181             PackageSorter.getPackageName( "a.b" ) );
182     }
183     
184     
185     public void testGetPackageName2()
186     {
187         assertEquals(
188             "",
189             PackageSorter.getPackageName( ".b" ) );
190     }
191     
192     
193     public void testGetPackageName3()
194     {
195         assertEquals(
196             "",
197             PackageSorter.getPackageName( "b" ) );
198     }
199     
200     
201     public void testGetPackageName4()
202     {
203         assertEquals(
204             "",
205             PackageSorter.getPackageName( "." ) );
206     }
207     
208     
209     public void testGetPackageName5()
210     {
211         assertEquals(
212             "a.b.c.d",
213             PackageSorter.getPackageName( "a.b.c.d.e" ) );
214     }
215     
216     
217     public void testGetPackageName6()
218     {
219         assertEquals(
220             "a.b.c.d.e",
221             PackageSorter.getPackageName( "a.b.c.d.e." ) );
222     }
223     
224     
225     //-------------------------------------------------------------------------
226
// Helpers
227

228     
229     
230     //-------------------------------------------------------------------------
231
// Standard JUnit declarations
232

233     
234     public static Test suite()
235     {
236         TestSuite suite = new TestSuite( THIS_CLASS );
237         
238         return suite;
239     }
240     
241     public static void main( String JavaDoc[] args )
242     {
243         String JavaDoc[] name = { THIS_CLASS.getName() };
244         
245         // junit.textui.TestRunner.main( name );
246
// junit.swingui.TestRunner.main( name );
247

248         junit.textui.TestRunner.main( name );
249     }
250     
251     
252     /**
253      *
254      * @exception Exception thrown under any exceptional condition.
255      */

256     protected void setUp() throws Exception JavaDoc
257     {
258         super.setUp();
259
260        
261         // set ourself up
262
}
263     
264     
265     /**
266      *
267      * @exception Exception thrown under any exceptional condition.
268      */

269     protected void tearDown() throws Exception JavaDoc
270     {
271         // tear ourself down
272

273         
274         super.tearDown();
275     }
276 }
277
278
Popular Tags