View Javadoc

1   /*
2    * <cvs:source>$Source: /devel/astrogrid/community/common/src/java/org/astrogrid/community/common/junit/JUnitTestBase.java,v $</cvs:source>
3    * <cvs:author>$Author: dave $</cvs:author>
4    * <cvs:date>$Date: 2004/06/18 13:45:20 $</cvs:date>
5    * <cvs:version>$Revision: 1.3 $</cvs:version>
6    *
7    * <cvs:log>
8    *   $Log: JUnitTestBase.java,v $
9    *   Revision 1.3  2004/06/18 13:45:20  dave
10   *   Merged development branch, dave-dev-200406081614, into HEAD
11   *
12   *   Revision 1.2.54.2  2004/06/17 14:50:01  dave
13   *   Removed unused imports (PMD report).
14   *
15   *   Revision 1.2.54.1  2004/06/17 13:38:58  dave
16   *   Tidied up old CVS log entries
17   *
18   * </cvs:log>
19   *
20   */
21  package org.astrogrid.community.common.junit ;
22  
23  import junit.framework.TestCase ;
24  
25  /***
26   * Base class for our data object JUnit tests.
27   *
28   */
29  public class JUnitTestBase
30      extends TestCase
31      {
32  
33      /***
34       * Test that two objects are equal.
35       *
36       */
37      public void checkEqual(String message, Object a, Object b)
38          {
39          //
40          // Check one way.
41          assertEquals(message, a, b) ;
42          //
43          // Check the other way.
44          assertEquals(message, b, a) ;
45          }
46  
47      /***
48       * Test that two objects are not equal.
49       * Throws 
50       *
51       */
52      public void checkNotEqual(String message, Object a, Object b)
53          {
54          //
55          // Check that they are not the same object.
56          //assertNotSame(message, a, b) ;
57          //
58          // Check that they are not both null.
59          assertFalse(message, (a == b)) ;
60          //
61          // If a is not null.
62          if (null != a)
63              {
64              //
65              // Check that a does not equal b.
66              assertFalse(message, a.equals(b)) ;
67              }
68          //
69          // If b is not null.
70          if (null != b)
71              {
72              //
73              // Check that b does not equal a.
74              assertFalse(message, b.equals(a)) ;
75              }
76          }
77      }