001: /*
002: * @(#)ClassSignatureUtilUTest.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.util;
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 ClassSignatureUtil 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:44 $
039: * @since Feb 4, 2002
040: */
041: public class ClassSignatureUtilUTest extends TestCase {
042: //-------------------------------------------------------------------------
043: // Standard JUnit Class-specific declarations
044:
045: private static final Class THIS_CLASS = ClassSignatureUtilUTest.class;
046: private static final AutoDoc DOC = new AutoDoc(THIS_CLASS);
047:
048: public ClassSignatureUtilUTest(String name) {
049: super (name);
050: }
051:
052: //-------------------------------------------------------------------------
053: // Tests
054:
055: public void testGetInstance1() {
056: assertNotNull("Returned a null instance.", ClassSignatureUtil
057: .getInstance());
058: }
059:
060: public void testCreateClassSignature1() {
061: try {
062: ClassSignatureUtil.getInstance().createClassSignature(null,
063: -1);
064: fail("Did not throw IllegalArgumentException.");
065: } catch (IllegalArgumentException e) {
066: // test exception
067: }
068: }
069:
070: public void testCreateClassSignature2() {
071: String sig = ClassSignatureUtil.getInstance()
072: .createClassSignature("a.b.C", 1L);
073: assertEquals("Did not create correct signature.", "a.b.C-1",
074: sig);
075: }
076:
077: public void testCreateClassSignature3() {
078: String sig = ClassSignatureUtil.getInstance()
079: .createClassSignature("", 100L);
080: assertEquals("Did not create correct signature.", "-100", sig);
081: }
082:
083: public void testGetClassName1() {
084: try {
085: ClassSignatureUtil.getInstance().getClassName(null);
086: fail("Did not throw IllegalArgumentException.");
087: } catch (IllegalArgumentException e) {
088: // test exception
089: }
090: }
091:
092: public void testGetClassName2() {
093: String name = ClassSignatureUtil.getInstance().getClassName("");
094: assertEquals("Did not return correct class name.", "", name);
095: }
096:
097: public void testGetClassName3() {
098: String name = ClassSignatureUtil.getInstance().getClassName(
099: "a.b.C");
100: assertEquals("Did not return correct class name.", "a.b.C",
101: name);
102: }
103:
104: public void testGetClassName4() {
105: String name = ClassSignatureUtil.getInstance().getClassName(
106: "a.b.C--100");
107: assertEquals("Did not return correct class name.", "a.b.C",
108: name);
109: }
110:
111: public void testGetClassName5() {
112: String name = ClassSignatureUtil.getInstance().getClassName(
113: "a.b.C D-100");
114: assertEquals("Did not return correct class name.", "a.b.C D",
115: name);
116: }
117:
118: //-------------------------------------------------------------------------
119: // Standard JUnit declarations
120:
121: public static Test suite() {
122: TestSuite suite = new TestSuite(THIS_CLASS);
123:
124: return suite;
125: }
126:
127: public static void main(String[] args) {
128: String[] name = { THIS_CLASS.getName() };
129:
130: // junit.textui.TestRunner.main( name );
131: // junit.swingui.TestRunner.main( name );
132:
133: junit.textui.TestRunner.main(name);
134: }
135:
136: /**
137: *
138: * @exception Exception thrown under any exceptional condition.
139: */
140: protected void setUp() throws Exception {
141: super .setUp();
142:
143: // set ourself up
144: }
145:
146: /**
147: *
148: * @exception Exception thrown under any exceptional condition.
149: */
150: protected void tearDown() throws Exception {
151: // tear ourself down
152:
153: super.tearDown();
154: }
155: }
|