org.apache.commons.collections.list
public abstract class AbstractTestList extends AbstractTestCollection
To use, simply extend this class, and implement the {@link #makeEmptyList} method.
If your {@link List} fails one of these tests by design, you may still use this base set of cases. Simply override the test case (method) your {@link List} fails or override one of the protected methods from AbstractTestCollection.
Nested Class Summary | |
---|---|
static class | AbstractTestList.BulkTestSubList |
class | AbstractTestList.TestListIterator |
Constructor Summary | |
---|---|
AbstractTestList(String testName)
JUnit constructor.
|
Method Summary | |
---|---|
BulkTest | bulkTestListIterator() |
BulkTest | bulkTestSubList()
Returns a {@link BulkTest} for testing {@link List#subList(int,int)}.
|
protected void | failFastAll(List list)
Invokes all the methods on the given sublist to make sure they raise
a {@link java.util.ConcurrentModificationException ConcurrentModificationException}. |
protected void | failFastMethod(List list, Method m)
Invokes the given method on the given sublist to make sure it raises
a {@link java.util.ConcurrentModificationException ConcurrentModificationException}.
|
List | getConfirmedList()
Returns the {@link #confirmed} field cast to a {@link List}.
|
List | getList()
Returns the {@link #collection} field cast to a {@link List}.
|
boolean | isEqualsCheckable()
List equals method is defined. |
boolean | isSetSupported()
Returns true if the collections produced by
{@link #makeCollection()} and {@link #makeFullCollection()}
support the set operation. |
Collection | makeCollection()
Returns {@link #makeEmptyList()}.
|
Collection | makeConfirmedCollection()
Returns an empty {@link ArrayList}. |
Collection | makeConfirmedFullCollection()
Returns a full {@link ArrayList}. |
abstract List | makeEmptyList()
Return a new, empty {@link List} to be used for testing.
|
Collection | makeFullCollection()
Returns {@link #makeFullList()}.
|
List | makeFullList()
Return a new, full {@link List} to be used for testing.
|
void | testEmptyListCompatibility()
Compare the current serialized form of the List
against the canonical version in CVS. |
void | testEmptyListSerialization() |
void | testFullListCompatibility()
Compare the current serialized form of the List
against the canonical version in CVS. |
void | testFullListSerialization() |
void | testListAddByIndex()
Tests {@link List#add(int,Object)}. |
void | testListAddByIndexBoundsChecking()
Tests bounds checking for {@link List#add(int, Object)} on an
empty list. |
void | testListAddByIndexBoundsChecking2()
Tests bounds checking for {@link List#add(int, Object)} on a
full list. |
void | testListEquals()
Tests {@link List#equals(Object)}. |
void | testListGetByIndex()
Tests {@link List#get(int)}. |
void | testListGetByIndexBoundsChecking()
Tests bounds checking for {@link List#get(int)} on an
empty list. |
void | testListGetByIndexBoundsChecking2()
Tests bounds checking for {@link List#get(int)} on a
full list. |
void | testListHashCode()
Tests {@link List#hashCode()}. |
void | testListIndexOf()
Tests {@link List#indexOf}. |
void | testListIteratorAdd()
Tests the {@link ListIterator#add(Object)} method of the list
iterator. |
void | testListIteratorSet()
Tests the {@link ListIterator#set(Object)} method of the list
iterator. |
void | testListLastIndexOf()
Tests {@link List#lastIndexOf}. |
void | testListListIterator()
Tests the read-only bits of {@link List#listIterator()}. |
void | testListListIteratorByIndex()
Tests the read-only bits of {@link List#listIterator(int)}. |
void | testListListIteratorPreviousRemove()
Tests remove on list iterator is correct. |
void | testListRemoveByIndex()
Tests {@link List#remove(int)}. |
void | testListRemoveByIndexBoundsChecking()
Tests bounds checking for {@link List#remove(int)} on an
empty list. |
void | testListRemoveByIndexBoundsChecking2()
Tests bounds checking for {@link List#remove(int)} on a
full list. |
void | testListSetByIndex()
Test {@link List#set(int,Object)}. |
void | testListSetByIndexBoundsChecking()
Tests bounds checking for {@link List#set(int,Object)} on an
empty list. |
void | testListSetByIndexBoundsChecking2()
Tests bounds checking for {@link List#set(int,Object)} on a
full list. |
void | testListSubListFailFastOnAdd()
Tests that a sublist raises a {@link java.util.ConcurrentModificationException ConcurrentModificationException}
if elements are added to the original list. |
void | testListSubListFailFastOnRemove()
Tests that a sublist raises a {@link java.util.ConcurrentModificationException ConcurrentModificationException}
if elements are removed from the original list. |
void | testUnsupportedSet()
If {@link #isSetSupported()} returns false, tests that set operation
raises UnsupportedOperationException. |
void | verify()
Verifies that the test list implementation matches the confirmed list
implementation. |
Parameters: testName the test class name
TestList
method, including another bulkTestSubList
.
Sublists are tested until the size of the sublist is less than 10.
Each sublist is 6 elements smaller than its parent list.
(By default this means that two rounds of sublists will be tested).
The verify() method is overloaded to test that the original list is
modified when the sublist is.Parameters: list the sublist to test m the method to invoke
Returns: the confirmed field as a List
Returns: the collection field as a List
set operation.
Default implementation returns true. Override if your collection
class does not support set.
Returns: an empty list to be used for testing
Returns: an empty list for testing.
Returns: a full list to be used for testing
Returns: a full list for testing
UnsupportedOperationException.