KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > groboutils > codecoverage > v2 > ant > AnalysisModuleTypeUTest


1 /*
2  * @(#)AnalysisModuleTypeUTest.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.ant;
28
29
30 import junit.framework.Test;
31 import junit.framework.TestSuite;
32 import net.sourceforge.groboutils.autodoc.v1.AutoDoc;
33 import net.sourceforge.groboutils.codecoverage.v2.IAnalysisModule;
34 import net.sourceforge.groboutils.codecoverage.v2.IAnalysisModuleUTestI;
35 import net.sourceforge.groboutils.codecoverage.v2.module.LineCountMeasure;
36 import net.sourceforge.groboutils.junit.v1.SubTestTestCase;
37 import net.sourceforge.groboutils.junit.v1.iftc.CxFactory;
38 import net.sourceforge.groboutils.junit.v1.iftc.InterfaceTestSuite;
39
40 import org.apache.tools.ant.BuildException;
41
42
43 /**
44  * Tests the AnalysisModuleType class.
45  *
46  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
47  * @version $Date: 2004/04/15 05:48:27 $
48  * @since December 28, 2002
49  */

50 public class AnalysisModuleTypeUTest extends SubTestTestCase
51 {
52     //-------------------------------------------------------------------------
53
// Standard JUnit Class-specific declarations
54

55     private static final Class JavaDoc THIS_CLASS = AnalysisModuleTypeUTest.class;
56     private static final AutoDoc DOC = new AutoDoc( THIS_CLASS );
57     
58     public AnalysisModuleTypeUTest( String JavaDoc name )
59     {
60         super( name );
61     }
62
63
64     //-------------------------------------------------------------------------
65
// Tests
66

67     public void testSetName1()
68     {
69         AnalysisModuleType atm = createAnalysisModuleType();
70         
71         atm.setName( null );
72     }
73
74
75     
76     public void testCreateModule1()
77     {
78         AnalysisModuleType atm = createAnalysisModuleType();
79         try
80         {
81             atm.getAnalysisModule();
82             fail( "Did not throw BuildException." );
83         }
84         catch (BuildException be)
85         {
86             // check exception?
87
}
88     }
89     
90     public void testCreateModule2()
91     {
92         AnalysisModuleType atm = createAnalysisModuleType();
93         atm.setName( null );
94         try
95         {
96             atm.getAnalysisModule();
97             fail( "Did not throw BuildException." );
98         }
99         catch (BuildException be)
100         {
101             // check exception?
102
}
103     }
104     
105     public void testCreateModule3()
106     {
107         AnalysisModuleType atm = createAnalysisModuleType();
108         atm.setName( "" );
109         try
110         {
111             atm.getAnalysisModule();
112             fail( "Did not throw BuildException." );
113         }
114         catch (BuildException be)
115         {
116             // check exception?
117
}
118     }
119     
120     
121     public void testCreateModule4()
122     {
123         AnalysisModuleType atm = createAnalysisModuleType();
124         atm.setName( "line" );
125         IAnalysisModule am = atm.getAnalysisModule();
126         assertNotNull(
127             "returned null module.",
128             am );
129         assertTrue(
130             "Not a LineCountMeasure module.",
131             am instanceof LineCountMeasure );
132         addAnalysisModuleTest( am, "CreateModule4" );
133     }
134
135
136     public void testCreateModule5()
137     {
138         AnalysisModuleType atm = createAnalysisModuleType();
139         atm.setName( "linecount" );
140         IAnalysisModule am = atm.getAnalysisModule();
141         assertNotNull(
142             "returned null module.",
143             am );
144         assertTrue(
145             "Not a LineCountMeasure module.",
146             am instanceof LineCountMeasure );
147         addAnalysisModuleTest( am, "CreateModule5" );
148     }
149     
150     
151     //-------------------------------------------------------------------------
152
// Helpers
153

154
155     protected AnalysisModuleType createAnalysisModuleType()
156     {
157         return new AnalysisModuleType();
158     }
159     
160     
161     protected void addAnalysisModuleTest( final IAnalysisModule am,
162             String JavaDoc testName )
163     {
164         InterfaceTestSuite its = IAnalysisModuleUTestI.suite();
165         its.addFactory( new CxFactory( testName ) {
166                 public Object JavaDoc createImplObject() throws Exception JavaDoc
167                 {
168                     return am;
169                 }
170             } );
171         addSubTest( its );
172     }
173     
174     
175     
176     //-------------------------------------------------------------------------
177
// Standard JUnit declarations
178

179     
180     public static Test suite()
181     {
182         TestSuite suite = new TestSuite( THIS_CLASS );
183         
184         return suite;
185     }
186     
187     public static void main( String JavaDoc[] args )
188     {
189         String JavaDoc[] name = { THIS_CLASS.getName() };
190         
191         // junit.textui.TestRunner.main( name );
192
// junit.swingui.TestRunner.main( name );
193

194         junit.textui.TestRunner.main( name );
195     }
196     
197     
198     /**
199      *
200      * @exception Exception thrown under any exceptional condition.
201      */

202     protected void setUp() throws Exception JavaDoc
203     {
204         super.setUp();
205         
206         // set ourself up
207
}
208     
209     
210     /**
211      *
212      * @exception Exception thrown under any exceptional condition.
213      */

214     protected void tearDown() throws Exception JavaDoc
215     {
216         // tear ourself down
217

218         
219         super.tearDown();
220     }
221 }
222
223
Popular Tags