Save This Page
Home » commons-collections-3.2.1-src » org.apache.commons » collections » [javadoc | source]
org.apache.commons.collections
abstract public class: AbstractTestObject [javadoc | source]
java.lang.Object
   junit.framework.TestCase
      org.apache.commons.collections.BulkTest
         org.apache.commons.collections.AbstractTestObject

All Implemented Interfaces:
    Cloneable

Direct Known Subclasses:
    TestIntIterator, TestSynchronizedSet, TestSynchronizedList, TestMapValues, AbstractTestList, TestPredicatedSortedSet, TestTransformedSortedMap, TestLazyMap, AbstractTestSortedBag, TestObjectArrayListIterator2, TestIteratorCharIterator, TestSortedSetSubSet, TestBoundedFifoBuffer2, TestByteCollectionCollection, TestUnmodifiableBidiMap, TestTransformedBag, TestListIteratorFloatListIterator, AbstractTestIterator, TestUnmodifiableIterator, TestCollectionShortCollection, TestStaticBucketMap, TestDoubleIteratorIterator, TestIteratorFloatIterator, TestSingletonIterator2, TestListView, TestCaseInsensitiveMap, TestListOrderedMap2, TestHashBag, TestUnmodifiableSet, TestUnmodifiableBuffer, TestShortCollectionCollection, TestCompositeSet, TestSynchronizedBuffer, TestListOrderedSet, TestHeadMap, TestCharCollectionCollection, AbstractTestBag, TestIteratorByteIterator, TestBlockingBuffer, TestSubMap, TestMapBackedSet, TestLinkedList, TestBooleanComparator, TestShortListIteratorListIterator, TestUnmodifiableSortedSet, AbstractTestOrderedMapIterator, TestShortIteratorIterator, TestPredicatedSortedBag, TestBoundedFifoBuffer, TestTransformedSet, TestTypedSortedSet, TestSynchronizedSortedSet, TestHashedMap, TestUnmodifiableMap, TestFloatListIterator, TestUnmodifiableMapIterator, InnerTestMapIterator, TestCollectionByteCollection, TestListIteratorShortListIterator, AbstractTestOrderedMap, TestTransformedList, TestUnmodifiableOrderedMapIterator, TestByteIteratorIterator, BulkTestSubList, TestIntListIteratorListIterator, AbstractTestCollection, TestTransformedSortedBag, TestListIteratorDoubleListIterator, TestCharListIterator, TestTransformedMap, TestPredicatedSortedMap, TestCharListIteratorListIterator, AbstractTestMap, TestFloatListIteratorListIterator, AbstractTestMapIterator, TestSingletonMap, TestIdentityMap, TestListView, TestCompositeMap, TestAbstractLinkedList, TestReferenceMap, AbstractTestIterableMap, TestSynchronizedCollection, TestLongIterator, TestTypedSet, TestFixedSizeList, TestPredicatedList, TestTreeBidiMap, TestPriorityBuffer, TestIntListIterator, TestLRUMap, TestMapEntrySet, TestBidiOrderedMapIterator, TestIntIteratorIterator, TestCollectionIntCollection, TestTypedBag, TestFlatMapIterator, TestShortListIterator, TestPredicatedBuffer, TestUnmodifiableSortedBidiMap, TestDoubleListIterator, TestUnmodifiableCollection, TestListOrderedMap, TestCursorableLinkedList, TestCircularFifoBuffer, TestFixedSizeMap, TestInverseBidiMap, AbstractTestSortedSet, AbstractTestSortedBidiMap, TestListOrderedSet2, TestCollectionCharCollection, TestDoubleCollectionCollection, AbstractTestListIterator, TestIteratorIntIterator, TestDualTreeBidiMap, TestFlat3Map, TestObjectArrayIterator, TestCharIteratorIterator, TestUnboundedFifoBuffer, TestShortIterator, TestViewMap, TestListIteratorCharListIterator, TestTreeBag, TestPredicatedMap, TestDualHashBidiMap, TestObjectArrayListIterator, TestDoubleIterator, TestFloatCollectionCollection, TestSetUniqueList, TestAbstractOrderedBidiMapDecorator, TestIntCollectionCollection, TestBidiMapIterator, AbstractTestSortedMap, TestNodeCachingLinkedList, AbstractTestSet, TestUnmodifiableOrderedMap, TestLongIteratorIterator, TestCollectionLongCollection, TestCharIterator, TestMultiKeyMap, TestPredicatedBag, TestUnmodifiableList, TestReaderCharIterator, TestLongCollectionCollection, TestLinkedMap, TestCollectionFloatCollection, TestFixedSizeSortedMap, TestUnmodifiableSortedMap, TestByteIterator, TestInputStreamByteIterator, TestTypedSortedBag, TestListIteratorIntListIterator, TestListIteratorByteListIterator, TestFloatIteratorIterator, TestPredicatedSet, TestLongListIterator, TestFloatIterator, TestListIterator, TestTypedList, TestUnmodifiableListIterator, TestListIteratorLongListIterator, TestDualTreeBidiMap2, TestIteratorShortIterator, TestTransformedSortedSet, TestIteratorLongIterator, TestMapBackedSet2, TestListView, TestReferenceIdentityMap, TestMapKeySet, InnerTestOrderedMapIterator, TestIteratorDoubleIterator, TestLongListIteratorListIterator, TestTransformedCollection, TestTailMap, TestLazySortedMap, TestCollectionDoubleCollection, TestDoubleListIteratorListIterator, AbstractTestOrderedBidiMap, AbstractTestBidiMap, AbstractTestComparator, TestByteListIteratorListIterator, TestObjectGraphIterator, TestPredicatedCollection, TestByteListIterator, TestCompositeCollection, TestUnmodifiableOrderedBidiMap, TestTreeList

