001: /*
002: * @(#)IClassMetaDataWriterUTestI.java
003: *
004: * Copyright (C) 2002-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.IOException;
030:
031: import net.sourceforge.groboutils.autodoc.v1.AutoDoc;
032: import net.sourceforge.groboutils.codecoverage.v2.CCCreatorUtil;
033: import net.sourceforge.groboutils.codecoverage.v2.compiler.ModifiedClass;
034: import net.sourceforge.groboutils.junit.v1.iftc.ImplFactory;
035: import net.sourceforge.groboutils.junit.v1.iftc.InterfaceTestCase;
036: import net.sourceforge.groboutils.junit.v1.iftc.InterfaceTestSuite;
037:
038: /**
039: * Tests the IClassMetaDataWriter interface.
040: *
041: * @author Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
042: * @version $Date: 2004/04/15 05:48:28 $
043: * @since December 28, 2002
044: */
045: public class IClassMetaDataWriterUTestI extends InterfaceTestCase {
046: //-------------------------------------------------------------------------
047: // Standard JUnit Class-specific declarations
048:
049: private static final Class THIS_CLASS = IClassMetaDataWriterUTestI.class;
050: private static final AutoDoc DOC = new AutoDoc(THIS_CLASS);
051:
052: public IClassMetaDataWriterUTestI(String name, ImplFactory f) {
053: super (name, IClassMetaDataWriter.class, f);
054: }
055:
056: public IClassMetaDataWriter createIClassMetaDataWriter() {
057: return (IClassMetaDataWriter) createImplObject();
058: }
059:
060: // This is the set that's used for creating the class records, if you
061: // need it. Note that the DirMetaDataIO class needs to have its set
062: // of AMS match the incoming class records.
063: public final static AnalysisModuleSet AMS = CCCreatorUtil
064: .createAnalysisModuleSet(2);
065:
066: //-------------------------------------------------------------------------
067: // Tests
068:
069: public void testWriteClassRecord1() throws Exception {
070: IClassMetaDataWriter cmdw = createIClassMetaDataWriter();
071: try {
072: cmdw.writeClassRecord(null);
073: fail("Did not throw IllegalArgumentException.");
074: } catch (IllegalArgumentException ex) {
075: // test exception
076: }
077: }
078:
079: public void testWriteClassRecord2() throws Exception {
080: IClassMetaDataWriter cmdw = createIClassMetaDataWriter();
081: ModifiedClass mc = CCCreatorUtil
082: .createModifiedClass(THIS_CLASS);
083: ClassRecord cr = mc.createClassRecord(AMS);
084:
085: cmdw.writeClassRecord(cr);
086:
087: // any way to check this?
088: }
089:
090: public void testClose1() throws Exception {
091: IClassMetaDataWriter cmdw = createIClassMetaDataWriter();
092: cmdw.close();
093: }
094:
095: public void testClose2() throws Exception {
096: IClassMetaDataWriter cmdw = createIClassMetaDataWriter();
097: ModifiedClass mc = CCCreatorUtil
098: .createModifiedClass(THIS_CLASS);
099: ClassRecord cr = mc.createClassRecord(AMS);
100: cmdw.close();
101:
102: try {
103: cmdw.writeClassRecord(cr);
104: fail("Did not throw IOException.");
105: } catch (IOException ex) {
106: // test exception
107: }
108: }
109:
110: public void testClose3() throws Exception {
111: IClassMetaDataWriter cmdw = createIClassMetaDataWriter();
112: cmdw.close();
113:
114: try {
115: cmdw.writeClassRecord(null);
116: fail("Did not throw IllegalArgumentException or IOException.");
117: }
118: // either of these two exceptions could be thrown
119: catch (IllegalArgumentException ex) {
120: // test exception
121: } catch (IOException ex) {
122: // test exception
123: }
124: }
125:
126: public void testClose4() throws Exception {
127: IClassMetaDataWriter cmdw = createIClassMetaDataWriter();
128: cmdw.close();
129:
130: try {
131: cmdw.close();
132: fail("Did not throw IOException.");
133: } catch (IOException ex) {
134: // test exception
135: }
136: }
137:
138: //-------------------------------------------------------------------------
139: // Standard JUnit declarations
140:
141: public static InterfaceTestSuite suite() {
142: InterfaceTestSuite suite = new InterfaceTestSuite(THIS_CLASS);
143:
144: return suite;
145: }
146:
147: public static void main(String[] args) {
148: String[] name = { THIS_CLASS.getName() };
149:
150: // junit.textui.TestRunner.main( name );
151: // junit.swingui.TestRunner.main( name );
152:
153: junit.textui.TestRunner.main(name);
154: }
155:
156: /**
157: *
158: * @exception Exception thrown under any exceptional condition.
159: */
160: protected void setUp() throws Exception {
161: super .setUp();
162:
163: // set ourself up
164: }
165:
166: /**
167: *
168: * @exception Exception thrown under any exceptional condition.
169: */
170: protected void tearDown() throws Exception {
171: // tear ourself down
172:
173: super.tearDown();
174: }
175: }
|