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, confirmed
Fields inherited from class org.apache.commons.collections.AbstractTestObject
COLLECTIONS_MAJOR_VERSION
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturn theAbstractTestCollection.confirmed
fixture, but cast as a Set.getSet()
Return theAbstractTestCollection.collection
fixture, but cast as a Set.boolean
Set equals method is defined.final Collection
Makes an empty collection by invokingmakeEmptySet()
.Returns an empty Set for use in modification testing.Returns a full Set for use in modification testing.abstract Set
Makes an empty set.final Collection
Makes a full collection by invokingmakeFullSet()
.Makes a full set by first creating an empty set and then adding all the elements returned byAbstractTestCollection.getFullElements()
.void
TestsSet.equals(Object)
.void
TestsSet.hashCode()
.void
verify()
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, testUnsupportedRemove
Methods 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, writeExternalFormToDisk
Methods inherited from class org.apache.commons.collections.BulkTest
clone, ignoredTests, makeSuite, toString
Methods 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:
verify
in classAbstractTestCollection
-
isEqualsCheckable
public boolean isEqualsCheckable()Set equals method is defined.- Overrides:
isEqualsCheckable
in classAbstractTestCollection
-
makeConfirmedCollection
Returns an empty Set for use in modification testing.- Specified by:
makeConfirmedCollection
in classAbstractTestCollection
- Returns:
- a confirmed empty collection
-
makeConfirmedFullCollection
Returns a full Set for use in modification testing.- Specified by:
makeConfirmedFullCollection
in 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:
makeCollection
in classAbstractTestCollection
- Returns:
- an empty collection
-
makeFullCollection
Makes a full collection by invokingmakeFullSet()
.- Overrides:
makeFullCollection
in classAbstractTestCollection
- Returns:
- a full collection
-
getSet
Return theAbstractTestCollection.collection
fixture, but cast as a Set. -
getConfirmedSet
Return theAbstractTestCollection.confirmed
fixture, but cast as a Set. -
testSetEquals
public void testSetEquals()TestsSet.equals(Object)
. -
testSetHashCode
public void testSetHashCode()TestsSet.hashCode()
.
-