001: /*
002: * @(#)DirMetaDataIOUTest.java
003: *
004: * Copyright (C) 2003 Matt Albrecht
005: * groboclown@users.sourceforge.net
006: * http://groboutils.sourceforge.net
007: *
008: * Permission is hereby granted, free of charge, to any person obtaining a
009: * copy of this software and associated documentation files (the "Software"),
010: * to deal in the Software without restriction, including without limitation
011: * the rights to use, copy, modify, merge, publish, distribute, sublicense,
012: * and/or sell copies of the Software, and to permit persons to whom the
013: * Software is furnished to do so, subject to the following conditions:
014: *
015: * The above copyright notice and this permission notice shall be included in
016: * all copies or substantial portions of the Software.
017: *
018: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
019: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
020: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
021: * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
022: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
023: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
024: * DEALINGS IN THE SOFTWARE.
025: */
026:
027: package net.sourceforge.groboutils.codecoverage.v2.datastore;
028:
029: import java.io.File;
030: import java.io.IOException;
031:
032: import junit.framework.Test;
033: import junit.framework.TestCase;
034: import junit.framework.TestSuite;
035: import net.sourceforge.groboutils.autodoc.v1.AutoDoc;
036: import net.sourceforge.groboutils.codecoverage.v2.CCCreatorUtil;
037: import net.sourceforge.groboutils.codecoverage.v2.IAnalysisModule;
038:
039: /**
040: * Tests the DirMetaDataIO class.
041: *
042: * @author Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
043: * @version $Date: 2004/04/15 05:48:28 $
044: * @since January 22, 2003
045: */
046: public class DirMetaDataIOUTest extends TestCase {
047: //-------------------------------------------------------------------------
048: // Standard JUnit Class-specific declarations
049:
050: private static final Class THIS_CLASS = DirMetaDataIOUTest.class;
051: private static final AutoDoc DOC = new AutoDoc(THIS_CLASS);
052:
053: public DirMetaDataIOUTest(String name) {
054: super (name);
055: }
056:
057: //-------------------------------------------------------------------------
058: // Tests
059:
060: public void testConstructor1() {
061: // fail( "Needs more tests." );
062: }
063:
064: public void testGetAnalysisModuleSet1() throws IOException {
065: // ensure that working off a non-empy file doesn't kill us
066: File f = CCCreatorUtil.createNewDirectory();
067: DirMetaDataIO dmd = new DirMetaDataIO(f);
068: AnalysisModuleSet ams = dmd.getAnalysisModuleSet();
069: assertEquals("Somehow we created data from nothing.", 0, ams
070: .getAnalysisModuleCount());
071: }
072:
073: public void testPutAnalysisModuleSet1() throws IOException {
074: // ensure that working off a brand-new file doesn't kill us.
075: File f = CCCreatorUtil.createNewDirectory();
076: AnalysisModuleSet ams = CCCreatorUtil
077: .createAnalysisModuleSet(4);
078: DirMetaDataIO dmd = new DirMetaDataIO(f);
079: dmd.getAnalysisModuleSet();
080: dmd.putAnalysisModuleSet(ams);
081: AnalysisModuleSet ams2 = dmd.getAnalysisModuleSet();
082: assertEquals("Didn't recreate the four modules.", 4, ams2
083: .getAnalysisModuleCount());
084: }
085:
086: public void testPutAnalysisModuleSet2() throws IOException {
087: // ensure that working off a brand-new file doesn't kill us.
088: File f = CCCreatorUtil.createNewDirectory();
089: IAnalysisModule am = CCCreatorUtil.createIAnalysisModule("a",
090: "u", "text/plain");
091: DirMetaDataIO dmd = new DirMetaDataIO(f);
092: dmd.getAnalysisModuleSet();
093: dmd.putAnalysisModuleSet(new AnalysisModuleSet(
094: new IAnalysisModule[] { am }));
095: AnalysisModuleSet ams = dmd.getAnalysisModuleSet();
096: assertEquals("Didn't recreate the one module.", 1, ams
097: .getAnalysisModuleCount());
098: assertTrue("Bad module index.",
099: ams.getAnalysisModuleIndex(am) >= 0);
100: assertTrue("Bad measure index.", ams.getMeasureIndex("a") >= 0);
101: }
102:
103: //-------------------------------------------------------------------------
104: // Helpers
105:
106: //-------------------------------------------------------------------------
107: // Standard JUnit declarations
108:
109: public static Test suite() {
110: TestSuite suite = new TestSuite(THIS_CLASS);
111:
112: return suite;
113: }
114:
115: public static void main(String[] args) {
116: String[] name = { THIS_CLASS.getName() };
117:
118: // junit.textui.TestRunner.main( name );
119: // junit.swingui.TestRunner.main( name );
120:
121: junit.textui.TestRunner.main(name);
122: }
123:
124: /**
125: *
126: * @exception Exception thrown under any exceptional condition.
127: */
128: protected void setUp() throws Exception {
129: super .setUp();
130:
131: // set ourself up
132: }
133:
134: /**
135: *
136: * @exception Exception thrown under any exceptional condition.
137: */
138: protected void tearDown() throws Exception {
139: // tear ourself down
140:
141: super.tearDown();
142: }
143: }
|