001: /*
002: * @(#)AnalysisModuleTypeUTest.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.ant;
028:
029: import junit.framework.Test;
030: import junit.framework.TestSuite;
031: import net.sourceforge.groboutils.autodoc.v1.AutoDoc;
032: import net.sourceforge.groboutils.codecoverage.v2.IAnalysisModule;
033: import net.sourceforge.groboutils.codecoverage.v2.IAnalysisModuleUTestI;
034: import net.sourceforge.groboutils.codecoverage.v2.module.LineCountMeasure;
035: import net.sourceforge.groboutils.junit.v1.SubTestTestCase;
036: import net.sourceforge.groboutils.junit.v1.iftc.CxFactory;
037: import net.sourceforge.groboutils.junit.v1.iftc.InterfaceTestSuite;
038:
039: import org.apache.tools.ant.BuildException;
040:
041: /**
042: * Tests the AnalysisModuleType class.
043: *
044: * @author Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
045: * @version $Date: 2004/04/15 05:48:27 $
046: * @since December 28, 2002
047: */
048: public class AnalysisModuleTypeUTest extends SubTestTestCase {
049: //-------------------------------------------------------------------------
050: // Standard JUnit Class-specific declarations
051:
052: private static final Class THIS_CLASS = AnalysisModuleTypeUTest.class;
053: private static final AutoDoc DOC = new AutoDoc(THIS_CLASS);
054:
055: public AnalysisModuleTypeUTest(String name) {
056: super (name);
057: }
058:
059: //-------------------------------------------------------------------------
060: // Tests
061:
062: public void testSetName1() {
063: AnalysisModuleType atm = createAnalysisModuleType();
064:
065: atm.setName(null);
066: }
067:
068: public void testCreateModule1() {
069: AnalysisModuleType atm = createAnalysisModuleType();
070: try {
071: atm.getAnalysisModule();
072: fail("Did not throw BuildException.");
073: } catch (BuildException be) {
074: // check exception?
075: }
076: }
077:
078: public void testCreateModule2() {
079: AnalysisModuleType atm = createAnalysisModuleType();
080: atm.setName(null);
081: try {
082: atm.getAnalysisModule();
083: fail("Did not throw BuildException.");
084: } catch (BuildException be) {
085: // check exception?
086: }
087: }
088:
089: public void testCreateModule3() {
090: AnalysisModuleType atm = createAnalysisModuleType();
091: atm.setName("");
092: try {
093: atm.getAnalysisModule();
094: fail("Did not throw BuildException.");
095: } catch (BuildException be) {
096: // check exception?
097: }
098: }
099:
100: public void testCreateModule4() {
101: AnalysisModuleType atm = createAnalysisModuleType();
102: atm.setName("line");
103: IAnalysisModule am = atm.getAnalysisModule();
104: assertNotNull("returned null module.", am);
105: assertTrue("Not a LineCountMeasure module.",
106: am instanceof LineCountMeasure);
107: addAnalysisModuleTest(am, "CreateModule4");
108: }
109:
110: public void testCreateModule5() {
111: AnalysisModuleType atm = createAnalysisModuleType();
112: atm.setName("linecount");
113: IAnalysisModule am = atm.getAnalysisModule();
114: assertNotNull("returned null module.", am);
115: assertTrue("Not a LineCountMeasure module.",
116: am instanceof LineCountMeasure);
117: addAnalysisModuleTest(am, "CreateModule5");
118: }
119:
120: //-------------------------------------------------------------------------
121: // Helpers
122:
123: protected AnalysisModuleType createAnalysisModuleType() {
124: return new AnalysisModuleType();
125: }
126:
127: protected void addAnalysisModuleTest(final IAnalysisModule am,
128: String testName) {
129: InterfaceTestSuite its = IAnalysisModuleUTestI.suite();
130: its.addFactory(new CxFactory(testName) {
131: public Object createImplObject() throws Exception {
132: return am;
133: }
134: });
135: addSubTest(its);
136: }
137:
138: //-------------------------------------------------------------------------
139: // Standard JUnit declarations
140:
141: public static Test suite() {
142: TestSuite suite = new TestSuite(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: }
|