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