001: /*
002: * @(#)ParseCoverageLoggerUTest.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.compiler;
028:
029: import junit.framework.Test;
030: import junit.framework.TestCase;
031: import junit.framework.TestSuite;
032: import net.sourceforge.groboutils.autodoc.v1.AutoDoc;
033:
034: /**
035: * Tests the ParseCoverageLogger class.
036: *
037: * @author Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
038: * @version $Date: 2004/04/15 05:48:28 $
039: * @since January 13, 2003
040: */
041: public class ParseCoverageLoggerUTest extends TestCase {
042: //-------------------------------------------------------------------------
043: // Standard JUnit Class-specific declarations
044:
045: private static final Class THIS_CLASS = ParseCoverageLoggerUTest.class;
046: private static final AutoDoc DOC = new AutoDoc(THIS_CLASS);
047:
048: public ParseCoverageLoggerUTest(String name) {
049: super (name);
050: }
051:
052: //-------------------------------------------------------------------------
053: // Tests
054:
055: public void testConstructor1() {
056: new ParseCoverageLogger();
057: }
058:
059: public void testConstructor2() {
060: try {
061: new ParseCoverageLogger(null, null);
062: fail("Did not throw IllegalArgumentException.");
063: } catch (IllegalArgumentException iae) {
064: // test exception
065: }
066: }
067:
068: public void testConstructor3() {
069: try {
070: new ParseCoverageLogger(THIS_CLASS, null);
071: fail("Did not throw IllegalArgumentException.");
072: } catch (IllegalArgumentException iae) {
073: // test exception
074: }
075: }
076:
077: public void testConstructor4() {
078: try {
079: new ParseCoverageLogger(null, "");
080: fail("Did not throw IllegalArgumentException.");
081: } catch (IllegalArgumentException iae) {
082: // test exception
083: }
084: }
085:
086: public void testConstructor5() {
087: try {
088: new ParseCoverageLogger(MyLogger.class, "not-exist");
089: fail("Did not throw IllegalStateException.");
090: } catch (IllegalStateException iae) {
091: // test exception
092: }
093: }
094:
095: public void testConstructor6() {
096: try {
097: new ParseCoverageLogger(MyLogger.class, "bad1");
098: fail("Did not throw IllegalStateException.");
099: } catch (IllegalStateException iae) {
100: // test exception
101: }
102: }
103:
104: public void testConstructor7() {
105: try {
106: new ParseCoverageLogger(MyLogger.class, "bad2");
107: fail("Did not throw IllegalStateException.");
108: } catch (IllegalStateException iae) {
109: // test exception
110: }
111: }
112:
113: public void testConstructor8() {
114: try {
115: new ParseCoverageLogger(MyLogger.class, "bad3");
116: fail("Did not throw IllegalStateException.");
117: } catch (IllegalStateException iae) {
118: // test exception
119: }
120: }
121:
122: public void testConstructor9() {
123: try {
124: new ParseCoverageLogger(MyLogger.class, "bad4");
125: fail("Did not throw IllegalStateException.");
126: } catch (IllegalStateException iae) {
127: // test exception
128: }
129: }
130:
131: public void testConstructor10() {
132: try {
133: new ParseCoverageLogger(MyLogger.class, "bad5");
134: fail("Did not throw IllegalStateException.");
135: } catch (IllegalStateException iae) {
136: // test exception
137: }
138: }
139:
140: public void testConstructor11() {
141: try {
142: new ParseCoverageLogger(MyLogger.class, "bad6");
143: fail("Did not throw IllegalStateException.");
144: } catch (IllegalStateException iae) {
145: // test exception
146: }
147: }
148:
149: public void testConstructor12() {
150: new ParseCoverageLogger(MyLogger.class, "good");
151: }
152:
153: public void testGetClassName1() {
154: ParseCoverageLogger pcl = new ParseCoverageLogger(
155: MyLogger.class, "good");
156: assertEquals("Incorrect class name.", MyLogger.class.getName(),
157: pcl.getClassName());
158: }
159:
160: public void testGetMethodName1() {
161: ParseCoverageLogger pcl = new ParseCoverageLogger(
162: MyLogger.class, "good");
163: assertEquals("Incorrect method name.", "good", pcl
164: .getMethodName());
165: }
166:
167: public void testGetMethodSignature1() {
168: ParseCoverageLogger pcl = new ParseCoverageLogger(
169: MyLogger.class, "good");
170: assertEquals("Incorrect method signature.",
171: "(Ljava/lang/String;SSS)V", pcl.getMethodSignature());
172: }
173:
174: //-------------------------------------------------------------------------
175: // Helpers
176:
177: public static class MyLogger {
178: public static void good(String s, short a, short b, short c) {
179: }
180:
181: public static String bad1(String s, short a, short b, short c) {
182: return "";
183: }
184:
185: public void bad2(String s, short a, short b, short c) {
186: }
187:
188: protected static void bad3(String s, short a, short b, short c) {
189: }
190:
191: static void bad4(String s, short a, short b, short c) {
192: }
193:
194: protected void bad5(String s, short a, short b, short c) {
195: }
196:
197: void bad6(String s, short a, short b, short c) {
198: }
199: }
200:
201: //-------------------------------------------------------------------------
202: // Standard JUnit declarations
203:
204: public static Test suite() {
205: TestSuite suite = new TestSuite(THIS_CLASS);
206:
207: return suite;
208: }
209:
210: public static void main(String[] args) {
211: String[] name = { THIS_CLASS.getName() };
212:
213: // junit.textui.TestRunner.main( name );
214: // junit.swingui.TestRunner.main( name );
215:
216: junit.textui.TestRunner.main(name);
217: }
218:
219: /**
220: *
221: * @exception Exception thrown under any exceptional condition.
222: */
223: protected void setUp() throws Exception {
224: super .setUp();
225:
226: // set ourself up
227: }
228:
229: /**
230: *
231: * @exception Exception thrown under any exceptional condition.
232: */
233: protected void tearDown() throws Exception {
234: // tear ourself down
235:
236: super.tearDown();
237: }
238: }
|