001: /*
002: * @(#)AutoDocITSetUTest.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.autodoc.v1.defimpl;
028:
029: import net.sourceforge.groboutils.autodoc.v1.spi.AutoDocLogFactory;
030: import net.sourceforge.groboutils.autodoc.v1.*;
031: import net.sourceforge.groboutils.autodoc.v1.spi.*;
032:
033: import org.easymock.EasyMock;
034: import org.easymock.MockControl;
035: import net.sourceforge.groboutils.junit.v1.iftc.*;
036: import junit.framework.Test;
037: import junit.framework.TestCase;
038: import junit.framework.TestSuite;
039:
040: import java.util.*;
041:
042: /**
043: * Tests the DefaultAutoDocFactory class.
044: *
045: * @author Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
046: * @version $Date: 2003/05/30 00:06:04 $
047: * @since March 27, 2002
048: */
049: public class AutoDocITSetUTest extends TestCase {
050: //-------------------------------------------------------------------------
051: // Standard JUnit Class-specific declarations
052:
053: private static final Class THIS_CLASS = AutoDocITSetUTest.class;
054:
055: public AutoDocITSetUTest(String name) {
056: super (name);
057: }
058:
059: //-------------------------------------------------------------------------
060: // setup
061:
062: /**
063: *
064: * @exception Exception thrown under any exceptional condition.
065: */
066: protected void setUp() throws Exception {
067: super .setUp();
068:
069: // set ourself up
070: }
071:
072: //-------------------------------------------------------------------------
073: // Tests
074:
075: private static class MyAutoDocIT implements AutoDocIT {
076: public Vector methodNames = new Vector();
077: public Vector longIssueID = new Vector();
078: public Vector strIssueID = new Vector();
079:
080: public void testsIssue(String methodName, long issueID) {
081: this .methodNames.addElement(methodName);
082: this .longIssueID.addElement(new Long(issueID));
083: }
084:
085: public void testsIssue(String methodName, String issueID) {
086: this .methodNames.addElement(methodName);
087: this .strIssueID.addElement(issueID);
088: }
089:
090: public void testsIssue(long issueID) {
091: this .longIssueID.addElement(new Long(issueID));
092: }
093:
094: public void testsIssue(String issueID) {
095: this .strIssueID.addElement(issueID);
096: }
097: }
098:
099: public void testTestsIssue1() {
100: MyAutoDocIT mad = new MyAutoDocIT();
101: AutoDocITSet set = new AutoDocITSet();
102: set.addIT(mad);
103:
104: set.testsIssue("name", 1L);
105:
106: assertEquals("Did not add only 1 method name.", mad.methodNames
107: .size(), 1);
108: assertEquals("Did not add only 1 long id.", mad.longIssueID
109: .size(), 1);
110: assertEquals("Added a string id.", mad.strIssueID.size(), 0);
111: }
112:
113: public void testTestsIssue2() {
114: MyAutoDocIT mad = new MyAutoDocIT();
115: AutoDocITSet set = new AutoDocITSet();
116: set.addIT(mad);
117:
118: set.testsIssue("name", "1");
119:
120: assertEquals("Did not add only 1 method name.", mad.methodNames
121: .size(), 1);
122: assertEquals("Did not add only 1 string id.", mad.strIssueID
123: .size(), 1);
124: assertEquals("Added a long id.", mad.longIssueID.size(), 0);
125: }
126:
127: public void testTestsIssue3() {
128: MyAutoDocIT mad = new MyAutoDocIT();
129: AutoDocITSet set = new AutoDocITSet();
130: set.addIT(mad);
131:
132: set.testsIssue(1L);
133:
134: assertEquals("Added a method name.", mad.methodNames.size(), 0);
135: assertEquals("Did not add only 1 long id.", mad.longIssueID
136: .size(), 1);
137: assertEquals("Added a string id.", mad.strIssueID.size(), 0);
138: }
139:
140: public void testTestsIssue4() {
141: MyAutoDocIT mad = new MyAutoDocIT();
142: AutoDocITSet set = new AutoDocITSet();
143: set.addIT(mad);
144:
145: set.testsIssue("l");
146:
147: assertEquals("Added a method name.", mad.methodNames.size(), 0);
148: assertEquals("Did not add only 1 string id.", mad.strIssueID
149: .size(), 1);
150: assertEquals("Added a long id.", mad.longIssueID.size(), 0);
151: }
152:
153: //-------------------------------------------------------------------------
154: // Standard JUnit declarations
155:
156: public static Test suite() {
157: TestSuite suite = new TestSuite(THIS_CLASS);
158: InterfaceTestSuite its = AutoDocITUTestI.suite();
159: its.addInterfaceTestSuite(IAutoDocSetUTestI.suite());
160: its.addFactory(new CxFactory("A") {
161: public Object createImplObject() {
162: return new AutoDocITSet();
163: }
164: });
165: suite.addTest(its);
166:
167: return suite;
168: }
169:
170: public static void main(String[] args) {
171: String[] name = { THIS_CLASS.getName() };
172:
173: // junit.textui.TestRunner.main( name );
174: // junit.swingui.TestRunner.main( name );
175:
176: junit.textui.TestRunner.main(name);
177: }
178:
179: /**
180: *
181: * @exception Exception thrown under any exceptional condition.
182: */
183: protected void tearDown() throws Exception {
184: // tear ourself down
185:
186: super.tearDown();
187: }
188: }
|