001: /*
002: * @(#)JUnitTestInfoJDK13UTest.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.testserver.junit;
028:
029: import net.sourceforge.groboutils.autodoc.v1.*;
030: import net.sourceforge.groboutils.autodoc.v1.testserver.*;
031:
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 JUnitTestInfo class.
041: *
042: * @author Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
043: * @since March 27, 2002
044: * @version $Date: 2003/02/10 22:52:18 $
045: */
046: public class JUnitTestInfoJDK13UTest extends TestCase {
047: //-------------------------------------------------------------------------
048: // Standard JUnit Class-specific declarations
049:
050: private static final Class THIS_CLASS = JUnitTestInfoJDK13UTest.class;
051:
052: public JUnitTestInfoJDK13UTest(String name) {
053: super (name);
054: }
055:
056: //-------------------------------------------------------------------------
057: // setup
058:
059: private MockControl logControl;
060: private AutoDocLog mockLog;
061:
062: private MockControl itControl;
063: private AutoDocIT mockIT;
064:
065: private MockControl tpControl;
066: private AutoDocTP mockTP;
067:
068: /**
069: *
070: * @exception Exception thrown under any exceptional condition.
071: */
072: protected void setUp() throws Exception {
073: super .setUp();
074:
075: // set ourself up
076: this .logControl = EasyMock.controlFor(AutoDocLog.class);
077: this .mockLog = (AutoDocLog) this .logControl.getMock();
078:
079: this .itControl = EasyMock.controlFor(AutoDocIT.class);
080: this .mockIT = (AutoDocIT) this .itControl.getMock();
081:
082: this .tpControl = EasyMock.controlFor(AutoDocTP.class);
083: this .mockTP = (AutoDocTP) this .tpControl.getMock();
084: }
085:
086: //-------------------------------------------------------------------------
087: // Tests
088:
089: public void testConstructor1() {
090: try {
091: new JUnitTestInfo(null);
092: fail("Did not throw IllegalArgumentException.");
093: } catch (IllegalArgumentException e) {
094: // test exception
095: }
096: }
097:
098: public void testConstructor2() {
099: JUnitTestInfo ti = new JUnitTestInfo(this );
100: assertEquals("Did not set suite name correctly.", getClass()
101: .getName(), ti.getSuite());
102: assertEquals("Did not set method name correctly.", getName(),
103: ti.getMethod());
104: }
105:
106: public void testConstructor3() {
107: String name = "myName";
108: TestSuite ts = new TestSuite();
109: ts.setName(name);
110: JUnitTestInfo ti = new JUnitTestInfo(ts);
111: assertEquals("Did not set suite name correctly.", name, ti
112: .getSuite());
113: assertEquals("Did not set method name correctly.", "run", ti
114: .getMethod());
115: }
116:
117: //-------------------------------------------------------------------------
118: // Helpers
119:
120: //-------------------------------------------------------------------------
121: // Standard JUnit declarations
122:
123: public static Test suite() {
124: InterfaceTestSuite suite = TestInfoUTestI.suite();
125: suite.addTestSuite(THIS_CLASS);
126: suite.addFactory(new CxFactory("A") {
127: public Object createImplObject() {
128: return new JUnitTestInfo(new Object());
129: }
130: });
131:
132: return suite;
133: }
134:
135: public static void main(String[] args) {
136: String[] name = { THIS_CLASS.getName() };
137:
138: // junit.textui.TestRunner.main( name );
139: // junit.swingui.TestRunner.main( name );
140:
141: junit.textui.TestRunner.main(name);
142: }
143:
144: /**
145: *
146: * @exception Exception thrown under any exceptional condition.
147: */
148: protected void tearDown() throws Exception {
149: // tear ourself down
150:
151: super.tearDown();
152: }
153: }
|