001: /*
002: * @(#)DefaultTestInfoUTest.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.autodoc.v1.testserver;
028:
029: import net.sourceforge.groboutils.autodoc.v1.*;
030:
031: import net.sourceforge.groboutils.junit.v1.iftc.*;
032: import junit.framework.Test;
033: import junit.framework.TestCase;
034: import junit.framework.TestSuite;
035:
036: /**
037: * Tests the DefaultTestInfo class.
038: *
039: * @author Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
040: * @since March 27, 2002
041: * @version $Date: 2003/02/10 22:52:17 $
042: */
043: public class DefaultTestInfoUTest extends TestCase {
044: //-------------------------------------------------------------------------
045: // Standard JUnit Class-specific declarations
046:
047: private static final Class THIS_CLASS = DefaultTestInfoUTest.class;
048:
049: public DefaultTestInfoUTest(String name) {
050: super (name);
051: }
052:
053: //-------------------------------------------------------------------------
054: // setup
055:
056: /**
057: *
058: * @exception Exception thrown under any exceptional condition.
059: */
060: protected void setUp() throws Exception {
061: super .setUp();
062:
063: // set ourself up
064: }
065:
066: //-------------------------------------------------------------------------
067: // Tests
068:
069: public void testConstructor1() {
070: TestInfo ti = new DefaultTestInfo();
071: assertNull("did not return null suite.", ti.getSuite());
072: assertNull("did not return null method.", ti.getMethod());
073: }
074:
075: public void testConstructor2() {
076: TestInfo ti = new DefaultTestInfo("a", "b");
077: assertEquals("did not return correct suite.", "a", ti
078: .getSuite());
079: assertEquals("did not return correct method.", "b", ti
080: .getMethod());
081: }
082:
083: public void testEquals1() {
084: TestInfo ti1 = new DefaultTestInfo("a", "b");
085: TestInfo ti2 = new DefaultTestInfo("a", "b");
086: assertTrue("did not think same data is equal.", ti1.equals(ti2));
087: }
088:
089: public void testEquals2() {
090: TestInfo ti1 = new DefaultTestInfo("a", "b");
091: TestInfo ti2 = new DefaultTestInfo("a", "c");
092: assertTrue("did not think different method is not equal.", !ti1
093: .equals(ti2));
094: }
095:
096: public void testEquals3() {
097: TestInfo ti1 = new DefaultTestInfo("a", "b");
098: TestInfo ti2 = new DefaultTestInfo("c", "b");
099: assertTrue("did not think different suite is not equal.", !ti1
100: .equals(ti2));
101: }
102:
103: public void testEquals4() {
104: TestInfo ti1 = new DefaultTestInfo("a", "b");
105: TestInfo ti2 = new DefaultTestInfo("d", "c");
106: assertTrue(
107: "did not think different method and suite is not equal.",
108: !ti1.equals(ti2));
109: }
110:
111: //-------------------------------------------------------------------------
112: // Helpers
113:
114: //-------------------------------------------------------------------------
115: // Standard JUnit declarations
116:
117: public static Test suite() {
118: InterfaceTestSuite suite = TestInfoUTestI.suite();
119: suite.addTestSuite(THIS_CLASS);
120: suite.addFactory(new CxFactory("A") {
121: public Object createImplObject() {
122: return new DefaultTestInfo();
123: }
124: });
125: suite.addFactory(new CxFactory("B") {
126: public Object createImplObject() {
127: return new DefaultTestInfo("a", null);
128: }
129: });
130: suite.addFactory(new CxFactory("C") {
131: public Object createImplObject() {
132: return new DefaultTestInfo(null, "a");
133: }
134: });
135: suite.addFactory(new CxFactory("D") {
136: public Object createImplObject() {
137: return new DefaultTestInfo("a", "b");
138: }
139: });
140:
141: return suite;
142: }
143:
144: public static void main(String[] args) {
145: String[] name = { THIS_CLASS.getName() };
146:
147: // junit.textui.TestRunner.main( name );
148: // junit.swingui.TestRunner.main( name );
149:
150: junit.textui.TestRunner.main(name);
151: }
152:
153: /**
154: *
155: * @exception Exception thrown under any exceptional condition.
156: */
157: protected void tearDown() throws Exception {
158: // tear ourself down
159:
160: super.tearDown();
161: }
162: }
|