001: /*
002: * @(#)MonitorUTestI.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;
028:
029: import net.sourceforge.groboutils.autodoc.v1.*;
030:
031: //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 Monitor interface.
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:17 $
045: */
046: public class MonitorUTestI extends InterfaceTestCase {
047: //-------------------------------------------------------------------------
048: // Standard JUnit Class-specific declarations
049:
050: private static final Class THIS_CLASS = MonitorUTestI.class;
051:
052: // private static final IJUnitDocumentor LOG = (new JUnitLog(THIS_CLASS)).getDocumentor();
053:
054: public MonitorUTestI(String name, ImplFactory f) {
055: super (name, Monitor.class, f);
056: }
057:
058: public Monitor createMonitor() {
059: return (Monitor) createImplObject();
060: }
061:
062: //-------------------------------------------------------------------------
063: // Tests
064:
065: public void testAddTestData1() {
066: Monitor m = createMonitor();
067: try {
068: m.addTestData(null);
069: fail("Did not throw IllegalArgumentException");
070: } catch (IllegalArgumentException e) {
071: // check exception?
072: }
073: }
074:
075: public void testAddTestData2() {
076: Monitor m = createMonitor();
077: TestInfo ti = new DefaultTestInfo("a", "b");
078: m.addTestData(ti);
079: }
080:
081: public void testAddTestData3() {
082: Monitor m = createMonitor();
083: TestInfo ti = new DefaultTestInfo("a", "b");
084: m.addTestData(ti);
085: try {
086: m.addTestData(ti);
087: fail("Did not throw an IllegalStateException");
088: } catch (IllegalStateException e) {
089: // check exception?
090: }
091: }
092:
093: public void testGetTestData1() {
094: Monitor m = createMonitor();
095: try {
096: m.getTestData(null);
097: fail("Did not throw IllegalArgumentException");
098: } catch (IllegalArgumentException e) {
099: // check exception?
100: }
101: }
102:
103: public void testGetTestData2() {
104: Monitor m = createMonitor();
105: TestInfo ti = new DefaultTestInfo("a", "b");
106: try {
107: m.getTestData(ti);
108: fail("Did not throw IllegalStateException");
109: } catch (IllegalStateException e) {
110: // check exception?
111: }
112: }
113:
114: public void testGetTestData3() {
115: Monitor m = createMonitor();
116: TestInfo ti = new DefaultTestInfo("a", "b");
117: m.addTestData(ti);
118: TestData td = m.getTestData(ti);
119: assertNotNull("returned null on valid test info.", td);
120: assertTrue("A new get did not return the exact same object.",
121: td == m.getTestData(ti));
122: }
123:
124: public void testSendTestData1() {
125: Monitor m = createMonitor();
126: try {
127: m.sendTestData(null);
128: fail("Did not throw IllegalArgumentException");
129: } catch (IllegalArgumentException e) {
130: // check exception?
131: }
132: }
133:
134: public void testSendTestData2() {
135: Monitor m = createMonitor();
136: TestInfo ti = new DefaultTestInfo("a", "b");
137: try {
138: m.sendTestData(ti);
139: fail("Did not throw IllegalStateException");
140: } catch (IllegalStateException e) {
141: // check exception?
142: }
143: }
144:
145: public void testSendTestData3() {
146: Monitor m = createMonitor();
147: TestInfo ti = new DefaultTestInfo("a", "b");
148: m.addTestData(ti);
149: m.sendTestData(ti);
150: try {
151: m.getTestData(ti);
152: fail("Did not throw IllegalStateException");
153: } catch (IllegalStateException ise) {
154: // test exception?
155: }
156: }
157:
158: //-------------------------------------------------------------------------
159: // Standard JUnit declarations
160:
161: public static InterfaceTestSuite suite() {
162: InterfaceTestSuite suite = new InterfaceTestSuite(THIS_CLASS);
163:
164: return suite;
165: }
166:
167: public static void main(String[] args) {
168: String[] name = { THIS_CLASS.getName() };
169:
170: // junit.textui.TestRunner.main( name );
171: // junit.swingui.TestRunner.main( name );
172:
173: junit.textui.TestRunner.main(name);
174: }
175:
176: /**
177: *
178: * @exception Exception thrown under any exceptional condition.
179: */
180: protected void setUp() throws Exception {
181: super .setUp();
182:
183: // set ourself up
184: }
185:
186: /**
187: *
188: * @exception Exception thrown under any exceptional condition.
189: */
190: protected void tearDown() throws Exception {
191: // tear ourself down
192:
193: super.tearDown();
194: }
195: }
|