Class AbstractTestSet
java.lang.Object
junit.framework.Assert
junit.framework.TestCase
org.apache.commons.collections.BulkTest
org.apache.commons.collections.AbstractTestObject
org.apache.commons.collections.collection.AbstractTestCollection
org.apache.commons.collections.set.AbstractTestSet
- All Implemented Interfaces:
Cloneable,junit.framework.Test
- Direct Known Subclasses:
AbstractTestMap.TestMapEntrySet,AbstractTestMap.TestMapKeySet,AbstractTestSortedSet
Abstract test class for
Set methods and contracts.
Since Set doesn't stipulate much new behavior that isn't already
found in Collection, this class basically just adds tests for
Set.equals(java.lang.Object) and Set.hashCode() along with an updated
verify() that ensures elements do not appear more than once in the
set.
To use, subclass and override the makeEmptySet()
method. You may have to override other protected methods if your
set is not modifiable, or if your set restricts what kinds of
elements may be added; see AbstractTestCollection for more details.
- Since:
- Commons Collections 3.0
-
Field Summary
Fields inherited from class org.apache.commons.collections.collection.AbstractTestCollection
collection, confirmedFields inherited from class org.apache.commons.collections.AbstractTestObject
COLLECTIONS_MAJOR_VERSION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturn theAbstractTestCollection.confirmedfixture, but cast as a Set.getSet()Return theAbstractTestCollection.collectionfixture, but cast as a Set.booleanSet equals method is defined.final CollectionMakes an empty collection by invokingmakeEmptySet().Returns an empty Set for use in modification testing.Returns a full Set for use in modification testing.abstract SetMakes an empty set.final CollectionMakes a full collection by invokingmakeFullSet().Makes a full set by first creating an empty set and then adding all the elements returned byAbstractTestCollection.getFullElements().voidTestsSet.equals(Object).voidTestsSet.hashCode().voidverify()Provides additional verifications for sets.Methods inherited from class org.apache.commons.collections.collection.AbstractTestCollection
areEqualElementsDistinguishable, cloneMapEntry, getFullElements, getFullNonNullElements, getFullNonNullStringElements, getOtherElements, getOtherNonNullElements, getOtherNonNullStringElements, isAddSupported, isFailFastSupported, isNullSupported, isRemoveSupported, makeObject, resetEmpty, resetFull, testCollectionAdd, testCollectionAddAll, testCollectionClear, testCollectionContains, testCollectionContainsAll, testCollectionIsEmpty, testCollectionIterator, testCollectionIteratorFailFast, testCollectionIteratorRemove, testCollectionRemove, testCollectionRemoveAll, testCollectionRetainAll, testCollectionSize, testCollectionToArray, testCollectionToArray2, testCollectionToString, testSerializeDeserializeThenCompare, testUnsupportedAdd, testUnsupportedRemoveMethods inherited from class org.apache.commons.collections.AbstractTestObject
getCanonicalEmptyCollectionName, getCanonicalFullCollectionName, getCompatibilityVersion, isTestSerialization, readExternalFormFromBytes, readExternalFormFromDisk, skipSerializedCanonicalTests, supportsEmptyCollections, supportsFullCollections, testCanonicalEmptyCollectionExists, testCanonicalFullCollectionExists, testEqualsNull, testObjectEqualsSelf, testObjectHashCodeEqualsContract, testObjectHashCodeEqualsSelfHashCode, 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
-
AbstractTestSet
JUnit constructor.- Parameters:
name- name for test
-
-
Method Details
-
verify
public void verify()Provides additional verifications for sets.- Overrides:
verifyin classAbstractTestCollection
-
isEqualsCheckable
public boolean isEqualsCheckable()Set equals method is defined.- Overrides:
isEqualsCheckablein classAbstractTestCollection
-
makeConfirmedCollection
Returns an empty Set for use in modification testing.- Specified by:
makeConfirmedCollectionin classAbstractTestCollection- Returns:
- a confirmed empty collection
-
makeConfirmedFullCollection
Returns a full Set for use in modification testing.- Specified by:
makeConfirmedFullCollectionin classAbstractTestCollection- Returns:
- a confirmed full collection
-
makeEmptySet
Makes an empty set. The returned set should have no elements.- Returns:
- an empty set
-
makeFullSet
Makes a full set by first creating an empty set and then adding all the elements returned byAbstractTestCollection.getFullElements(). Override if your set does not support the add operation.- Returns:
- a full set
-
makeCollection
Makes an empty collection by invokingmakeEmptySet().- Specified by:
makeCollectionin classAbstractTestCollection- Returns:
- an empty collection
-
makeFullCollection
Makes a full collection by invokingmakeFullSet().- Overrides:
makeFullCollectionin classAbstractTestCollection- Returns:
- a full collection
-
getSet
Return theAbstractTestCollection.collectionfixture, but cast as a Set. -
getConfirmedSet
Return theAbstractTestCollection.confirmedfixture, but cast as a Set. -
testSetEquals
public void testSetEquals()TestsSet.equals(Object). -
testSetHashCode
public void testSetHashCode()TestsSet.hashCode().
-