001: /*
002: * @(#)AutoDocTPFactoryUTestI.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: import net.sourceforge.groboutils.autodoc.v1.defimpl.*;
031:
032: import java.util.Enumeration; //import net.sourceforge.groboutils.testing.junitlog.v1.*;
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: /**
041: * Tests the AutoDocTPFactory interface.
042: *
043: * @author Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
044: * @since March 27, 2002
045: * @version $Date: 2003/02/10 22:52:17 $
046: */
047: public class AutoDocTPFactoryUTestI extends InterfaceTestCase {
048: //-------------------------------------------------------------------------
049: // Standard JUnit Class-specific declarations
050:
051: private static final Class THIS_CLASS = AutoDocTPFactoryUTestI.class;
052:
053: // private static final IJUnitDocumentor LOG = (new JUnitLog(THIS_CLASS)).getDocumentor();
054:
055: public AutoDocTPFactoryUTestI(String name, ImplFactory f) {
056: super (name, AutoDocTPFactory.class, f);
057: }
058:
059: public AutoDocTPFactory createAutoDocTPFactory() {
060: return (AutoDocTPFactory) createImplObject();
061: }
062:
063: //-------------------------------------------------------------------------
064: // Tests
065:
066: public void testCreateTP1() {
067: AutoDocTPFactory adtpf = createAutoDocTPFactory();
068: try {
069: adtpf.createTP(null);
070: fail("Did not throw IllegalArgumentException");
071: } catch (IllegalArgumentException e) {
072: // check exception?
073: }
074: }
075:
076: public void testCreateTP2() {
077: AutoDocTPFactory adtpf = createAutoDocTPFactory();
078: assertNotNull("AutoDocTPFactory returned null.", adtpf
079: .createTP(THIS_CLASS));
080: }
081:
082: public void testHasEmptyConstructor1() throws Exception {
083: Class c = createAutoDocTPFactory().getClass();
084:
085: assertNotNull("Must have a no-arg constructor.", c
086: .getConstructor(new Class[0]));
087: }
088:
089: public void testHasSPI1()
090: {
091: AutoDocTPFactory adtpf = createAutoDocTPFactory();
092:
093: Enumeration enum = DefaultAutoDocFactory.getTPFactoryStore().
094: getSingletons();
095:
096: while (enum.hasMoreElements())
097: {
098: if (enum.nextElement().getClass().equals( adtpf.getClass() ))
099: {
100: // we're ok - found the class in the SPI set.
101: return;
102: }
103: }
104:
105: fail("Did not find "+adtpf.getClass()+" in the SPI set.");
106: }
107:
108: //-------------------------------------------------------------------------
109: // Standard JUnit declarations
110:
111: public static InterfaceTestSuite suite() {
112: InterfaceTestSuite suite = new InterfaceTestSuite(THIS_CLASS);
113:
114: return suite;
115: }
116:
117: public static void main(String[] args) {
118: String[] name = { THIS_CLASS.getName() };
119:
120: // junit.textui.TestRunner.main( name );
121: // junit.swingui.TestRunner.main( name );
122:
123: junit.textui.TestRunner.main(name);
124: }
125:
126: /**
127: *
128: * @exception Exception thrown under any exceptional condition.
129: */
130: protected void setUp() throws Exception {
131: super .setUp();
132:
133: // set ourself up
134: }
135:
136: /**
137: *
138: * @exception Exception thrown under any exceptional condition.
139: */
140: protected void tearDown() throws Exception {
141: // tear ourself down
142:
143: super.tearDown();
144: }
145: }
|