org.apache.commons.collections.set
Class AbstractTestSet
AbstractTestCollection
org.apache.commons.collections.set.AbstractTestSet
public abstract class AbstractTestSet
extends AbstractTestCollection
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
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.
AbstractTestSet
public AbstractTestSet(String name)
JUnit constructor.
getConfirmedSet
public Set getConfirmedSet()
Return the AbstractTestCollection.confirmed
fixture, but cast as a Set.
getSet
public Set getSet()
Return the AbstractTestCollection.collection
fixture, but cast as a Set.
isEqualsCheckable
public boolean isEqualsCheckable()
Set equals method is defined.
makeCollection
public final Collection makeCollection()
makeConfirmedCollection
public Collection makeConfirmedCollection()
Returns an empty Set for use in modification testing.
- a confirmed empty collection
makeConfirmedFullCollection
public Collection makeConfirmedFullCollection()
Returns a full Set for use in modification testing.
- a confirmed full collection
makeEmptySet
public abstract Set makeEmptySet()
Makes an empty set. The returned set should have no elements.
makeFullCollection
public final Collection makeFullCollection()
makeFullSet
public Set makeFullSet()
Makes a full set by first creating an empty set and then adding
all the elements returned by getFullElements()
.
Override if your set does not support the add operation.
testSetEquals
public void testSetEquals()
Tests Set.equals(Object)
.
testSetHashCode
public void testSetHashCode()
Tests Set.hashCode()
.
verify
public void verify()
Provides additional verifications for sets.
Copyright © 2001-2015 Apache Software Foundation. All Rights Reserved.