001: /*
002: * @(#)AutoDocFactoryUTestI.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.spi;
028:
029: import net.sourceforge.groboutils.autodoc.v1.*;
030:
031: import java.util.Enumeration; //import net.sourceforge.groboutils.testing.junitlog.v1.*;
032: import org.easymock.EasyMock;
033: import org.easymock.MockControl;
034: import net.sourceforge.groboutils.junit.v1.iftc.*;
035: import junit.framework.Test;
036: import junit.framework.TestCase;
037: import junit.framework.TestSuite;
038:
039: /**
040: * Tests the AutoDocFactory interface.
041: *
042: * @author Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
043: * @version $Date: 2003/02/10 22:52:17 $
044: * @since March 1, 2002
045: */
046: public class AutoDocFactoryUTestI extends InterfaceTestCase {
047: //-------------------------------------------------------------------------
048: // Standard JUnit Class-specific declarations
049:
050: private static final Class THIS_CLASS = AutoDocFactoryUTestI.class;
051:
052: // private static final IJUnitDocumentor LOG = (new JUnitLog(THIS_CLASS)).getDocumentor();
053:
054: public AutoDocFactoryUTestI(String name, ImplFactory f) {
055: super (name, AutoDocFactory.class, f);
056: }
057:
058: public AutoDocFactory createAutoDocFactory() {
059: return (AutoDocFactory) createImplObject();
060: }
061:
062: //-------------------------------------------------------------------------
063: // Tests
064:
065: public void testCreateLog1() {
066: AutoDocFactory adf = createAutoDocFactory();
067:
068: try {
069: adf.createLog(null);
070: fail("Did not throw IllegalArgumentException");
071: } catch (IllegalArgumentException e) {
072: // test exception?
073: }
074: }
075:
076: public void testCreateLog2() {
077: AutoDocFactory adf = createAutoDocFactory();
078:
079: AutoDocLog adl = adf.createLog(getClass());
080: assertNotNull("Must never return null.", adl);
081: }
082:
083: public void testCreateIT1() {
084: AutoDocFactory adf = createAutoDocFactory();
085:
086: try {
087: adf.createIT(null);
088: fail("Did not throw IllegalArgumentException");
089: } catch (IllegalArgumentException e) {
090: // test exception?
091: }
092: }
093:
094: public void testCreateIT2() {
095: AutoDocFactory adf = createAutoDocFactory();
096:
097: AutoDocIT ad = adf.createIT(getClass());
098: assertNotNull("Must never return null.", ad);
099: }
100:
101: public void testCreateTP1() {
102: AutoDocFactory adf = createAutoDocFactory();
103:
104: try {
105: adf.createTP(null);
106: fail("Did not throw IllegalArgumentException");
107: } catch (IllegalArgumentException e) {
108: // test exception?
109: }
110: }
111:
112: public void testCreateTP2() {
113: AutoDocFactory adf = createAutoDocFactory();
114:
115: AutoDocTP ad = adf.createTP(getClass());
116: assertNotNull("Must never return null.", ad);
117: }
118:
119: public void testHasEmptyConstructor1() throws Exception {
120: Class c = createAutoDocFactory().getClass();
121:
122: assertNotNull("Must have a no-arg constructor.", c
123: .getConstructor(new Class[0]));
124: }
125:
126: public void testHasSPI1()
127: {
128: AutoDocFactory adf = createAutoDocFactory();
129:
130: Enumeration enum = AutoDoc.getFactoryStore().
131: getSingletons();
132:
133: while (enum.hasMoreElements())
134: {
135: if (enum.nextElement().getClass().equals( adf.getClass() ))
136: {
137: // we're ok - found the class in the SPI set.
138: return;
139: }
140: }
141:
142: fail("Did not find "+adf.getClass()+" in the SPI set.");
143: }
144:
145: //-------------------------------------------------------------------------
146: // Standard JUnit declarations
147:
148: public static InterfaceTestSuite suite() {
149: InterfaceTestSuite suite = new InterfaceTestSuite(THIS_CLASS);
150:
151: return suite;
152: }
153:
154: public static void main(String[] args) {
155: String[] name = { THIS_CLASS.getName() };
156:
157: // junit.textui.TestRunner.main( name );
158: // junit.swingui.TestRunner.main( name );
159:
160: junit.textui.TestRunner.main(name);
161: }
162:
163: /**
164: *
165: * @exception Exception thrown under any exceptional condition.
166: */
167: protected void setUp() throws Exception {
168: super .setUp();
169:
170: // set ourself up
171: }
172:
173: /**
174: *
175: * @exception Exception thrown under any exceptional condition.
176: */
177: protected void tearDown() throws Exception {
178: // tear ourself down
179:
180: super.tearDown();
181: }
182: }
|