org.apache.commons.collections
public abstract class AbstractTestObject extends BulkTest
To use, simply extend this class, and implement the {@link #makeObject()} method.
If your {@link Object} fails one of these tests by design, you may still use this base set of cases. Simply override the test case (method) your {@link Object} fails.
| Field Summary | |
|---|---|
| static int | COLLECTIONS_MAJOR_VERSION Current major release for Collections |
| Constructor Summary | |
|---|---|
| AbstractTestObject(String testName)
JUnit constructor.
| |
| Method Summary | |
|---|---|
| protected String | getCanonicalEmptyCollectionName(Object object) |
| protected String | getCanonicalFullCollectionName(Object object) |
| String | getCompatibilityVersion()
Get the version of Collections that this object tries to
maintain serialization compatibility with. |
| boolean | isEqualsCheckable()
Returns true to indicate that the collection supports equals() comparisons.
|
| boolean | isTestSerialization()
Is serialization testing supported.
|
| abstract Object | makeObject()
Implement this method to return the object to test.
|
| protected Object | readExternalFormFromBytes(byte[] b)
Read a Serialized or Externalized Object from bytes.
|
| protected Object | readExternalFormFromDisk(String path)
Reads a Serialized or Externalized Object from disk.
|
| protected boolean | skipSerializedCanonicalTests() |
| boolean | supportsEmptyCollections()
Override this method if a subclass is testing an object
that cannot serialize an "empty" Collection.
(e.g. |
| boolean | supportsFullCollections()
Override this method if a subclass is testing an object
that cannot serialize a "full" Collection.
(e.g. |
| void | testCanonicalEmptyCollectionExists()
Tests serialization by comparing against a previously stored version in CVS.
|
| void | testCanonicalFullCollectionExists()
Tests serialization by comparing against a previously stored version in CVS.
|
| void | testEqualsNull() |
| void | testObjectEqualsSelf() |
| void | testObjectHashCodeEqualsContract() |
| void | testObjectHashCodeEqualsSelfHashCode() |
| void | testSerializeDeserializeThenCompare() |
| void | testSimpleSerialization()
Sanity check method, makes sure that any Serializable
class can be serialized and de-serialized in memory,
using the handy makeObject() method
|
| protected byte[] | writeExternalFormToBytes(Serializable o)
Converts a Serializable or Externalizable object to
bytes. |
| protected void | writeExternalFormToDisk(Serializable o, String path)
Write a Serializable or Externalizable object as
a file at the given path. |
Parameters: testName the test class name
Returns: The version, or null if this object shouldn't be
tested for compatibility with previous versions.
Returns: the object to test
Parameters: b byte array containing a serialized Object
Returns: Object contained in the bytes
Throws: IOException ClassNotFoundException
Parameters: path path to the serialized Object
Returns: the Object at the given path
Throws: IOException ClassNotFoundException
Returns: true
Returns: true
Throws: IOException ClassNotFoundException
Parameters: o Object to convert to bytes
Returns: serialized form of the Object
Throws: IOException
Parameters: o Object to serialize path path to write the serialized Object
Throws: IOException