KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * @(#)AssertTestFactory.java
3  *
4  * Copyright (C) 2002-2003 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
36 /**
37  * A factory that creates test instances for the standard set of assert
38  * methods. The created test instances should have their <tt>setName()</tt>
39  * method invoked to properly set the name of the test. Alternatively, the
40  * factory instance can have the name set so that all tests will have the
41  * same name.
42  * <P>
43  * To support JUnit 3.8 functionality, but remain backwards compatible with
44  * earlier JUnit libraries, the names for the JUnit 3.8 methods will be
45  * allowed, but they will call JUnit 3.7 compatible methods.
46  * <P>
47  * As of Dec 8, 2002, the factory can uniquely (per instance) name each
48  * generated test via an index. This can help traceability in identifying
49  * each created test. Alternatively, the user can set the factory's name
50  * before invoking a create method.
51  *
52  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
53  * @version $Date: 2004/01/09 20:32:26 $
54  * @since July 26, 2002
55  */

56 public class AssertTestFactory
57 {
58     /**
59      * Inner test instance which specializes in generating a message with
60      * the test's instance's specific name.
61      */

62     public static abstract class InnerTest extends TestCase
63     {
64         private String JavaDoc message;
65         
66         /**
67          * JUnit 3.8 allows for test constructors to not have to specify
68          * a name in the super() call, but for JUnit 3.7 compatibility,
69          * we will only support the original usage.
70          */

71         public InnerTest( String JavaDoc name, String JavaDoc msg )
72         {
73             super( name );
74             this.message = msg;
75         }
76         
77         public void setMessage( String JavaDoc msg )
78         {
79             this.message = msg;
80         }
81         
82         public String JavaDoc getMessage()
83         {
84             return this.message;
85         }
86         
87         public String JavaDoc getFullMessage()
88         {
89             String JavaDoc msg = getMessage();
90             String JavaDoc name = this.getName();
91             if (name != null)
92             {
93                 msg = name + ": " + msg;
94             }
95             return msg;
96         }
97         
98         protected final void runTest()
99         {
100             callAssert( getFullMessage() );
101         }
102         
103         public abstract void callAssert( String JavaDoc message );
104     }
105     
106     
107     private String JavaDoc name;
108     private int index = 0;
109     private boolean useIndex = false;
110     
111     
112     /**
113      * Creates a new factory that can generate assertions as independent
114      * test objects.
115      */

116     public AssertTestFactory()
117     {
118         // do nothing
119
}
120     
121     
122     /**
123      * Creates a new factory with a specific name for each generated test,
124      * but will not add an index to each generated test's name.
125      *
126      * @param name default name shared by all generated assertion tests.
127      */

128     public AssertTestFactory( String JavaDoc name )
129     {
130         this( name, false );
131     }
132     
133     
134     /**
135      * Creates a new factory with a specific name for each generated test,
136      * and can optionally add an index to each generated test's name.
137      *
138      * @param name default name shared by all generated assertion tests.
139      * @param useIndexWithName <tt>true</tt> if indecies will be appended
140      * to each generated test's name, or <tt>false</tt> if they
141      * will use the passed-in name exactly.
142      * @since 08-Dec-2002
143      */

144     public AssertTestFactory( String JavaDoc name, boolean useIndexWithName )
145     {
146         setName( name );
147         setUseIndexWithName( useIndexWithName );
148     }
149     
150     
151     /**
152      * Sets the default test name. This will not reset the generated index.
153      *
154      * @param name default name shared by all generated assertion tests.
155      */

156     public void setName( String JavaDoc name )
157     {
158         this.name = name;
159     }
160     
161     
162     /**
163      * Returns the default test name. If the name has never been set, then
164      * this will return <tt>null</tt>.
165      *
166      * @return default name shared by all generated assertion tests.
167      */

168     public String JavaDoc getName()
169     {
170         return this.name;
171     }
172     
173     
174     /**
175      * Sets whether each generated test will add a unique (for this instance)
176      * index to the test's name. Reseting this value will not affect the
177      * index's value.
178      *
179      * @param useIndexWithName <tt>true</tt> if indecies will be appended
180      * to each generated test's name, or <tt>false</tt> if they
181      * will use the passed-in name exactly.
182      * @since 08-Dec-2002
183      */

184     public void setUseIndexWithName( boolean useIndexWithName )
185     {
186         this.useIndex = useIndexWithName;
187     }
188     
189     
190     /**
191      * Returns whether each generated test will add a unique (for this
192      * instance) index to the test's name.
193      *
194      * @return <tt>true</tt> if an index is appended to the name, or
195      * <tt>false</tt> if the test's name is exactly the factory's name.
196      * @since 08-Dec-2002
197      */

198     public boolean getUseIndexWithName()
199     {
200         return this.useIndex;
201     }
202     
203
204     
205     //-----------------------------------------------------------------------
206

207     private static class AssertTrue1 extends InnerTest
208     {
209         boolean condition;
210         public AssertTrue1( String JavaDoc n, String JavaDoc m, boolean c )
211         {
212             super( n, m );
213             this.condition = c;
214         }
215         public void callAssert( String JavaDoc msg )
216         {
217             Assert.assertTrue( msg, this.condition );
218         }
219     }
220     
221
222     /**
223      * Asserts that a condition is true. If it isn't it throws an
224      * AssertionFailedError with the given message.
225      *
226      * @param message message that describes what failed if the assertion
227      * fails.
228      * @param condition boolean to check for failure
229      */

230     public InnerTest createAssertTrue( String JavaDoc message, boolean condition )
231     {
232         return new AssertTrue1( getNextTestName(), message, condition );
233     }
234
235
236     /**
237      * Asserts that a condition is true. If it isn't it throws an
238      * AssertionFailedError.
239      *
240      * @param condition boolean to check for failure
241      */

242     public InnerTest createAssertTrue( boolean condition )
243     {
244         return createAssertTrue( null, condition );
245     }
246     
247
248     /**
249      * Asserts that a condition is false. If it isn't it throws an
250      * AssertionFailedError with the given message.
251      *
252      * @since 30-Oct-2002
253      * @param message message that describes what failed if the assertion
254      * fails.
255      * @param condition boolean to check for failure
256      */

257     public InnerTest createAssertFalse( String JavaDoc message, boolean condition )
258     {
259         return new AssertTrue1( getNextTestName(), message, !condition );
260     }
261
262
263     /**
264      * Asserts that a condition is true. If it isn't it throws an
265      * AssertionFailedError.
266      *
267      * @since 30-Oct-2002
268      * @param condition boolean to check for failure
269      */

270     public InnerTest createAssertFalse( boolean condition )
271     {
272         // don't 'not' the condition here - it will be done in the
273
// invoked method.
274
return createAssertFalse( null, condition );
275     }
276
277     //-----------------------------------------------------------------------
278

279     private static class Fail1 extends InnerTest
280     {
281         public Fail1( String JavaDoc n, String JavaDoc m )
282         {
283             super( n, m );
284         }
285         public void callAssert( String JavaDoc msg )
286         {
287             Assert.fail( msg );
288         }
289     }
290     
291
292     /**
293      * Fails a test with the given message.
294      *
295      * @param message message that describes what failed if the assertion
296      * fails.
297      */

298     public InnerTest createFail( String JavaDoc message )
299     {
300         return new Fail1( getNextTestName(), message );
301     }
302
303
304     /**
305      * Fails a test with no message.
306      */

307     public InnerTest createFail()
308     {
309         return createFail( null );
310     }
311
312     
313     //-----------------------------------------------------------------------
314

315     
316     private static class AssertEquals1 extends InnerTest
317     {
318         Object JavaDoc expected;
319         Object JavaDoc actual;
320         public AssertEquals1( String JavaDoc n, String JavaDoc m, Object JavaDoc e, Object JavaDoc a )
321         {
322             super( n, m );
323             this.expected = e;
324             this.actual = a;
325         }
326         public void callAssert( String JavaDoc msg )
327         {
328             Assert.assertEquals( msg, this.expected, this.actual );
329         }
330     }
331
332
333     /**
334      * Asserts that two objects are equal. If they are not an
335      * AssertionFailedError is thrown.
336      *
337      * @param message message that describes what failed if the assertion
338      * fails.
339      * @param expected value that the test expects to find from the tested
340      * code.
341      * @param actual actual value generated by tested code.
342      */

343     public InnerTest createAssertEquals( String JavaDoc message, Object JavaDoc expected,
344             Object JavaDoc actual )
345     {
346         return new AssertEquals1( getNextTestName(), message, expected, actual );
347     }
348
349
350     /**
351      * Asserts that two objects are equal. If they are not an
352      * AssertionFailedError is thrown.
353      *
354      * @param expected value that the test expects to find from the tested
355      * code.
356      * @param actual actual value generated by tested code.
357      */

358     public InnerTest createAssertEquals( Object JavaDoc expected, Object JavaDoc actual )
359     {
360         return createAssertEquals(null, expected, actual);
361     }
362
363
364     /**
365      * Asserts that two objects are equal. If they are not an
366      * AssertionFailedError is thrown.
367      *
368      * @since 30-Oct-2002
369      * @param message message that describes what failed if the assertion
370      * fails.
371      * @param expected value that the test expects to find from the tested
372      * code.
373      * @param actual actual value generated by tested code.
374      */

375     public InnerTest createAssertEquals( String JavaDoc message, String JavaDoc expected,
376             String JavaDoc actual )
377     {
378         return new AssertEquals1( getNextTestName(), message, expected, actual );
379     }
380
381
382     /**
383      * Asserts that two objects are equal. If they are not an
384      * AssertionFailedError is thrown.
385      *
386      * @since 30-Oct-2002
387      * @param expected value that the test expects to find from the tested
388      * code.
389      * @param actual actual value generated by tested code.
390      */

391     public InnerTest createAssertEquals( String JavaDoc expected, String JavaDoc actual )
392     {
393         return createAssertEquals( null, expected, actual );
394     }
395
396     //-----------------------------------------------------------------------
397

398     private static class AssertEquals2 extends InnerTest
399     {
400         double expected;
401         double actual;
402         double delta;
403         public AssertEquals2( String JavaDoc n, String JavaDoc m, double e, double a,
404                 double d )
405         {
406             super( n, m );
407             this.expected = e;
408             this.actual = a;
409             this.delta = d;
410         }
411         public void callAssert( String JavaDoc msg )
412         {
413             Assert.assertEquals( msg, this.expected, this.actual,
414                 this.delta );
415         }
416     }
417
418     
419     /**
420      * Asserts that two doubles are equal concerning a delta. If the expected
421      * value is infinity then the delta value is ignored.
422      *
423      * @param message message that describes what failed if the assertion
424      * fails.
425      * @param expected value that the test expects to find from the tested
426      * code.
427      * @param actual actual value generated by tested code.
428      * @param delta maximum distance between expected and actual such that
429      * the two values are considered equivalent. Necessary since
430      * floating-point numbers on computers are approximations of their
431      * equivalent values; that is, storing <tt>1.1</tt> may actually be
432      * stored as <tt>1.099999999999</tt>.
433      */

434     public InnerTest createAssertEquals( String JavaDoc message, double expected,
435             double actual, double delta )
436     {
437         return new AssertEquals2( getNextTestName(), message, expected, actual,
438             delta );
439     }
440
441
442     /**
443      * Asserts that two doubles are equal concerning a delta. If the expected
444      * value is infinity then the delta value is ignored.
445      *
446      * @param expected value that the test expects to find from the tested
447      * code.
448      * @param actual actual value generated by tested code.
449      * @param delta maximum distance between expected and actual such that
450      * the two values are considered equivalent. Necessary since
451      * floating-point numbers on computers are approximations of their
452      * equivalent values; that is, storing <tt>1.1</tt> may actually be
453      * stored as <tt>1.099999999999</tt>.
454      */

455     public InnerTest createAssertEquals( double expected, double actual,
456             double delta )
457     {
458         return createAssertEquals( null, expected, actual, delta );
459     }
460
461     
462     //-----------------------------------------------------------------------
463

464
465     private static class AssertEquals3 extends InnerTest
466     {
467         float expected;
468         float actual;
469         float delta;
470         public AssertEquals3( String JavaDoc n, String JavaDoc m, float e, float a, float d )
471         {
472             super( n, m );
473             this.expected = e;
474             this.actual = a;
475             this.delta = d;
476         }
477         public void callAssert( String JavaDoc msg )
478         {
479             Assert.assertEquals( msg, this.expected, this.actual,
480                 this.delta );
481         }
482     }
483
484
485     /**
486      * Asserts that two floats are equal concerning a delta. If the expected
487      * value is infinity then the delta value is ignored.
488      *
489      * @param message message that describes what failed if the assertion
490      * fails.
491      * @param expected value that the test expects to find from the tested
492      * code.
493      * @param actual actual value generated by tested code.
494      * @param delta maximum distance between expected and actual such that
495      * the two values are considered equivalent. Necessary since
496      * floating-point numbers on computers are approximations of their
497      * equivalent values; that is, storing <tt>1.1</tt> may actually be
498      * stored as <tt>1.099999999999</tt>.
499      */

500     public InnerTest createAssertEquals( String JavaDoc message, float expected,
501             float actual, float delta )
502     {
503         return new AssertEquals3( getNextTestName(), message, expected, actual,
504             delta );
505     }
506
507
508     /**
509      * Asserts that two floats are equal concerning a delta. If the expected
510      * value is infinity then the delta value is ignored.
511      *
512      * @param expected value that the test expects to find from the tested
513      * code.
514      * @param actual actual value generated by tested code.
515      * @param delta maximum distance between expected and actual such that
516      * the two values are considered equivalent. Necessary since
517      * floating-point numbers on computers are approximations of their
518      * equivalent values; that is, storing <tt>1.1</tt> may actually be
519      * stored as <tt>1.099999999999</tt>.
520      */

521     public InnerTest createAssertEquals( float expected, float actual,
522             float delta )
523     {
524         return createAssertEquals( null, expected, actual, delta );
525     }
526     
527
528     /**
529      * Asserts that two longs are equal.
530      *
531      * @param message message that describes what failed if the assertion
532      * fails.
533      * @param expected value that the test expects to find from the tested
534      * code.
535      * @param actual actual value generated by tested code.
536      */

537     public InnerTest createAssertEquals( String JavaDoc message, long expected,
538             long actual )
539     {
540         return createAssertEquals( message, new Long JavaDoc( expected ),
541             new Long JavaDoc( actual ) );
542     }
543
544
545     /**
546      * Asserts that two longs are equal.
547      *
548      * @param expected value that the test expects to find from the tested
549      * code.
550      * @param actual actual value generated by tested code.
551      */

552     public InnerTest createAssertEquals( long expected, long actual )
553     {
554         return createAssertEquals( null, expected, actual );
555     }
556
557
558     /**
559      * Asserts that two booleans are equal.
560      *
561      * @param message message that describes what failed if the assertion
562      * fails.
563      * @param expected value that the test expects to find from the tested
564      * code.
565      * @param actual actual value generated by tested code.
566      */

567     public InnerTest createAssertEquals( String JavaDoc message, boolean expected,
568             boolean actual )
569     {
570         return createAssertEquals( message, new Boolean JavaDoc( expected ),
571             new Boolean JavaDoc( actual ) );
572     }
573
574
575     /**
576      * Asserts that two booleans are equal.
577      *
578      * @param expected value that the test expects to find from the tested
579      * code.
580      * @param actual actual value generated by tested code.
581      */

582     public InnerTest createAssertEquals( boolean expected, boolean actual )
583     {
584         return createAssertEquals( null, expected, actual );
585     }
586
587
588     /**
589      * Asserts that two bytes are equal.
590      *
591      * @param message message that describes what failed if the assertion
592      * fails.
593      * @param expected value that the test expects to find from the tested
594      * code.
595      * @param actual actual value generated by tested code.
596      */

597     public InnerTest createAssertEquals( String JavaDoc message, byte expected,
598             byte actual )
599     {
600         return createAssertEquals( message, new Byte JavaDoc( expected ),
601             new Byte JavaDoc( actual ) );
602     }
603
604
605     /**
606      * Asserts that two bytes are equal.
607      *
608      * @param expected value that the test expects to find from the tested
609      * code.
610      * @param actual actual value generated by tested code.
611      */

612     public InnerTest createAssertEquals( byte expected, byte actual )
613     {
614         return createAssertEquals( null, expected, actual );
615     }
616
617
618     /**
619      * Asserts that two chars are equal.
620      *
621      * @param message message that describes what failed if the assertion
622      * fails.
623      * @param expected value that the test expects to find from the tested
624      * code.
625      * @param actual actual value generated by tested code.
626      */

627     public InnerTest createAssertEquals( String JavaDoc message, char expected,
628             char actual )
629     {
630         return createAssertEquals( message, new Character JavaDoc( expected ),
631             new Character JavaDoc( actual ) );
632     }
633
634
635     /**
636      * Asserts that two chars are equal.
637      *
638      * @param expected value that the test expects to find from the tested
639      * code.
640      * @param actual actual value generated by tested code.
641      */

642     public InnerTest createAssertEquals( char expected, char actual )
643     {
644         return createAssertEquals( null, expected, actual );
645     }
646
647
648     /**
649      * Asserts that two shorts are equal.
650      *
651      * @param message message that describes what failed if the assertion
652      * fails.
653      * @param expected value that the test expects to find from the tested
654      * code.
655      * @param actual actual value generated by tested code.
656      */

657     public InnerTest createAssertEquals( String JavaDoc message, short expected,
658             short actual )
659     {
660         return createAssertEquals( message, new Short JavaDoc( expected ),
661             new Short JavaDoc( actual ) );
662     }
663
664
665     /**
666      * Asserts that two shorts are equal.
667      *
668      * @param expected value that the test expects to find from the tested
669      * code.
670      * @param actual actual value generated by tested code.
671      */

672     public InnerTest createAssertEquals( short expected, short actual )
673     {
674         return createAssertEquals( null, expected, actual );
675     }
676
677
678     /**
679      * Asserts that two ints are equal.
680      *
681      * @param message message that describes what failed if the assertion
682      * fails.
683      * @param expected value that the test expects to find from the tested
684      * code.
685      * @param actual actual value generated by tested code.
686      */

687     public InnerTest createAssertEquals( String JavaDoc message, int expected,
688             int actual )
689     {
690         return createAssertEquals( message, new Integer JavaDoc( expected ),
691             new Integer JavaDoc( actual ) );
692     }
693
694
695     /**
696      * Asserts that two ints are equal.
697      *
698      * @param expected value that the test expects to find from the tested
699      * code.
700      * @param actual actual value generated by tested code.
701      */

702     public InnerTest createAssertEquals( int expected, int actual )
703     {
704         return createAssertEquals( null, expected, actual );
705     }
706
707     
708     //-----------------------------------------------------------------------
709

710     
711     
712     private static class AssertNotNull1 extends InnerTest
713     {
714         Object JavaDoc object;
715         public AssertNotNull1( String JavaDoc n, String JavaDoc m, Object JavaDoc o )
716         {
717             super( n, m );
718             this.object = o;
719         }
720         public void callAssert( String JavaDoc msg )
721         {
722             Assert.assertNotNull( msg, this.object );
723         }
724     }
725
726
727     /**
728      * Asserts that an object isn't null.
729      *
730      * @param message message that describes what failed if the assertion
731      * fails.
732      * @param object test object that must not be null.
733      */

734     public InnerTest createAssertNotNull( String JavaDoc message, Object JavaDoc object )
735     {
736         return new AssertNotNull1( getNextTestName(), message, object );
737     }
738
739
740     /**
741      * Asserts that an object isn't null.
742      *
743      * @param object test object that must not be null.
744      */

745     public InnerTest createAssertNotNull( Object JavaDoc object )
746     {
747         return createAssertNotNull( null, object );
748     }
749
750     
751     //-----------------------------------------------------------------------
752

753     
754     private static class AssertNull1 extends InnerTest
755     {
756         Object JavaDoc object;
757         public AssertNull1( String JavaDoc n, String JavaDoc m, Object JavaDoc o )
758         {
759             super( n, m );
760             this.object = o;
761         }
762         public void callAssert( String JavaDoc msg )
763         {
764             Assert.assertNull( msg, this.object );
765         }
766     }
767
768
769     /**
770      * Asserts that an object is null.
771      *
772      * @param message message that describes what failed if the assertion
773      * fails.
774      * @param object test object that must be null.
775      */

776     public InnerTest createAssertNull( String JavaDoc message, Object JavaDoc object )
777     {
778         return new AssertNull1( getNextTestName(), message, object );
779     }
780
781
782     /**
783      * Asserts that an object is null.
784      *
785      * @param object test object that must be null.
786      */

787     public InnerTest createAssertNull( Object JavaDoc object )
788     {
789         return createAssertNull( null, object );
790     }
791
792     
793     //-----------------------------------------------------------------------
794

795     
796     private static class AssertSame1 extends InnerTest
797     {
798         Object JavaDoc expected;
799         Object JavaDoc actual;
800         public AssertSame1( String JavaDoc n, String JavaDoc m, Object JavaDoc e, Object JavaDoc a )
801         {
802             super( n, m );
803             this.expected = e;
804             this.actual = a;
805         }
806         public void callAssert( String JavaDoc msg )
807         {
808             Assert.assertSame( msg, this.expected, this.actual );
809         }
810     }
811
812
813     /**
814      * Asserts that two objects refer to the same object. If they are not an
815      * AssertionFailedError is thrown.
816      *
817      * @param message message that describes what failed if the assertion
818      * fails.
819      * @param expected value that the test expects to find from the tested
820      * code.
821      * @param actual actual value generated by tested code.
822      */

823     public InnerTest createAssertSame( String JavaDoc message, Object JavaDoc expected,
824             Object JavaDoc actual )
825     {
826         return new AssertSame1( getNextTestName(), message, expected, actual );
827     }
828
829
830     /**
831      * Asserts that two objects refer to the same object. If they are not the
832      * same an AssertionFailedError is thrown.
833      *
834      * @param expected value that the test expects to find from the tested
835      * code.
836      * @param actual actual value generated by tested code.
837      */

838     public InnerTest createAssertSame( Object JavaDoc expected, Object JavaDoc actual )
839     {
840         return createAssertSame(null, expected, actual);
841     }
842
843
844     /**
845      * Asserts that two objects refer to the same object. If they are not an
846      * AssertionFailedError is thrown.
847      *
848      * @since 30-Oct-2002
849      * @param message message that describes what failed if the assertion
850      * fails.
851      * @param expected value that the test expects to not find from the tested
852      * code.
853      * @param actual actual value generated by tested code.
854      */

855     public InnerTest createAssertNotSame( String JavaDoc message, Object JavaDoc expected,
856             Object JavaDoc actual )
857     {
858         String JavaDoc str = "expected not same";
859         if (message != null)
860         {
861             str = message + ' ' + str;
862         }
863         // manual emulation of JUnit 3.8 functionality
864
return new AssertTrue1( getNextTestName(),
865             str, expected != actual );
866     }
867
868
869     /**
870      * Asserts that two objects refer to the same object. If they are not the
871      * same an AssertionFailedError is thrown.
872      *
873      * @since 30-Oct-2002
874      * @param expected value that the test expects to not find from the tested
875      * code.
876      * @param actual actual value generated by tested code.
877      */

878     public InnerTest createAssertNotSame( Object JavaDoc expected, Object JavaDoc actual )
879     {
880         return createAssertNotSame( null, expected, actual );
881     }
882     
883     
884     /**
885      * Generates the next test's name.
886      *
887      * @return the next name for a generated test, possibly appending an
888      * index value.
889      * @since 08-Dec-2002
890      */

891     private String JavaDoc getNextTestName()
892     {
893         String JavaDoc n = getName();
894         if (this.useIndex)
895         {
896             synchronized( this )
897             {
898                 ++this.index;
899                 n += this.index;
900             }
901         }
902         return n;
903     }
904 }
905
906
Popular Tags