KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * @(#)DirMetaDataIOUTest.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.datastore;
28
29 import java.io.File JavaDoc;
30 import java.io.IOException JavaDoc;
31
32 import junit.framework.Test;
33 import junit.framework.TestCase;
34 import junit.framework.TestSuite;
35 import net.sourceforge.groboutils.autodoc.v1.AutoDoc;
36 import net.sourceforge.groboutils.codecoverage.v2.CCCreatorUtil;
37 import net.sourceforge.groboutils.codecoverage.v2.IAnalysisModule;
38
39
40 /**
41  * Tests the DirMetaDataIO class.
42  *
43  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
44  * @version $Date: 2004/04/15 05:48:28 $
45  * @since January 22, 2003
46  */

47 public class DirMetaDataIOUTest extends TestCase
48 {
49     //-------------------------------------------------------------------------
50
// Standard JUnit Class-specific declarations
51

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

64     
65     public void testConstructor1()
66     {
67         // fail( "Needs more tests." );
68
}
69     
70     
71     public void testGetAnalysisModuleSet1() throws IOException JavaDoc
72     {
73         // ensure that working off a non-empy file doesn't kill us
74
File JavaDoc f = CCCreatorUtil.createNewDirectory();
75         DirMetaDataIO dmd = new DirMetaDataIO( f );
76         AnalysisModuleSet ams = dmd.getAnalysisModuleSet();
77         assertEquals(
78             "Somehow we created data from nothing.",
79             0,
80             ams.getAnalysisModuleCount() );
81     }
82     
83     
84     public void testPutAnalysisModuleSet1() throws IOException JavaDoc
85     {
86         // ensure that working off a brand-new file doesn't kill us.
87
File JavaDoc f = CCCreatorUtil.createNewDirectory();
88         AnalysisModuleSet ams = CCCreatorUtil.createAnalysisModuleSet( 4 );
89         DirMetaDataIO dmd = new DirMetaDataIO( f );
90         dmd.getAnalysisModuleSet();
91         dmd.putAnalysisModuleSet( ams );
92         AnalysisModuleSet ams2 = dmd.getAnalysisModuleSet();
93         assertEquals(
94             "Didn't recreate the four modules.",
95             4,
96             ams2.getAnalysisModuleCount() );
97     }
98     
99     
100     public void testPutAnalysisModuleSet2() throws IOException JavaDoc
101     {
102         // ensure that working off a brand-new file doesn't kill us.
103
File JavaDoc f = CCCreatorUtil.createNewDirectory();
104         IAnalysisModule am = CCCreatorUtil.createIAnalysisModule( "a", "u",
105             "text/plain" );
106         DirMetaDataIO dmd = new DirMetaDataIO( f );
107         dmd.getAnalysisModuleSet();
108         dmd.putAnalysisModuleSet( new AnalysisModuleSet(
109             new IAnalysisModule[] { am } ) );
110         AnalysisModuleSet ams = dmd.getAnalysisModuleSet();
111         assertEquals(
112             "Didn't recreate the one module.",
113             1,
114             ams.getAnalysisModuleCount() );
115         assertTrue(
116             "Bad module index.",
117             ams.getAnalysisModuleIndex( am ) >= 0 );
118         assertTrue(
119             "Bad measure index.",
120             ams.getMeasureIndex( "a" ) >= 0 );
121     }
122     
123     
124     
125     
126     
127     //-------------------------------------------------------------------------
128
// Helpers
129

130     
131     
132     //-------------------------------------------------------------------------
133
// Standard JUnit declarations
134

135     
136     public static Test suite()
137     {
138         TestSuite suite = new TestSuite( THIS_CLASS );
139         
140         return suite;
141     }
142     
143     public static void main( String JavaDoc[] args )
144     {
145         String JavaDoc[] name = { THIS_CLASS.getName() };
146         
147         // junit.textui.TestRunner.main( name );
148
// junit.swingui.TestRunner.main( name );
149

150         junit.textui.TestRunner.main( name );
151     }
152     
153     
154     /**
155      *
156      * @exception Exception thrown under any exceptional condition.
157      */

158     protected void setUp() throws Exception JavaDoc
159     {
160         super.setUp();
161
162        
163         // set ourself up
164
}
165     
166     
167     /**
168      *
169      * @exception Exception thrown under any exceptional condition.
170      */

171     protected void tearDown() throws Exception JavaDoc
172     {
173         // tear ourself down
174

175         
176         super.tearDown();
177     }
178 }
179
180
Popular Tags