public class TestUtil extends Object
Modifier and Type | Method and Description |
---|---|
static boolean |
appearsEqual(Object a,
Object b)
Return true if the two objects appear to be equal.
|
static void |
assertAppearsEqual(String message,
Object a,
Object b)
Assert that a and b appear equal.
|
static void |
assertAppearsNotEqual(String message,
Object a,
Object b)
Assert that a and b do not appear equal.
|
static void |
assertNotNull(String fieldName,
Object fieldValue)
Verify that the specified value is not null.
|
static Object |
copyBySerialization(Object object)
Copy an object by serializing it into a buffer and then deserializing
it again.
|
static void |
testClone(Object object,
boolean checkEquality)
The the clone() method on an object.
|
static Object |
testSerialization(Object object)
Same as testSerialization(object, true).
|
static Object |
testSerialization(Object object,
boolean checkEquality)
Serialize the specified object to a stream and then deserialize
it again.
|
public static Object testSerialization(Object object, boolean checkEquality) throws IOException
object
- The object to testcheckEquality
- True if the original and copy should be
equal according to the semantics of the equals() method.IOException
- If an error occcurs during serialization.public static Object testSerialization(Object object) throws IOException
object
- The object to testIOException
- If an error occcurs during serialization.public static Object copyBySerialization(Object object) throws IOException
object
- The original.IOException
- If an error occcurs during serialization.public static void testClone(Object object, boolean checkEquality) throws IllegalAccessException, InvocationTargetException
object
- The original object to clone.checkEquality
- True if the original and copy are to be compared
for equality after the clone().IllegalAccessException
- If we do not have authority to call the
clone() method.InvocationTargetException
- If an exception is thrown during
the processing of the clone() methodpublic static void assertAppearsEqual(String message, Object a, 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(String message, Object a, 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(Object a, 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 comparedpublic static final void assertNotNull(String fieldName, Object fieldValue) throws DetailedNullPointerException
fieldName
- The name of the field to checkfieldValue
- The value of the field to checkDetailedNullPointerException
- If fieldValue is nullCopyright © 1998–2014 Gargoyle Software Inc.. All rights reserved.