001: /*
002: * @(#)IntegrationTestCase.java
003: *
004: * Copyright (C) 2002-2004 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.junit.v1;
028:
029: import org.apache.log4j.Logger;
030: import junit.framework.TestCase;
031: import junit.framework.TestResult;
032: import junit.framework.AssertionFailedError;
033: import junit.framework.Assert;
034:
035: import java.util.Hashtable;
036:
037: /**
038: * A TestCase specific for Integration tests. It has the additional
039: * functionality of soft validation through the AssertTestFactory class.
040: *
041: * @author Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
042: * @version $Date: 2004/01/09 20:32:26 $
043: * @since March 28, 2002
044: */
045: public class IntegrationTestCase extends SubTestTestCase {
046: private AssertTestFactory atf;
047:
048: /**
049: * Standard JUnit format for test constructors (pre JUnit 3.8).
050: *
051: * @param name the name of the test case.
052: */
053: public IntegrationTestCase(String name) {
054: super (name);
055:
056: this .atf = new AssertTestFactory(getName(), true);
057: }
058:
059: //-------------------------------------------------------------------------
060: // Soft assert calls
061:
062: /**
063: * Asserts that a condtion is true. If it isn't it throws an
064: * AssertionFailedError.
065: *
066: * @param message text reported during failure.
067: * @param condition must be true or an exception is raised.
068: */
069: public void softAssertTrue(String message, boolean condition) {
070: addSubTest(this .atf.createAssertTrue(message, condition));
071: }
072:
073: /**
074: * Asserts that a condition is true. If it isn't it throws an
075: * AssertionFailedError.
076: *
077: * @param condition must be true or an exception is raised.
078: */
079: public void softAssertTrue(boolean condition) {
080: addSubTest(this .atf.createAssertTrue(condition));
081: }
082:
083: /**
084: * Asserts that a condtion is false. If it isn't it throws an
085: * AssertionFailedError.
086: *
087: * @since 03-Nov-2002
088: * @param message text reported during failure.
089: * @param condition must be false or an exception is raised.
090: */
091: public void softAssertFalse(String message, boolean condition) {
092: addSubTest(this .atf.createAssertFalse(message, condition));
093: }
094:
095: /**
096: * Asserts that a condition is false. If it isn't it throws an
097: * AssertionFailedError.
098: *
099: * @since 03-Nov-2002
100: * @param condition must be false or an exception is raised.
101: */
102: public void softAssertFalse(boolean condition) {
103: addSubTest(this .atf.createAssertFalse(condition));
104: }
105:
106: /**
107: * Fails a test with the given message.
108: *
109: * @param message text reported during failure.
110: */
111: public void softFail(String message) {
112: addSubTest(this .atf.createFail(message));
113: }
114:
115: /**
116: * Fails a test with no message.
117: */
118: public void softFail() {
119: addSubTest(this .atf.createFail());
120: }
121:
122: /**
123: * Asserts that two objects are equal (<tt>.equals()</tt>). If they
124: * are not an AssertionFailedError is thrown.
125: *
126: * @param message text reported during failure.
127: * @param expected value expected from the test.
128: * @param actual actual value generated by the test.
129: */
130: public void softAssertEquals(String message, Object expected,
131: Object actual) {
132: addSubTest(this .atf.createAssertEquals(message, expected,
133: actual));
134: }
135:
136: /**
137: * Asserts that two objects are equal. If they are not an
138: * AssertionFailedError is thrown.
139: *
140: * @param expected value expected from the test.
141: * @param actual actual value generated by the test.
142: */
143: public void softAssertEquals(Object expected, Object actual) {
144: addSubTest(this .atf.createAssertEquals(expected, actual));
145: }
146:
147: /**
148: * Asserts that two objects are equal. If they are not an
149: * AssertionFailedError is thrown.
150: *
151: * @since 03-Nov-2002
152: * @param message text reported during failure.
153: * @param expected value expected from the test.
154: * @param actual actual value generated by the test.
155: */
156: public void softAssertEquals(String message, String expected,
157: String actual) {
158: addSubTest(this .atf.createAssertEquals(message, expected,
159: actual));
160: }
161:
162: /**
163: * Asserts that two objects are equal. If they are not an
164: * AssertionFailedError is thrown.
165: *
166: * @since 03-Nov-2002
167: * @param expected value expected from the test.
168: * @param actual actual value generated by the test.
169: */
170: public void softAssertEquals(String expected, String actual) {
171: addSubTest(this .atf.createAssertEquals(expected, actual));
172: }
173:
174: /**
175: * Asserts that two doubles are equal concerning a delta. If the expected
176: * value is infinity then the delta value is ignored.
177: *
178: * @param message text reported during failure.
179: * @param expected value expected from the test.
180: * @param actual actual value generated by the test.
181: * @param delta Description of the Parameter
182: */
183: public void softAssertEquals(String message, double expected,
184: double actual, double delta) {
185: addSubTest(this .atf.createAssertEquals(message, expected,
186: actual, delta));
187: }
188:
189: /**
190: * Asserts that two doubles are equal concerning a delta. If the expected
191: * value is infinity then the delta value is ignored.
192: *
193: * @param expected value expected from the test.
194: * @param actual actual value generated by the test.
195: * @param delta Description of the Parameter
196: */
197: public void softAssertEquals(double expected, double actual,
198: double delta) {
199: addSubTest(this .atf.createAssertEquals(expected, actual, delta));
200: }
201:
202: /**
203: * Asserts that two floats are equal concerning a delta. If the expected
204: * value is infinity then the delta value is ignored.
205: *
206: * @param message text reported during failure.
207: * @param expected value expected from the test.
208: * @param actual actual value generated by the test.
209: * @param delta Description of the Parameter
210: */
211: public void softAssertEquals(String message, float expected,
212: float actual, float delta) {
213: addSubTest(this .atf.createAssertEquals(message, expected,
214: actual, delta));
215: }
216:
217: /**
218: * Asserts that two floats are equal concerning a delta. If the expected
219: * value is infinity then the delta value is ignored.
220: *
221: * @param expected value expected from the test.
222: * @param actual actual value generated by the test.
223: * @param delta Description of the Parameter
224: */
225: public void softAssertEquals(float expected, float actual,
226: float delta) {
227: addSubTest(this .atf.createAssertEquals(expected, actual, delta));
228: }
229:
230: /**
231: * Asserts that two longs are equal.
232: *
233: * @param message text reported during failure.
234: * @param expected value expected from the test.
235: * @param actual actual value generated by the test.
236: */
237: public void softAssertEquals(String message, long expected,
238: long actual) {
239: addSubTest(this .atf.createAssertEquals(message, expected,
240: actual));
241: }
242:
243: /**
244: * Asserts that two longs are equal.
245: *
246: * @param expected value expected from the test.
247: * @param actual actual value generated by the test.
248: */
249: public void softAssertEquals(long expected, long actual) {
250: addSubTest(this .atf.createAssertEquals(expected, actual));
251: }
252:
253: /**
254: * Asserts that two booleans are equal.
255: *
256: * @param message text reported during failure.
257: * @param expected value expected from the test.
258: * @param actual actual value generated by the test.
259: */
260: public void softAssertEquals(String message, boolean expected,
261: boolean actual) {
262: addSubTest(this .atf.createAssertEquals(message, expected,
263: actual));
264: }
265:
266: /**
267: * Asserts that two booleans are equal.
268: *
269: * @param expected value expected from the test.
270: * @param actual actual value generated by the test.
271: */
272: public void softAssertEquals(boolean expected, boolean actual) {
273: addSubTest(this .atf.createAssertEquals(expected, actual));
274: }
275:
276: /**
277: * Asserts that two bytes are equal.
278: *
279: * @param message text reported during failure.
280: * @param expected value expected from the test.
281: * @param actual actual value generated by the test.
282: */
283: public void softAssertEquals(String message, byte expected,
284: byte actual) {
285: addSubTest(this .atf.createAssertEquals(message, expected,
286: actual));
287: }
288:
289: /**
290: * Asserts that two bytes are equal.
291: *
292: * @param expected value expected from the test.
293: * @param actual actual value generated by the test.
294: */
295: public void softAssertEquals(byte expected, byte actual) {
296: addSubTest(this .atf.createAssertEquals(expected, actual));
297: }
298:
299: /**
300: * Asserts that two chars are equal.
301: *
302: * @param message text reported during failure.
303: * @param expected value expected from the test.
304: * @param actual actual value generated by the test.
305: */
306: public void softAssertEquals(String message, char expected,
307: char actual) {
308: addSubTest(this .atf.createAssertEquals(message, expected,
309: actual));
310: }
311:
312: /**
313: * Asserts that two chars are equal.
314: *
315: * @param expected value expected from the test.
316: * @param actual actual value generated by the test.
317: */
318: public void softAssertEquals(char expected, char actual) {
319: addSubTest(this .atf.createAssertEquals(expected, actual));
320: }
321:
322: /**
323: * Asserts that two shorts are equal.
324: *
325: * @param message text reported during failure.
326: * @param expected value expected from the test.
327: * @param actual actual value generated by the test.
328: */
329: public void softAssertEquals(String message, short expected,
330: short actual) {
331: addSubTest(this .atf.createAssertEquals(message, expected,
332: actual));
333: }
334:
335: /**
336: * Asserts that two shorts are equal.
337: *
338: * @param expected value expected from the test.
339: * @param actual actual value generated by the test.
340: */
341: public void softAssertEquals(short expected, short actual) {
342: addSubTest(this .atf.createAssertEquals(expected, actual));
343: }
344:
345: /**
346: * Asserts that two ints are equal.
347: *
348: * @param message text reported during failure.
349: * @param expected value expected from the test.
350: * @param actual actual value generated by the test.
351: */
352: public void softAssertEquals(String message, int expected,
353: int actual) {
354: addSubTest(this .atf.createAssertEquals(message, expected,
355: actual));
356: }
357:
358: /**
359: * Asserts that two ints are equal.
360: *
361: * @param expected value expected from the test.
362: * @param actual actual value generated by the test.
363: */
364: public void softAssertEquals(int expected, int actual) {
365: addSubTest(this .atf.createAssertEquals(expected, actual));
366: }
367:
368: /**
369: * Asserts that an object isn't null.
370: *
371: * @param message text reported during failure.
372: * @param object Description of the Parameter
373: */
374: public void softAssertNotNull(String message, Object object) {
375: addSubTest(this .atf.createAssertNotNull(message, object));
376: }
377:
378: /**
379: * Asserts that an object isn't null.
380: *
381: * @param object Description of the Parameter
382: */
383: public void softAssertNotNull(Object object) {
384: addSubTest(this .atf.createAssertNotNull(object));
385: }
386:
387: /**
388: * Asserts that an object is null.
389: *
390: * @param message text reported during failure.
391: * @param object Description of the Parameter
392: */
393: public void softAssertNull(String message, Object object) {
394: addSubTest(this .atf.createAssertNull(message, object));
395: }
396:
397: /**
398: * Asserts that an object is null.
399: *
400: * @param object Description of the Parameter
401: */
402: public void softAssertNull(Object object) {
403: addSubTest(this .atf.createAssertNull(object));
404: }
405:
406: /**
407: * Asserts that two objects refer to the same object. If they are not an
408: * AssertionFailedError is thrown.
409: *
410: * @param message text reported during failure.
411: * @param expected value expected from the test.
412: * @param actual actual value generated by the test.
413: */
414: public void softAssertSame(String message, Object expected,
415: Object actual) {
416: addSubTest(this .atf.createAssertSame(message, expected, actual));
417: }
418:
419: /**
420: * Asserts that two objects refer to the same object. If they are not the
421: * same an AssertionFailedError is thrown.
422: *
423: * @param expected value expected from the test.
424: * @param actual actual value generated by the test.
425: */
426: public void softAssertSame(Object expected, Object actual) {
427: addSubTest(this .atf.createAssertSame(expected, actual));
428: }
429:
430: /**
431: * Asserts that two objects refer to the same object. If they are not an
432: * AssertionFailedError is thrown.
433: *
434: * @since 03-Nov-2002
435: * @param message text reported during failure.
436: * @param expected value expected from the test.
437: * @param actual actual value generated by the test.
438: */
439: public void softAssertNotSame(String message, Object expected,
440: Object actual) {
441: addSubTest(this .atf.createAssertNotSame(message, expected,
442: actual));
443: }
444:
445: /**
446: * Asserts that two objects refer to the same object. If they are not the
447: * same an AssertionFailedError is thrown.
448: *
449: * @since 03-Nov-2002
450: * @param expected value expected from the test.
451: * @param actual actual value generated by the test.
452: */
453: public void softAssertNotSame(Object expected, Object actual) {
454: addSubTest(this.atf.createAssertNotSame(expected, actual));
455: }
456: }
|