KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > groboutils > codecoverage > v2 > datastore > IClassMetaDataWriterUTestI


1 /*
2  * @(#)IClassMetaDataWriterUTestI.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.datastore;
28
29 import java.io.IOException JavaDoc;
30
31 import net.sourceforge.groboutils.autodoc.v1.AutoDoc;
32 import net.sourceforge.groboutils.codecoverage.v2.CCCreatorUtil;
33 import net.sourceforge.groboutils.codecoverage.v2.compiler.ModifiedClass;
34 import net.sourceforge.groboutils.junit.v1.iftc.ImplFactory;
35 import net.sourceforge.groboutils.junit.v1.iftc.InterfaceTestCase;
36 import net.sourceforge.groboutils.junit.v1.iftc.InterfaceTestSuite;
37
38
39 /**
40  * Tests the IClassMetaDataWriter interface.
41  *
42  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
43  * @version $Date: 2004/04/15 05:48:28 $
44  * @since December 28, 2002
45  */

46 public class IClassMetaDataWriterUTestI extends InterfaceTestCase
47 {
48     //-------------------------------------------------------------------------
49
// Standard JUnit Class-specific declarations
50

51     private static final Class JavaDoc THIS_CLASS = IClassMetaDataWriterUTestI.class;
52     private static final AutoDoc DOC = new AutoDoc( THIS_CLASS );
53     
54     public IClassMetaDataWriterUTestI( String JavaDoc name, ImplFactory f )
55     {
56         super( name, IClassMetaDataWriter.class, f );
57     }
58
59     
60     public IClassMetaDataWriter createIClassMetaDataWriter()
61     {
62         return (IClassMetaDataWriter)createImplObject();
63     }
64
65     
66     // This is the set that's used for creating the class records, if you
67
// need it. Note that the DirMetaDataIO class needs to have its set
68
// of AMS match the incoming class records.
69
public final static AnalysisModuleSet AMS =
70         CCCreatorUtil.createAnalysisModuleSet( 2 );
71     
72     
73     //-------------------------------------------------------------------------
74
// Tests
75

76     public void testWriteClassRecord1() throws Exception JavaDoc
77     {
78         IClassMetaDataWriter cmdw = createIClassMetaDataWriter();
79         try
80         {
81             cmdw.writeClassRecord( null );
82             fail( "Did not throw IllegalArgumentException." );
83         }
84         catch (IllegalArgumentException JavaDoc ex)
85         {
86             // test exception
87
}
88     }
89     
90     
91     public void testWriteClassRecord2() throws Exception JavaDoc
92     {
93         IClassMetaDataWriter cmdw = createIClassMetaDataWriter();
94         ModifiedClass mc = CCCreatorUtil.createModifiedClass( THIS_CLASS );
95         ClassRecord cr = mc.createClassRecord( AMS );
96         
97         cmdw.writeClassRecord( cr );
98         
99         // any way to check this?
100
}
101     
102     
103     public void testClose1() throws Exception JavaDoc
104     {
105         IClassMetaDataWriter cmdw = createIClassMetaDataWriter();
106         cmdw.close();
107     }
108     
109     
110     public void testClose2() throws Exception JavaDoc
111     {
112         IClassMetaDataWriter cmdw = createIClassMetaDataWriter();
113         ModifiedClass mc = CCCreatorUtil.createModifiedClass( THIS_CLASS );
114         ClassRecord cr = mc.createClassRecord( AMS );
115         cmdw.close();
116         
117         try
118         {
119             cmdw.writeClassRecord( cr );
120             fail( "Did not throw IOException." );
121         }
122         catch (IOException JavaDoc ex)
123         {
124             // test exception
125
}
126     }
127     
128     
129     public void testClose3() throws Exception JavaDoc
130     {
131         IClassMetaDataWriter cmdw = createIClassMetaDataWriter();
132         cmdw.close();
133         
134         try
135         {
136             cmdw.writeClassRecord( null );
137             fail( "Did not throw IllegalArgumentException or IOException." );
138         }
139         // either of these two exceptions could be thrown
140
catch (IllegalArgumentException JavaDoc ex)
141         {
142             // test exception
143
}
144         catch (IOException JavaDoc ex)
145         {
146             // test exception
147
}
148     }
149     
150     
151     public void testClose4() throws Exception JavaDoc
152     {
153         IClassMetaDataWriter cmdw = createIClassMetaDataWriter();
154         cmdw.close();
155         
156         try
157         {
158             cmdw.close();
159             fail( "Did not throw IOException." );
160         }
161         catch (IOException JavaDoc ex)
162         {
163             // test exception
164
}
165     }
166      
167     
168     
169     //-------------------------------------------------------------------------
170
// Standard JUnit declarations
171

172     
173     public static InterfaceTestSuite suite()
174     {
175         InterfaceTestSuite suite = new InterfaceTestSuite( THIS_CLASS );
176         
177         return suite;
178     }
179     
180     public static void main( String JavaDoc[] args )
181     {
182         String JavaDoc[] name = { THIS_CLASS.getName() };
183         
184         // junit.textui.TestRunner.main( name );
185
// junit.swingui.TestRunner.main( name );
186

187         junit.textui.TestRunner.main( name );
188     }
189     
190     
191     /**
192      *
193      * @exception Exception thrown under any exceptional condition.
194      */

195     protected void setUp() throws Exception JavaDoc
196     {
197         super.setUp();
198         
199         // set ourself up
200
}
201     
202     
203     /**
204      *
205      * @exception Exception thrown under any exceptional condition.
206      */

207     protected void tearDown() throws Exception JavaDoc
208     {
209         // tear ourself down
210

211         
212         super.tearDown();
213     }
214 }
215
216
Popular Tags