|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
org.apache.commons.collections.BulkTest
org.apache.commons.collections.AbstractTestObject
Abstract test class for 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.
Field Summary | |
static int |
COLLECTIONS_MAJOR_VERSION
Current major release for Collections |
Constructor Summary | |
AbstractTestObject(java.lang.String testName)
JUnit constructor. |
Method Summary | |
protected java.lang.String |
getCanonicalEmptyCollectionName(java.lang.Object object)
|
protected java.lang.String |
getCanonicalFullCollectionName(java.lang.Object object)
|
java.lang.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 java.lang.Object |
makeObject()
Implement this method to return the object to test. |
protected java.lang.Object |
readExternalFormFromBytes(byte[] b)
Read a Serialized or Externalized Object from bytes. |
protected java.lang.Object |
readExternalFormFromDisk(java.lang.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(java.io.Serializable o)
Converts a Serializable or Externalizable object to bytes. |
protected void |
writeExternalFormToDisk(java.io.Serializable o,
java.lang.String path)
Write a Serializable or Externalizable object as a file at the given path. |
Methods inherited from class org.apache.commons.collections.BulkTest |
clone, ignoredTests, makeSuite, toString |
Methods inherited from class junit.framework.TestCase |
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown |
Methods inherited from class junit.framework.Assert |
assertEquals, 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, fail, fail, failNotEquals, failNotSame, failSame |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int COLLECTIONS_MAJOR_VERSION
Constructor Detail |
public AbstractTestObject(java.lang.String testName)
testName
- the test class nameMethod Detail |
public abstract java.lang.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 java.lang.Exception
java.lang.Exception
public void testSimpleSerialization() throws java.lang.Exception
java.io.IOException
java.lang.ClassNotFoundException
java.lang.Exception
public void testCanonicalEmptyCollectionExists()
public void testCanonicalFullCollectionExists()
public java.lang.String getCompatibilityVersion()
null
if this object shouldn't be
tested for compatibility with previous versions.protected java.lang.String getCanonicalEmptyCollectionName(java.lang.Object object)
protected java.lang.String getCanonicalFullCollectionName(java.lang.Object object)
protected void writeExternalFormToDisk(java.io.Serializable o, java.lang.String path) throws java.io.IOException
o
- Object to serializepath
- path to write the serialized Object
java.io.IOException
protected byte[] writeExternalFormToBytes(java.io.Serializable o) throws java.io.IOException
o
- Object to convert to bytes
java.io.IOException
protected java.lang.Object readExternalFormFromDisk(java.lang.String path) throws java.io.IOException, java.lang.ClassNotFoundException
path
- path to the serialized Object
java.io.IOException
java.lang.ClassNotFoundException
protected java.lang.Object readExternalFormFromBytes(byte[] b) throws java.io.IOException, java.lang.ClassNotFoundException
b
- byte array containing a serialized Object
java.io.IOException
java.lang.ClassNotFoundException
protected boolean skipSerializedCanonicalTests()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |