|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
com.google.common.collect.testing.AbstractTester<OneSizeTestContainerGenerator<C,E>>
com.google.common.collect.testing.AbstractContainerTester<C,E>
C
- the type of the containerE
- the type of the container's contents@GwtCompatible public abstract class AbstractContainerTester<C,E>
Base class for testers of classes (including Collection
and Map
) that contain elements.
This class is GWT compatible.
Nested Class Summary | |
---|---|
static class |
AbstractContainerTester.ArrayWithDuplicate<E>
|
Field Summary | |
---|---|
protected C |
container
|
protected SampleElements<E> |
samples
|
Constructor Summary | |
---|---|
AbstractContainerTester()
|
Method Summary | |
---|---|
protected abstract Collection<E> |
actualContents()
|
protected AbstractContainerTester.ArrayWithDuplicate<E> |
createArrayWithDuplicateElement()
|
protected MinimalCollection<E> |
createDisjointCollection()
|
protected E[] |
createSamplesArray()
|
protected MinimalCollection<E> |
emptyCollection()
|
protected void |
expectAdded(E... elements)
Asserts that the collection under test contains exactly the elements it was initialized with plus the given elements, according to expectContents(java.util.Collection) . |
protected void |
expectAdded(int index,
Collection<E> elements)
|
protected void |
expectAdded(int index,
E... elements)
|
protected void |
expectContents(Collection<E> expected)
Asserts that the collection under test contains exactly the given elements, respecting cardinality but not order. |
protected void |
expectContents(E... elements)
|
protected void |
expectMissing(E... elements)
|
protected void |
expectUnchanged()
|
protected int |
getNullLocation()
|
protected int |
getNumElements()
|
protected List<E> |
getOrderedElements()
Returns the sample elements as ordered by TestContainerGenerator.order(List) . |
protected Collection<E> |
getSampleElements()
|
protected Collection<E> |
getSampleElements(int howMany)
|
protected C |
resetContainer()
Replaces the existing container under test with a new container created by the subject generator. |
protected C |
resetContainer(C newValue)
Replaces the existing container under test with a new container. |
void |
setUp()
|
Methods inherited from class com.google.common.collect.testing.AbstractTester |
---|
getName, getSubjectGenerator, getTestMethodName, init, init, tearDown |
Methods inherited from class junit.framework.TestCase |
---|
countTestCases, createResult, run, run, runBare, runTest, setName, toString |
Methods inherited from class junit.framework.Assert |
---|
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, fail, fail, failNotEquals, failNotSame, failSame, format |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected SampleElements<E> samples
protected C container
Constructor Detail |
---|
public AbstractContainerTester()
Method Detail |
---|
public void setUp() throws Exception
setUp
in class AbstractTester<OneSizeTestContainerGenerator<C,E>>
Exception
protected abstract Collection<E> actualContents()
expectContents(E...)
and its friends.protected C resetContainer()
resetContainer(C)
protected C resetContainer(C newValue)
expectContents(E...)
and other
convenience methods. The creation of multiple containers in a single
method is discouraged in most cases, but it is vital to the iterator tests.
newValue
- the new container instance
protected final void expectContents(E... elements)
elements
- expected contents of container
expectContents(java.util.Collection)
protected void expectContents(Collection<E> expected)
AbstractListTester
, a call to expectContents()
invokes this
version.
expected
- expected value of container
protected void expectUnchanged()
protected final void expectAdded(E... elements)
expectContents(java.util.Collection)
. In other words, for the
default expectContents()
implementation, the number of occurrences
of each given element has increased by one since the test collection was
created, and the number of occurrences of all other elements has not
changed.
Note: This means that a test like the following will fail if
collection
is a Set
:
collection.add(existingElement); expectAdded(existingElement);In this case,
collection
was not modified as a result of the
add()
call, and the test will fail because the number of
occurrences of existingElement
is unchanged.
elements
- expected additional contents of container
protected final void expectAdded(int index, E... elements)
protected final void expectAdded(int index, Collection<E> elements)
protected void expectMissing(E... elements)
protected E[] createSamplesArray()
protected AbstractContainerTester.ArrayWithDuplicate<E> createArrayWithDuplicateElement()
protected int getNumElements()
protected Collection<E> getSampleElements(int howMany)
protected Collection<E> getSampleElements()
protected List<E> getOrderedElements()
TestContainerGenerator.order(List)
. Tests should used this method
only if they declare requirement CollectionFeature.KNOWN_ORDER
.
protected int getNullLocation()
protected MinimalCollection<E> createDisjointCollection()
protected MinimalCollection<E> emptyCollection()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |