org.apache.commons.collections.comparators

Class AbstractTestComparator

public abstract class AbstractTestComparator extends AbstractTestObject

Abstract test class for testing the Comparator interface.

Concrete subclasses declare the comparator to be tested. They also declare certain aspects of the tests.

Constructor Summary
AbstractTestComparator(String testName)
JUnit constructor.
Method Summary
StringgetCanonicalComparatorName(Object object)
abstract ListgetComparableObjectsOrdered()
Implement this method to return a list of sorted objects.
StringgetCompatibilityVersion()
Overrides superclass to set the compatability to version 2 as there were no Comparators in version 1.x.
abstract ComparatormakeComparator()
Implement this method to return the comparator to test.
ObjectmakeObject()
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.
booleansupportsEmptyCollections()
Overrides superclass to block tests.
booleansupportsFullCollections()
Overrides superclass to block tests.
voidtestComparatorCompatibility()
Compare the current serialized form of the Comparator against the canonical version in CVS.
voidtestComparatorIsSerializable()
Nearly all Comparators should be Serializable.
voidtestEmptyListSort()
Test sorting an empty list
voidtestRandomListSort()
Test sorting a random list.
voidtestReverseListSort()
Test sorting a reversed list.

Constructor Detail

AbstractTestComparator

public AbstractTestComparator(String testName)
JUnit constructor.

Parameters: testName the test class name

Method Detail

getCanonicalComparatorName

public String getCanonicalComparatorName(Object object)

getComparableObjectsOrdered

public abstract List getComparableObjectsOrdered()
Implement this method to return a list of sorted objects.

Returns: sorted objects

getCompatibilityVersion

public String getCompatibilityVersion()
Overrides superclass to set the compatability to version 2 as there were no Comparators in version 1.x.

makeComparator

public abstract Comparator makeComparator()
Implement this method to return the comparator to test.

Returns: the comparator to test

makeObject

public Object makeObject()
Implements the abstract superclass method to return the comparator.

Returns: a full iterator

randomizeObjects

protected void randomizeObjects(List list)
Randomize the list.

reverseObjects

protected void reverseObjects(List list)
Reverse the list.

sortObjects

protected void sortObjects(List list, Comparator comparator)
Sort the list.

supportsEmptyCollections

public boolean supportsEmptyCollections()
Overrides superclass to block tests.

supportsFullCollections

public boolean supportsFullCollections()
Overrides superclass to block tests.

testComparatorCompatibility

public void testComparatorCompatibility()
Compare the current serialized form of the Comparator against the canonical version in CVS.

testComparatorIsSerializable

public void testComparatorIsSerializable()
Nearly all Comparators should be Serializable.

testEmptyListSort

public void testEmptyListSort()
Test sorting an empty list

testRandomListSort

public void testRandomListSort()
Test sorting a random list.

testReverseListSort

public void testReverseListSort()
Test sorting a reversed list.
Copyright © 2001-2009 Apache Software Foundation. All Rights Reserved.