public abstract class AbstractTestObject extends BulkTest
Object methods and contracts.
To use, simply extend this class, and implement the makeObject() method.
If your Object fails one of these tests by design, you may still use this base set of cases. Simply
override the test case (method) your Object fails.
| Modifier and Type | Field and Description |
|---|---|
static int |
COLLECTIONS_MAJOR_VERSION
Current major release for Collections
|
| Constructor and Description |
|---|
AbstractTestObject(String testName)
JUnit constructor.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
boolean |
supportsFullCollections()
Override this method if a subclass is testing an object that cannot serialize a "full" Collection.
|
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.
|
clone, ignoredTests, makeSuite, toStringassertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runBare, runTest, setName, setUp, tearDownpublic static final int COLLECTIONS_MAJOR_VERSION
public AbstractTestObject(String testName)
testName - the test class namepublic abstract Object makeObject()
public boolean supportsEmptyCollections()
public boolean supportsFullCollections()
public boolean isTestSerialization()
public boolean isEqualsCheckable()
public void testObjectEqualsSelf()
public void testEqualsNull()
public void testObjectHashCodeEqualsSelfHashCode()
public void testObjectHashCodeEqualsContract()
public void testSerializeDeserializeThenCompare()
throws Exception
Exceptionpublic void testSimpleSerialization()
throws Exception
public void testCanonicalEmptyCollectionExists()
public void testCanonicalFullCollectionExists()
public String getCompatibilityVersion()
null if this object shouldn't be tested for compatibility with
previous versions.protected void writeExternalFormToDisk(Serializable o, String path) throws IOException
o - Object to serializepath - path to write the serialized ObjectIOExceptionprotected byte[] writeExternalFormToBytes(Serializable o) throws IOException
o - Object to convert to bytesIOExceptionprotected Object readExternalFormFromDisk(String path) throws IOException, ClassNotFoundException
path - path to the serialized ObjectIOExceptionClassNotFoundExceptionprotected Object readExternalFormFromBytes(byte[] b) throws IOException, ClassNotFoundException
b - byte array containing a serialized ObjectIOExceptionClassNotFoundExceptionprotected boolean skipSerializedCanonicalTests()
Copyright © 2015-2016 Eclipse Foundation. All Rights Reserved.