|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.gargoylesoftware.base.testing.TestUtil
public class TestUtil
Utility methods dealing with JUnit testing.
Constructor Summary | |
---|---|
private |
TestUtil()
|
Method Summary | |
---|---|
static boolean |
appearsEqual(java.lang.Object a,
java.lang.Object b)
Return true if the two objects appear to be equal. |
static void |
assertAppearsEqual(java.lang.String message,
java.lang.Object a,
java.lang.Object b)
Assert that a and b appear equal. |
static void |
assertAppearsNotEqual(java.lang.String message,
java.lang.Object a,
java.lang.Object b)
Assert that a and b do not appear equal. |
static void |
assertNotNull(java.lang.String fieldName,
java.lang.Object fieldValue)
Verify that the specified value is not null. |
private static void |
checkEquality(java.lang.Object original,
java.lang.Object copy)
Assert that the two objects are equal |
static java.lang.Object |
copyBySerialization(java.lang.Object object)
Copy an object by serializing it into a buffer and then deserializing it again. |
private static boolean |
isEqual(java.lang.Object a,
java.lang.Object b)
|
static void |
testClone(java.lang.Object object,
boolean checkEquality)
Test the clone() method on an object. |
static java.lang.Object |
testSerialization(java.lang.Object object)
Same as testSerialization(object, true). |
static java.lang.Object |
testSerialization(java.lang.Object object,
boolean checkEquality)
Serialize the specified object to a stream and then deserialize it again. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
private TestUtil()
Method Detail |
---|
public static java.lang.Object testSerialization(java.lang.Object object, boolean checkEquality) throws java.io.IOException
object
- The object to testcheckEquality
- True if the original and copy should be
equal according to the semantics of the equals() method.
java.io.IOException
- If an error occcurs during serialization.public static java.lang.Object testSerialization(java.lang.Object object) throws java.io.IOException
object
- The object to test
java.io.IOException
- If an error occcurs during serialization.public static java.lang.Object copyBySerialization(java.lang.Object object) throws java.io.IOException
object
- The original.
java.io.IOException
- If an error occcurs during serialization.public static void testClone(java.lang.Object object, boolean checkEquality) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
object
- The original object to clone.checkEquality
- True if the original and copy are to be compared
for equality after the clone().
java.lang.IllegalAccessException
- If we do not have authority to call the
clone() method.
java.lang.reflect.InvocationTargetException
- If an exception is thrown during
the processing of the clone() methodprivate static void checkEquality(java.lang.Object original, java.lang.Object copy)
original
- The original objectcopy
- The object to compare againstpublic static void assertAppearsEqual(java.lang.String message, java.lang.Object a, java.lang.Object b)
appearsEqual(Object,Object)
for an explanation of "appears"
message
- The message to display if the assert fails.a
- The first object to compareb
- The second object to comparepublic static void assertAppearsNotEqual(java.lang.String message, java.lang.Object a, java.lang.Object b)
appearsEqual(Object,Object)
for an explanation of "appears"
message
- The message to display if the assert fails.a
- The first object to compareb
- The second object to comparepublic static boolean appearsEqual(java.lang.Object a, java.lang.Object b)
This method will attempt to determine if the two objects are equal by calling all the public accessor methods on the objects and performing equals checks on the results.
If an exception is thrown during the invocation of any of the getXX() methods then that method will be ignored for the purpose of considering equality.
a
- The first object to be comparedb
- The second object to be compared
private static boolean isEqual(java.lang.Object a, java.lang.Object b)
public static final void assertNotNull(java.lang.String fieldName, java.lang.Object fieldValue) throws DetailedNullPointerException
fieldName
- The name of the field to checkfieldValue
- The value of the field to check
DetailedNullPointerException
- If fieldValue is null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |