Class AbstractTestComparator
java.lang.Object
junit.framework.Assert
junit.framework.TestCase
org.apache.commons.collections.BulkTest
org.apache.commons.collections.AbstractTestObject
org.apache.commons.collections.comparators.AbstractTestComparator
- All Implemented Interfaces:
Cloneable,junit.framework.Test
Abstract test class for testing the Comparator interface.
Concrete subclasses declare the comparator to be tested. They also declare certain aspects of the tests.
-
Field Summary
Fields inherited from class org.apache.commons.collections.AbstractTestObject
COLLECTIONS_MAJOR_VERSION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetCanonicalComparatorName(Object object) abstract ListImplement this method to return a list of sorted objects.Overrides superclass to set the compatability to version 2 as there were no Comparators in version 1.x.abstract ComparatorImplement this method to return the comparator to test.Implements the abstract superclass method to return the comparator.protected voidrandomizeObjects(List list) Randomize the list.protected voidreverseObjects(List list) Reverse the list.protected voidsortObjects(List list, Comparator comparator) Sort the list.booleanOverrides superclass to block tests.booleanOverrides superclass to block tests.voidCompare the current serialized form of the Comparator against the canonical version in CVS.voidNearly all Comparators should be Serializable.voidTest sorting an empty listvoidTest sorting a random list.voidTest sorting a reversed list.Methods inherited from class org.apache.commons.collections.AbstractTestObject
getCanonicalEmptyCollectionName, getCanonicalFullCollectionName, isEqualsCheckable, isTestSerialization, readExternalFormFromBytes, readExternalFormFromDisk, skipSerializedCanonicalTests, testCanonicalEmptyCollectionExists, testCanonicalFullCollectionExists, testEqualsNull, testObjectEqualsSelf, testObjectHashCodeEqualsContract, testObjectHashCodeEqualsSelfHashCode, testSerializeDeserializeThenCompare, testSimpleSerialization, writeExternalFormToBytes, writeExternalFormToDiskMethods inherited from class org.apache.commons.collections.BulkTest
clone, ignoredTests, makeSuite, toStringMethods inherited from class junit.framework.TestCase
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, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runBare, runTest, setName, setUp, tearDown
-
Constructor Details
-
AbstractTestComparator
JUnit constructor.- Parameters:
testName- the test class name
-
-
Method Details
-
makeComparator
Implement this method to return the comparator to test.- Returns:
- the comparator to test
-
getComparableObjectsOrdered
Implement this method to return a list of sorted objects.- Returns:
- sorted objects
-
makeObject
Implements the abstract superclass method to return the comparator.- Specified by:
makeObjectin classAbstractTestObject- Returns:
- a full iterator
-
supportsEmptyCollections
public boolean supportsEmptyCollections()Overrides superclass to block tests.- Overrides:
supportsEmptyCollectionsin classAbstractTestObject- Returns:
- true
-
supportsFullCollections
public boolean supportsFullCollections()Overrides superclass to block tests.- Overrides:
supportsFullCollectionsin classAbstractTestObject- Returns:
- true
-
getCompatibilityVersion
Overrides superclass to set the compatability to version 2 as there were no Comparators in version 1.x.- Overrides:
getCompatibilityVersionin classAbstractTestObject- Returns:
- The version, or
nullif this object shouldn't be tested for compatibility with previous versions.
-
reverseObjects
Reverse the list. -
randomizeObjects
Randomize the list. -
sortObjects
Sort the list. -
testEmptyListSort
public void testEmptyListSort()Test sorting an empty list -
testReverseListSort
public void testReverseListSort()Test sorting a reversed list. -
testRandomListSort
public void testRandomListSort()Test sorting a random list. -
testComparatorIsSerializable
public void testComparatorIsSerializable()Nearly all Comparators should be Serializable. -
getCanonicalComparatorName
-
testComparatorCompatibility
Compare the current serialized form of the Comparator against the canonical version in CVS.- Throws:
IOExceptionClassNotFoundException
-