KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > groboutils > codecoverage > v2 > compiler > ParseCoverageLoggerUTest


1 /*
2  * @(#)ParseCoverageLoggerUTest.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.compiler;
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 ParseCoverageLogger 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:28 $
40  * @since January 13, 2003
41  */

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

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

59     
60     public void testConstructor1()
61     {
62         new ParseCoverageLogger();
63     }
64     
65     
66     public void testConstructor2()
67     {
68         try
69         {
70             new ParseCoverageLogger( null, null );
71             fail( "Did not throw IllegalArgumentException." );
72         }
73         catch (IllegalArgumentException JavaDoc iae)
74         {
75             // test exception
76
}
77     }
78     
79     
80     public void testConstructor3()
81     {
82         try
83         {
84             new ParseCoverageLogger( THIS_CLASS, null );
85             fail( "Did not throw IllegalArgumentException." );
86         }
87         catch (IllegalArgumentException JavaDoc iae)
88         {
89             // test exception
90
}
91     }
92     
93     
94     public void testConstructor4()
95     {
96         try
97         {
98             new ParseCoverageLogger( null, "" );
99             fail( "Did not throw IllegalArgumentException." );
100         }
101         catch (IllegalArgumentException JavaDoc iae)
102         {
103             // test exception
104
}
105     }
106     
107     
108     public void testConstructor5()
109     {
110         try
111         {
112             new ParseCoverageLogger( MyLogger.class, "not-exist" );
113             fail( "Did not throw IllegalStateException." );
114         }
115         catch (IllegalStateException JavaDoc iae)
116         {
117             // test exception
118
}
119     }
120     
121     
122     public void testConstructor6()
123     {
124         try
125         {
126             new ParseCoverageLogger( MyLogger.class, "bad1" );
127             fail( "Did not throw IllegalStateException." );
128         }
129         catch (IllegalStateException JavaDoc iae)
130         {
131             // test exception
132
}
133     }
134     
135     
136     public void testConstructor7()
137     {
138         try
139         {
140             new ParseCoverageLogger( MyLogger.class, "bad2" );
141             fail( "Did not throw IllegalStateException." );
142         }
143         catch (IllegalStateException JavaDoc iae)
144         {
145             // test exception
146
}
147     }
148     
149     
150     public void testConstructor8()
151     {
152         try
153         {
154             new ParseCoverageLogger( MyLogger.class, "bad3" );
155             fail( "Did not throw IllegalStateException." );
156         }
157         catch (IllegalStateException JavaDoc iae)
158         {
159             // test exception
160
}
161     }
162     
163     
164     public void testConstructor9()
165     {
166         try
167         {
168             new ParseCoverageLogger( MyLogger.class, "bad4" );
169             fail( "Did not throw IllegalStateException." );
170         }
171         catch (IllegalStateException JavaDoc iae)
172         {
173             // test exception
174
}
175     }
176     
177     
178     public void testConstructor10()
179     {
180         try
181         {
182             new ParseCoverageLogger( MyLogger.class, "bad5" );
183             fail( "Did not throw IllegalStateException." );
184         }
185         catch (IllegalStateException JavaDoc iae)
186         {
187             // test exception
188
}
189     }
190     
191     
192     public void testConstructor11()
193     {
194         try
195         {
196             new ParseCoverageLogger( MyLogger.class, "bad6" );
197             fail( "Did not throw IllegalStateException." );
198         }
199         catch (IllegalStateException JavaDoc iae)
200         {
201             // test exception
202
}
203     }
204     
205     
206     public void testConstructor12()
207     {
208         new ParseCoverageLogger( MyLogger.class, "good" );
209     }
210     
211     
212     public void testGetClassName1()
213     {
214         ParseCoverageLogger pcl = new ParseCoverageLogger(
215             MyLogger.class, "good" );
216         assertEquals(
217             "Incorrect class name.",
218             MyLogger.class.getName(),
219             pcl.getClassName() );
220     }
221     
222     
223     public void testGetMethodName1()
224     {
225         ParseCoverageLogger pcl = new ParseCoverageLogger(
226             MyLogger.class, "good" );
227         assertEquals(
228             "Incorrect method name.",
229             "good",
230             pcl.getMethodName() );
231     }
232     
233     
234     public void testGetMethodSignature1()
235     {
236         ParseCoverageLogger pcl = new ParseCoverageLogger(
237             MyLogger.class, "good" );
238         assertEquals(
239             "Incorrect method signature.",
240             "(Ljava/lang/String;SSS)V",
241             pcl.getMethodSignature() );
242     }
243     
244     
245     
246     //-------------------------------------------------------------------------
247
// Helpers
248

249     public static class MyLogger
250     {
251         public static void good( String JavaDoc s, short a, short b, short c )
252         {
253         }
254         public static String JavaDoc bad1( String JavaDoc s, short a, short b, short c )
255         {
256             return "";
257         }
258         public void bad2( String JavaDoc s, short a, short b, short c )
259         {
260         }
261         protected static void bad3( String JavaDoc s, short a, short b, short c )
262         {
263         }
264         static void bad4( String JavaDoc s, short a, short b, short c )
265         {
266         }
267         protected void bad5( String JavaDoc s, short a, short b, short c )
268         {
269         }
270         void bad6( String JavaDoc s, short a, short b, short c )
271         {
272         }
273     }
274     
275     
276     //-------------------------------------------------------------------------
277
// Standard JUnit declarations
278

279     
280     public static Test suite()
281     {
282         TestSuite suite = new TestSuite( THIS_CLASS );
283         
284         return suite;
285     }
286     
287     public static void main( String JavaDoc[] args )
288     {
289         String JavaDoc[] name = { THIS_CLASS.getName() };
290         
291         // junit.textui.TestRunner.main( name );
292
// junit.swingui.TestRunner.main( name );
293

294         junit.textui.TestRunner.main( name );
295     }
296     
297     
298     /**
299      *
300      * @exception Exception thrown under any exceptional condition.
301      */

302     protected void setUp() throws Exception JavaDoc
303     {
304         super.setUp();
305         
306         // set ourself up
307
}
308     
309     
310     /**
311      *
312      * @exception Exception thrown under any exceptional condition.
313      */

314     protected void tearDown() throws Exception JavaDoc
315     {
316         // tear ourself down
317

318         
319         super.tearDown();
320     }
321 }
322
323
Popular Tags