001: /*
002: * @(#)IErrorsUTestI.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.mbtf.v1;
028:
029: import org.easymock.EasyMock;
030: import org.easymock.MockControl;
031: import net.sourceforge.groboutils.junit.v1.iftc.*;
032: import junit.framework.Test;
033: import junit.framework.TestCase;
034: import junit.framework.TestSuite;
035:
036: /**
037: * Tests the IErrors interface.
038: *
039: * @author Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
040: * @since March 27, 2002
041: * @version $Date: 2003/02/10 22:52:27 $
042: */
043: public class IErrorsUTestI extends InterfaceTestCase {
044: //-------------------------------------------------------------------------
045: // Standard JUnit Class-specific declarations
046:
047: private static final Class THIS_CLASS = IErrorsUTestI.class;
048:
049: public IErrorsUTestI(String name, ImplFactory f) {
050: super (name, IErrors.class, f);
051: }
052:
053: public IErrors createIErrors() {
054: return (IErrors) createImplObject();
055: }
056:
057: //-------------------------------------------------------------------------
058: // Tests
059:
060: public void testHalt1() {
061: IErrors e = createIErrors();
062:
063: try {
064: e.halt(null);
065: fail("Did not throw TestHaltRuntimeException.");
066: } catch (TestHaltRuntimeException ex) {
067: }
068:
069: assertNotNull("Returned null error list.", e.getErrors());
070: assertEquals("Returned incorrect number of errors.", 1, e
071: .getErrors().length);
072: }
073:
074: public void testHalt2() {
075: IErrors e = createIErrors();
076:
077: try {
078: e.halt("");
079: fail("Did not throw TestHaltRuntimeException.");
080: } catch (TestHaltRuntimeException ex) {
081: }
082:
083: assertNotNull("Returned null error list.", e.getErrors());
084: assertEquals("Returned incorrect number of errors.", 1, e
085: .getErrors().length);
086: }
087:
088: public void testHalt3() {
089: IErrors e = createIErrors();
090:
091: try {
092: e.halt("a");
093: fail("Did not throw TestHaltRuntimeException.");
094: } catch (TestHaltRuntimeException ex) {
095: }
096:
097: assertNotNull("Returned null error list.", e.getErrors());
098: assertEquals("Returned incorrect number of errors.", 1, e
099: .getErrors().length);
100: }
101:
102: public void testFail1() {
103: IErrors e = createIErrors();
104:
105: try {
106: e.fail(null);
107: fail("Did not throw TestFailRuntimeException.");
108: } catch (TestFailRuntimeException ex) {
109: }
110:
111: assertNotNull("Returned null error list.", e.getErrors());
112: assertEquals("Returned incorrect number of errors.", 1, e
113: .getErrors().length);
114: }
115:
116: public void testFail2() {
117: IErrors e = createIErrors();
118:
119: try {
120: e.fail("");
121: fail("Did not throw TestFailRuntimeException.");
122: } catch (TestFailRuntimeException ex) {
123: }
124:
125: assertNotNull("Returned null error list.", e.getErrors());
126: assertEquals("Returned incorrect number of errors.", 1, e
127: .getErrors().length);
128: }
129:
130: public void testFail3() {
131: IErrors e = createIErrors();
132:
133: try {
134: e.fail("a");
135: fail("Did not throw TestFailRuntimeException.");
136: } catch (TestFailRuntimeException ex) {
137: }
138:
139: assertNotNull("Returned null error list.", e.getErrors());
140: assertEquals("Returned incorrect number of errors.", 1, e
141: .getErrors().length);
142: }
143:
144: public void testFail4() {
145: IErrors e = createIErrors();
146:
147: try {
148: e.fail(null, null);
149: fail("Did not throw TestFailRuntimeException.");
150: } catch (TestFailRuntimeException ex) {
151: }
152:
153: assertNotNull("Returned null error list.", e.getErrors());
154: assertEquals("Returned incorrect number of errors.", 1, e
155: .getErrors().length);
156: }
157:
158: public void testFail5() {
159: IErrors e = createIErrors();
160:
161: try {
162: e.fail("", null);
163: fail("Did not throw TestFailRuntimeException.");
164: } catch (TestFailRuntimeException ex) {
165: }
166:
167: assertNotNull("Returned null error list.", e.getErrors());
168: assertEquals("Returned incorrect number of errors.", 1, e
169: .getErrors().length);
170: }
171:
172: public void testFail6() {
173: IErrors e = createIErrors();
174:
175: try {
176: e.fail("a", null);
177: fail("Did not throw TestFailRuntimeException.");
178: } catch (TestFailRuntimeException ex) {
179: }
180:
181: assertNotNull("Returned null error list.", e.getErrors());
182: assertEquals("Returned incorrect number of errors.", 1, e
183: .getErrors().length);
184: }
185:
186: public void testFail7() {
187: IErrors e = createIErrors();
188:
189: try {
190: e.fail(null, new Throwable());
191: fail("Did not throw TestFailRuntimeException.");
192: } catch (TestFailRuntimeException ex) {
193: }
194:
195: assertNotNull("Returned null error list.", e.getErrors());
196: assertEquals("Returned incorrect number of errors.", 1, e
197: .getErrors().length);
198: }
199:
200: public void testFail8() {
201: IErrors e = createIErrors();
202:
203: try {
204: e.fail("", new Throwable());
205: fail("Did not throw TestFailRuntimeException.");
206: } catch (TestFailRuntimeException ex) {
207: }
208:
209: assertNotNull("Returned null error list.", e.getErrors());
210: assertEquals("Returned incorrect number of errors.", 1, e
211: .getErrors().length);
212: }
213:
214: public void testFail9() {
215: IErrors e = createIErrors();
216:
217: try {
218: e.fail("a", new Throwable());
219: fail("Did not throw TestFailRuntimeException.");
220: } catch (TestFailRuntimeException ex) {
221: }
222:
223: assertNotNull("Returned null error list.", e.getErrors());
224: assertEquals("Returned incorrect number of errors.", 1, e
225: .getErrors().length);
226: }
227:
228: public void tstAddFailure1() {
229: IErrors e = createIErrors();
230: e.addFailure(null);
231:
232: assertNotNull("Returned null error list.", e.getErrors());
233: assertEquals("Returned incorrect number of errors.", 1, e
234: .getErrors().length);
235: }
236:
237: public void tstAddFailure2() {
238: IErrors e = createIErrors();
239: e.addFailure("");
240:
241: assertNotNull("Returned null error list.", e.getErrors());
242: assertEquals("Returned incorrect number of errors.", 1, e
243: .getErrors().length);
244: }
245:
246: public void tstAddFailure3() {
247: IErrors e = createIErrors();
248: e.addFailure("a");
249:
250: assertNotNull("Returned null error list.", e.getErrors());
251: assertEquals("Returned incorrect number of errors.", 1, e
252: .getErrors().length);
253: }
254:
255: public void tstAddFailure4() {
256: IErrors e = createIErrors();
257: e.addFailure(null, null);
258:
259: assertNotNull("Returned null error list.", e.getErrors());
260: assertEquals("Returned incorrect number of errors.", 1, e
261: .getErrors().length);
262: }
263:
264: public void tstAddFailure5() {
265: IErrors e = createIErrors();
266: e.addFailure("", null);
267:
268: assertNotNull("Returned null error list.", e.getErrors());
269: assertEquals("Returned incorrect number of errors.", 1, e
270: .getErrors().length);
271: }
272:
273: public void tstAddFailure6() {
274: IErrors e = createIErrors();
275: e.addFailure("a", null);
276:
277: assertNotNull("Returned null error list.", e.getErrors());
278: assertEquals("Returned incorrect number of errors.", 1, e
279: .getErrors().length);
280: }
281:
282: public void tstAddFailure7() {
283: IErrors e = createIErrors();
284: e.addFailure(null, new Throwable());
285:
286: assertNotNull("Returned null error list.", e.getErrors());
287: assertEquals("Returned incorrect number of errors.", 1, e
288: .getErrors().length);
289: }
290:
291: public void tstAddFailure8() {
292: IErrors e = createIErrors();
293: e.addFailure("", new Throwable());
294:
295: assertNotNull("Returned null error list.", e.getErrors());
296: assertEquals("Returned incorrect number of errors.", 1, e
297: .getErrors().length);
298: }
299:
300: public void tstAddFailure9() {
301: IErrors e = createIErrors();
302: e.addFailure("a", new Throwable());
303:
304: assertNotNull("Returned null error list.", e.getErrors());
305: assertEquals("Returned incorrect number of errors.", 1, e
306: .getErrors().length);
307: }
308:
309: //-------------------------------------------------------------------------
310: // Standard JUnit declarations
311:
312: public static InterfaceTestSuite suite() {
313: InterfaceTestSuite suite = new InterfaceTestSuite(THIS_CLASS);
314:
315: return suite;
316: }
317:
318: public static void main(String[] args) {
319: String[] name = { THIS_CLASS.getName() };
320:
321: // junit.textui.TestRunner.main( name );
322: // junit.swingui.TestRunner.main( name );
323:
324: junit.textui.TestRunner.main(name);
325: }
326:
327: /**
328: *
329: * @exception Exception thrown under any exceptional condition.
330: */
331: protected void setUp() throws Exception {
332: super .setUp();
333:
334: // set ourself up
335: }
336:
337: /**
338: *
339: * @exception Exception thrown under any exceptional condition.
340: */
341: protected void tearDown() throws Exception {
342: // tear ourself down
343:
344: super.tearDown();
345: }
346: }
|