Abstract test class for java.lang.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
public static final  int COLLECTIONS_MAJOR_VERSION    Current major release for Collections 
Fields inherited from org.apache.commons.collections.BulkTest:
verboseName
Constructor:
 public AbstractTestObject(String testName) 
    JUnit constructor.
    Parameters:
    testName - the test class name
Method from org.apache.commons.collections.AbstractTestObject Summary:
getCanonicalEmptyCollectionName,   getCanonicalFullCollectionName,   getCompatibilityVersion,   isEqualsCheckable,   isTestSerialization,   makeObject,   readExternalFormFromBytes,   readExternalFormFromDisk,   skipSerializedCanonicalTests,   supportsEmptyCollections,   supportsFullCollections,   testCanonicalEmptyCollectionExists,   testCanonicalFullCollectionExists,   testEqualsNull,   testObjectEqualsSelf,   testObjectHashCodeEqualsContract,   testObjectHashCodeEqualsSelfHashCode,   testSerializeDeserializeThenCompare,   testSimpleSerialization,   writeExternalFormToBytes,   writeExternalFormToDisk
Methods from org.apache.commons.collections.BulkTest:
clone,   ignoredSimpleTests,   makeSuite,   toString
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.commons.collections.AbstractTestObject Detail:
 protected String getCanonicalEmptyCollectionName(Object object) 
 protected String getCanonicalFullCollectionName(Object object) 
 public String getCompatibilityVersion() 
    Get the version of Collections that this object tries to maintain serialization compatibility with. Defaults to 1, the earliest Collections version. (Note: some collections did not even exist in this version). This constant makes it possible for TestMap (and other subclasses, if necessary) to automatically check CVS for a versionX copy of a Serialized object, so we can make sure that compatibility is maintained. See, for example, TestMap.getCanonicalFullMapName(Map map). Subclasses can override this variable, indicating compatibility with earlier Collections versions.
 public boolean isEqualsCheckable() 
    Returns true to indicate that the collection supports equals() comparisons. This implementation returns true;
 public boolean isTestSerialization() 
    Is serialization testing supported. Default is true.
 abstract public Object makeObject()
    Implement this method to return the object to test.
 protected Object readExternalFormFromBytes(byte[] b) throws ClassNotFoundException, IOException 
    Read a Serialized or Externalized Object from bytes. Useful for verifying serialization in memory.
 protected Object readExternalFormFromDisk(String path) throws ClassNotFoundException, IOException 
    Reads a Serialized or Externalized Object from disk. Useful for creating compatibility tests between different CVS versions of the same class
 protected boolean skipSerializedCanonicalTests() 
 public boolean supportsEmptyCollections() 
    Override this method if a subclass is testing an object that cannot serialize an "empty" Collection. (e.g. Comparators have no contents)
 public boolean supportsFullCollections() 
    Override this method if a subclass is testing an object that cannot serialize a "full" Collection. (e.g. Comparators have no contents)
 public  void testCanonicalEmptyCollectionExists() 
    Tests serialization by comparing against a previously stored version in CVS. If the test object is serializable, confirm that a canonical form exists.
 public  void testCanonicalFullCollectionExists() 
    Tests serialization by comparing against a previously stored version in CVS. If the test object is serializable, confirm that a canonical form exists.
 public  void testEqualsNull() 
 public  void testObjectEqualsSelf() 
 public  void testObjectHashCodeEqualsContract() 
 public  void testObjectHashCodeEqualsSelfHashCode() 
 public  void testSerializeDeserializeThenCompare() throws Exception 
 public  void testSimpleSerialization() throws Exception 
    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) throws IOException 
    Converts a Serializable or Externalizable object to bytes. Useful for in-memory tests of serialization
 protected  void writeExternalFormToDisk(Serializable o,
    String path) throws IOException 
    Write a Serializable or Externalizable object as a file at the given path. NOT USEFUL as part of a unit test; this is just a utility method for creating disk-based objects in CVS that can become the basis for compatibility tests using readExternalFormFromDisk(String path)