org.apache.commons.collections.set
public abstract class AbstractTestSet extends AbstractTestCollection
Since {@link Set} doesn't stipulate much new behavior that isn't already found in {@link Collection}, this class basically just adds tests for {@link Set#equals} and {@link Set#hashCode()} along with an updated {@link #verify()} that ensures elements do not appear more than once in the set.
To use, subclass and override the {@link #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 {@link AbstractTestCollection} for more details.
Since: Commons Collections 3.0
Constructor Summary | |
---|---|
AbstractTestSet(String name)
JUnit constructor.
|
Method Summary | |
---|---|
Set | getConfirmedSet()
Return the {@link AbstractTestCollection#confirmed} fixture, but cast as a Set. |
Set | getSet()
Return the {@link AbstractTestCollection#collection} fixture, but cast as a Set. |
boolean | isEqualsCheckable()
Set equals method is defined. |
Collection | makeCollection()
Makes an empty collection by invoking {@link #makeEmptySet()}.
|
Collection | makeConfirmedCollection()
Returns an empty Set for use in modification testing.
|
Collection | makeConfirmedFullCollection()
Returns a full Set for use in modification testing.
|
abstract Set | makeEmptySet()
Makes an empty set. |
Collection | makeFullCollection()
Makes a full collection by invoking {@link #makeFullSet()}.
|
Set | makeFullSet()
Makes a full set by first creating an empty set and then adding
all the elements returned by {@link #getFullElements()}.
|
void | testSetEquals()
Tests {@link Set#equals(Object)}. |
void | testSetHashCode()
Tests {@link Set#hashCode()}. |
void | verify()
Provides additional verifications for sets. |
Parameters: name name for test
Returns: an empty collection
Returns: a confirmed empty collection
Returns: a confirmed full collection
Returns: an empty set
Returns: a full collection
Returns: a full set