001:/*
002: * @(#)DefaultAutoDocFactoryUTest.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.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:/**
044: * Tests the DefaultAutoDocFactory class.
045: *
046: * @author Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
047: * @version $Date: 2003/02/10 22:52:15 $
048: * @since March 27, 2002
049: */
050:public class DefaultAutoDocFactoryUTest extends TestCase
051:{
052: //-------------------------------------------------------------------------
053: // Standard JUnit Class-specific declarations
054:
055: private static final Class THIS_CLASS = DefaultAutoDocFactoryUTest.class;
056:
057: public DefaultAutoDocFactoryUTest( String name )
058: {
059: super ( name );
060: }
061:
062:
063: //-------------------------------------------------------------------------
064: // setup
065:
066: /**
067: *
068: * @exception Exception thrown under any exceptional condition.
069: */
070: protected void setUp() throws Exception
071: {
072: super .setUp();
073:
074: // set ourself up
075: }
076:
077:
078: //-------------------------------------------------------------------------
079: // Tests
080:
081:
082: public void testGetLogFactories1()
083: {
084: assertHasAtLeastOne(
085: (new DefaultAutoDocFactory()).getLogFactories(),
086: AutoDocLogFactory.class, true );
087: }
088:
089:
090: public void testGetITFactories1()
091: {
092: assertHasAtLeastOne(
093: (new DefaultAutoDocFactory()).getITFactories(),
094: AutoDocITFactory.class, false );
095: }
096:
097:
098: public void testGetTPFactories1()
099: {
100: assertHasAtLeastOne(
101: (new DefaultAutoDocFactory()).getTPFactories(),
102: AutoDocTPFactory.class, false );
103: }
104:
105:
106: public void testGetLogFactoryStore1()
107: {
108: assertNotNull(
109: "Log factory store must never be null.",
110: DefaultAutoDocFactory.getLogFactoryStore() );
111: }
112:
113:
114: public void testGetITFactoryStore1()
115: {
116: assertNotNull(
117: "IT factory store must never be null.",
118: DefaultAutoDocFactory.getITFactoryStore() );
119: }
120:
121:
122: public void testGetTPFactoryStore1()
123: {
124: assertNotNull(
125: "TP factory store must never be null.",
126: DefaultAutoDocFactory.getTPFactoryStore() );
127: }
128:
129:
130:
131: //-------------------------------------------------------------------------
132: // Helpers
133:
134:
135: protected void assertHasAtLeastOne( Enumeration enum, Class parent,
136: boolean mustHaveAtLeastOne )
137: {
138: assertNotNull(
139: "Enumeration cannot be null.",
140: enum );
141: if (mustHaveAtLeastOne)
142: {
143: assertTrue(
144: "Enumeration does not have any contents.",
145: enum.hasMoreElements() );
146: }
147:
148: while (enum.hasMoreElements())
149: {
150: Object o = enum.nextElement();
151: assertTrue(
152: "Enum contains "+o.getClass().getName()+
153: ", but is not of type "+parent.getName()+".",
154: parent.isInstance( o ) );
155: }
156: }
157:
158:
159: //-------------------------------------------------------------------------
160: // Standard JUnit declarations
161:
162:
163: public static Test suite()
164: {
165: InterfaceTestSuite suite = AutoDocFactoryUTestI.suite();
166: suite.addTestSuite( THIS_CLASS );
167: suite.addFactory( new CxFactory( "A" ) {
168: public Object createImplObject() {
169: return new DefaultAutoDocFactory();
170: }
171: } );
172:
173: return suite;
174: }
175:
176: public static void main( String[] args )
177: {
178: String[] name = { THIS_CLASS.getName() };
179:
180: // junit.textui.TestRunner.main( name );
181: // junit.swingui.TestRunner.main( name );
182:
183: junit.textui.TestRunner.main( name );
184: }
185:
186:
187: /**
188: *
189: * @exception Exception thrown under any exceptional condition.
190: */
191: protected void tearDown() throws Exception
192: {
193: // tear ourself down
194:
195: super.tearDown();
196: }
197:}
|