KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > groboutils > junit > v1 > IntegrationTestCase


1 /*
2  * @(#)IntegrationTestCase.java
3  *
4  * Copyright (C) 2002-2004 Matt Albrecht
5  * groboclown@users.sourceforge.net
6  * http://groboutils.sourceforge.net
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation
11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12  * and/or sell copies of the Software, and to permit persons to whom the
13  * Software is furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24  * DEALINGS IN THE SOFTWARE.
25  */

26
27 package net.sourceforge.groboutils.junit.v1;
28
29 import org.apache.log4j.Logger;
30 import junit.framework.TestCase;
31 import junit.framework.TestResult;
32 import junit.framework.AssertionFailedError;
33 import junit.framework.Assert;
34
35 import java.util.Hashtable JavaDoc;
36
37
38 /**
39  * A TestCase specific for Integration tests. It has the additional
40  * functionality of soft validation through the AssertTestFactory class.
41  *
42  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
43  * @version $Date: 2004/01/09 20:32:26 $
44  * @since March 28, 2002
45  */

46 public class IntegrationTestCase extends SubTestTestCase
47 {
48     private AssertTestFactory atf;
49     
50     
51     /**
52      * Standard JUnit format for test constructors (pre JUnit 3.8).
53      *
54      * @param name the name of the test case.
55      */

56     public IntegrationTestCase( String JavaDoc name )
57     {
58         super( name );
59         
60         this.atf = new AssertTestFactory( getName(), true );
61     }
62     
63     
64     //-------------------------------------------------------------------------
65
// Soft assert calls
66

67     /**
68      * Asserts that a condtion is true. If it isn't it throws an
69      * AssertionFailedError.
70      *
71      * @param message text reported during failure.
72      * @param condition must be true or an exception is raised.
73      */

74     public void softAssertTrue(String JavaDoc message, boolean condition)
75     {
76         addSubTest( this.atf.createAssertTrue( message, condition ) );
77     }
78
79
80     /**
81      * Asserts that a condition is true. If it isn't it throws an
82      * AssertionFailedError.
83      *
84      * @param condition must be true or an exception is raised.
85      */

86     public void softAssertTrue(boolean condition)
87     {
88         addSubTest( this.atf.createAssertTrue( condition ) );
89     }
90     
91     
92     /**
93      * Asserts that a condtion is false. If it isn't it throws an
94      * AssertionFailedError.
95      *
96      * @since 03-Nov-2002
97      * @param message text reported during failure.
98      * @param condition must be false or an exception is raised.
99      */

100     public void softAssertFalse(String JavaDoc message, boolean condition)
101     {
102         addSubTest( this.atf.createAssertFalse( message, condition ) );
103     }
104
105
106     /**
107      * Asserts that a condition is false. If it isn't it throws an
108      * AssertionFailedError.
109      *
110      * @since 03-Nov-2002
111      * @param condition must be false or an exception is raised.
112      */

113     public void softAssertFalse(boolean condition)
114     {
115         addSubTest( this.atf.createAssertFalse( condition ) );
116     }
117     
118
119     /**
120      * Fails a test with the given message.
121      *
122      * @param message text reported during failure.
123      */

124     public void softFail(String JavaDoc message)
125     {
126         addSubTest( this.atf.createFail( message ) );
127     }
128
129
130     /**
131      * Fails a test with no message.
132      */

133     public void softFail()
134     {
135         addSubTest( this.atf.createFail() );
136     }
137
138
139     /**
140      * Asserts that two objects are equal (<tt>.equals()</tt>). If they
141      * are not an AssertionFailedError is thrown.
142      *
143      * @param message text reported during failure.
144      * @param expected value expected from the test.
145      * @param actual actual value generated by the test.
146      */

147     public void softAssertEquals(String JavaDoc message, Object JavaDoc expected, Object JavaDoc actual)
148     {
149         addSubTest( this.atf.createAssertEquals( message, expected, actual ) );
150     }
151
152
153     /**
154      * Asserts that two objects are equal. If they are not an
155      * AssertionFailedError is thrown.
156      *
157      * @param expected value expected from the test.
158      * @param actual actual value generated by the test.
159      */

160     public void softAssertEquals(Object JavaDoc expected, Object JavaDoc actual)
161     {
162         addSubTest( this.atf.createAssertEquals( expected, actual ) );
163     }
164
165
166     /**
167      * Asserts that two objects are equal. If they are not an
168      * AssertionFailedError is thrown.
169      *
170      * @since 03-Nov-2002
171      * @param message text reported during failure.
172      * @param expected value expected from the test.
173      * @param actual actual value generated by the test.
174      */

175     public void softAssertEquals(String JavaDoc message, String JavaDoc expected, String JavaDoc actual)
176     {
177         addSubTest( this.atf.createAssertEquals( message, expected, actual ) );
178     }
179
180
181     /**
182      * Asserts that two objects are equal. If they are not an
183      * AssertionFailedError is thrown.
184      *
185      * @since 03-Nov-2002
186      * @param expected value expected from the test.
187      * @param actual actual value generated by the test.
188      */

189     public void softAssertEquals(String JavaDoc expected, String JavaDoc actual)
190     {
191         addSubTest( this.atf.createAssertEquals( expected, actual ) );
192     }
193
194     
195     /**
196      * Asserts that two doubles are equal concerning a delta. If the expected
197      * value is infinity then the delta value is ignored.
198      *
199      * @param message text reported during failure.
200      * @param expected value expected from the test.
201      * @param actual actual value generated by the test.
202      * @param delta Description of the Parameter
203      */

204     public void softAssertEquals(String JavaDoc message, double expected,
205             double actual, double delta)
206     {
207         addSubTest( this.atf.createAssertEquals( message, expected, actual,
208             delta ) );
209     }
210
211
212     /**
213      * Asserts that two doubles are equal concerning a delta. If the expected
214      * value is infinity then the delta value is ignored.
215      *
216      * @param expected value expected from the test.
217      * @param actual actual value generated by the test.
218      * @param delta Description of the Parameter
219      */

220     public void softAssertEquals(double expected, double actual, double delta)
221     {
222         addSubTest( this.atf.createAssertEquals( expected, actual, delta ) );
223     }
224
225
226     /**
227      * Asserts that two floats are equal concerning a delta. If the expected
228      * value is infinity then the delta value is ignored.
229      *
230      * @param message text reported during failure.
231      * @param expected value expected from the test.
232      * @param actual actual value generated by the test.
233      * @param delta Description of the Parameter
234      */

235     public void softAssertEquals(String JavaDoc message, float expected, float actual,
236             float delta)
237     {
238         addSubTest( this.atf.createAssertEquals( message, expected, actual,
239             delta ) );
240     }
241
242
243     /**
244      * Asserts that two floats are equal concerning a delta. If the expected
245      * value is infinity then the delta value is ignored.
246      *
247      * @param expected value expected from the test.
248      * @param actual actual value generated by the test.
249      * @param delta Description of the Parameter
250      */

251     public void softAssertEquals(float expected, float actual, float delta)
252     {
253         addSubTest( this.atf.createAssertEquals( expected, actual, delta ) );
254     }
255     
256
257     /**
258      * Asserts that two longs are equal.
259      *
260      * @param message text reported during failure.
261      * @param expected value expected from the test.
262      * @param actual actual value generated by the test.
263      */

264     public void softAssertEquals(String JavaDoc message, long expected, long actual)
265     {
266         addSubTest( this.atf.createAssertEquals( message, expected, actual ) );
267     }
268
269
270     /**
271      * Asserts that two longs are equal.
272      *
273      * @param expected value expected from the test.
274      * @param actual actual value generated by the test.
275      */

276     public void softAssertEquals(long expected, long actual)
277     {
278         addSubTest( this.atf.createAssertEquals( expected, actual ) );
279     }
280
281
282     /**
283      * Asserts that two booleans are equal.
284      *
285      * @param message text reported during failure.
286      * @param expected value expected from the test.
287      * @param actual actual value generated by the test.
288      */

289     public void softAssertEquals(String JavaDoc message, boolean expected,
290             boolean actual)
291     {
292         addSubTest( this.atf.createAssertEquals( message, expected, actual ) );
293     }
294
295
296     /**
297      * Asserts that two booleans are equal.
298      *
299      * @param expected value expected from the test.
300      * @param actual actual value generated by the test.
301      */

302     public void softAssertEquals(boolean expected, boolean actual)
303     {
304         addSubTest( this.atf.createAssertEquals( expected, actual ) );
305     }
306
307
308     /**
309      * Asserts that two bytes are equal.
310      *
311      * @param message text reported during failure.
312      * @param expected value expected from the test.
313      * @param actual actual value generated by the test.
314      */

315     public void softAssertEquals(String JavaDoc message, byte expected, byte actual)
316     {
317         addSubTest( this.atf.createAssertEquals( message, expected, actual ) );
318     }
319
320
321     /**
322      * Asserts that two bytes are equal.
323      *
324      * @param expected value expected from the test.
325      * @param actual actual value generated by the test.
326      */

327     public void softAssertEquals(byte expected, byte actual)
328     {
329         addSubTest( this.atf.createAssertEquals( expected, actual ) );
330     }
331
332
333     /**
334      * Asserts that two chars are equal.
335      *
336      * @param message text reported during failure.
337      * @param expected value expected from the test.
338      * @param actual actual value generated by the test.
339      */

340     public void softAssertEquals(String JavaDoc message, char expected, char actual)
341     {
342         addSubTest( this.atf.createAssertEquals( message, expected, actual ) );
343     }
344
345
346     /**
347      * Asserts that two chars are equal.
348      *
349      * @param expected value expected from the test.
350      * @param actual actual value generated by the test.
351      */

352     public void softAssertEquals(char expected, char actual)
353     {
354         addSubTest( this.atf.createAssertEquals( expected, actual ) );
355     }
356
357
358     /**
359      * Asserts that two shorts are equal.
360      *
361      * @param message text reported during failure.
362      * @param expected value expected from the test.
363      * @param actual actual value generated by the test.
364      */

365     public void softAssertEquals(String JavaDoc message, short expected, short actual)
366     {
367         addSubTest( this.atf.createAssertEquals( message, expected, actual ) );
368     }
369
370
371     /**
372      * Asserts that two shorts are equal.
373      *
374      * @param expected value expected from the test.
375      * @param actual actual value generated by the test.
376      */

377     public void softAssertEquals(short expected, short actual)
378     {
379         addSubTest( this.atf.createAssertEquals( expected, actual ) );
380     }
381
382
383     /**
384      * Asserts that two ints are equal.
385      *
386      * @param message text reported during failure.
387      * @param expected value expected from the test.
388      * @param actual actual value generated by the test.
389      */

390     public void softAssertEquals(String JavaDoc message, int expected, int actual)
391     {
392         addSubTest( this.atf.createAssertEquals( message, expected, actual ) );
393     }
394
395
396     /**
397      * Asserts that two ints are equal.
398      *
399      * @param expected value expected from the test.
400      * @param actual actual value generated by the test.
401      */

402     public void softAssertEquals(int expected, int actual)
403     {
404         addSubTest( this.atf.createAssertEquals( expected, actual ) );
405     }
406
407
408     /**
409      * Asserts that an object isn't null.
410      *
411      * @param message text reported during failure.
412      * @param object Description of the Parameter
413      */

414     public void softAssertNotNull(String JavaDoc message, Object JavaDoc object)
415     {
416         addSubTest( this.atf.createAssertNotNull( message, object ) );
417     }
418
419
420     /**
421      * Asserts that an object isn't null.
422      *
423      * @param object Description of the Parameter
424      */

425     public void softAssertNotNull(Object JavaDoc object)
426     {
427         addSubTest( this.atf.createAssertNotNull( object ) );
428     }
429
430
431     /**
432      * Asserts that an object is null.
433      *
434      * @param message text reported during failure.
435      * @param object Description of the Parameter
436      */

437     public void softAssertNull(String JavaDoc message, Object JavaDoc object)
438     {
439         addSubTest( this.atf.createAssertNull( message, object ) );
440     }
441
442
443     /**
444      * Asserts that an object is null.
445      *
446      * @param object Description of the Parameter
447      */

448     public void softAssertNull(Object JavaDoc object)
449     {
450         addSubTest( this.atf.createAssertNull( object ) );
451     }
452
453
454     /**
455      * Asserts that two objects refer to the same object. If they are not an
456      * AssertionFailedError is thrown.
457      *
458      * @param message text reported during failure.
459      * @param expected value expected from the test.
460      * @param actual actual value generated by the test.
461      */

462     public void softAssertSame(String JavaDoc message, Object JavaDoc expected, Object JavaDoc actual)
463     {
464         addSubTest( this.atf.createAssertSame( message, expected, actual ) );
465     }
466
467
468     /**
469      * Asserts that two objects refer to the same object. If they are not the
470      * same an AssertionFailedError is thrown.
471      *
472      * @param expected value expected from the test.
473      * @param actual actual value generated by the test.
474      */

475     public void softAssertSame(Object JavaDoc expected, Object JavaDoc actual)
476     {
477         addSubTest( this.atf.createAssertSame( expected, actual ) );
478     }
479     
480
481     /**
482      * Asserts that two objects refer to the same object. If they are not an
483      * AssertionFailedError is thrown.
484      *
485      * @since 03-Nov-2002
486      * @param message text reported during failure.
487      * @param expected value expected from the test.
488      * @param actual actual value generated by the test.
489      */

490     public void softAssertNotSame(String JavaDoc message, Object JavaDoc expected, Object JavaDoc actual)
491     {
492         addSubTest( this.atf.createAssertNotSame( message, expected, actual ) );
493     }
494
495
496     /**
497      * Asserts that two objects refer to the same object. If they are not the
498      * same an AssertionFailedError is thrown.
499      *
500      * @since 03-Nov-2002
501      * @param expected value expected from the test.
502      * @param actual actual value generated by the test.
503      */

504     public void softAssertNotSame(Object JavaDoc expected, Object JavaDoc actual)
505     {
506         addSubTest( this.atf.createAssertNotSame( expected, actual ) );
507     }
508 }
509
510
Popular Tags