public abstract class AbstractTestList extends AbstractTestCollection
List
methods and contracts.
To use, simply extend this class, and implement
the makeEmptyList()
method.
If your List
fails one of these tests by design,
you may still use this base set of cases. Simply override the
test case (method) your List
fails or override one of the
protected methods from AbstractTestCollection.
Modifier and Type | Class and Description |
---|---|
static class |
AbstractTestList.BulkTestSubList |
class |
AbstractTestList.TestListIterator |
collection, confirmed
COLLECTIONS_MAJOR_VERSION
Constructor and Description |
---|
AbstractTestList(java.lang.String testName)
JUnit constructor.
|
Modifier and Type | Method and Description |
---|---|
BulkTest |
bulkTestListIterator() |
BulkTest |
bulkTestSubList()
Returns a
BulkTest for testing List.subList(int,int) . |
protected void |
failFastAll(java.util.List list)
Invokes all the methods on the given sublist to make sure they raise
a
ConcurrentModificationException . |
protected void |
failFastMethod(java.util.List list,
java.lang.reflect.Method m)
Invokes the given method on the given sublist to make sure it raises
a
ConcurrentModificationException . |
java.util.List |
getConfirmedList()
Returns the
AbstractTestCollection.confirmed field cast to a List . |
java.util.List |
getList()
Returns the
AbstractTestCollection.collection field cast to a List . |
boolean |
isEqualsCheckable()
List equals method is defined.
|
boolean |
isSetSupported()
Returns true if the collections produced by
makeCollection() and makeFullCollection()
support the set operation. |
java.util.Collection |
makeCollection()
Returns
makeEmptyList() . |
java.util.Collection |
makeConfirmedCollection()
Returns an empty
ArrayList . |
java.util.Collection |
makeConfirmedFullCollection()
Returns a full
ArrayList . |
abstract java.util.List |
makeEmptyList()
Return a new, empty
List to be used for testing. |
java.util.Collection |
makeFullCollection()
Returns
makeFullList() . |
java.util.List |
makeFullList()
Return a new, full
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
List.add(int,Object) . |
void |
testListAddByIndexBoundsChecking()
Tests bounds checking for
List.add(int, Object) on an
empty list. |
void |
testListAddByIndexBoundsChecking2()
Tests bounds checking for
List.add(int, Object) on a
full list. |
void |
testListEquals()
Tests
List.equals(Object) . |
void |
testListGetByIndex()
Tests
List.get(int) . |
void |
testListGetByIndexBoundsChecking()
Tests bounds checking for
List.get(int) on an
empty list. |
void |
testListGetByIndexBoundsChecking2()
Tests bounds checking for
List.get(int) on a
full list. |
void |
testListHashCode()
Tests
List.hashCode() . |
void |
testListIndexOf()
Tests
List.indexOf(java.lang.Object) . |
void |
testListIteratorAdd()
Tests the
ListIterator.add(Object) method of the list
iterator. |
void |
testListIteratorSet()
Tests the
ListIterator.set(Object) method of the list
iterator. |
void |
testListLastIndexOf()
Tests
List.lastIndexOf(java.lang.Object) . |
void |
testListListIterator()
Tests the read-only bits of
List.listIterator() . |
void |
testListListIteratorByIndex()
Tests the read-only bits of
List.listIterator(int) . |
void |
testListListIteratorNextRemoveNext()
Tests remove on list iterator is correct.
|
void |
testListListIteratorNextRemovePrevious()
Tests remove on list iterator is correct.
|
void |
testListListIteratorPreviousRemoveNext()
Tests remove on list iterator is correct.
|
void |
testListListIteratorPreviousRemovePrevious()
Tests remove on list iterator is correct.
|
void |
testListRemoveByIndex()
Tests
List.remove(int) . |
void |
testListRemoveByIndexBoundsChecking()
Tests bounds checking for
List.remove(int) on an
empty list. |
void |
testListRemoveByIndexBoundsChecking2()
Tests bounds checking for
List.remove(int) on a
full list. |
void |
testListSetByIndex()
Test
List.set(int,Object) . |
void |
testListSetByIndexBoundsChecking()
Tests bounds checking for
List.set(int,Object) on an
empty list. |
void |
testListSetByIndexBoundsChecking2()
Tests bounds checking for
List.set(int,Object) on a
full list. |
void |
testListSubListFailFastOnAdd()
Tests that a sublist raises a
ConcurrentModificationException
if elements are added to the original list. |
void |
testListSubListFailFastOnRemove()
Tests that a sublist raises a
ConcurrentModificationException
if elements are removed from the original list. |
void |
testUnsupportedSet()
If
isSetSupported() returns false, tests that set operation
raises UnsupportedOperationException. |
void |
verify()
Verifies that the test list implementation matches the confirmed list
implementation.
|
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
getCanonicalEmptyCollectionName, getCanonicalFullCollectionName, getCompatibilityVersion, isTestSerialization, readExternalFormFromBytes, readExternalFormFromDisk, skipSerializedCanonicalTests, supportsEmptyCollections, supportsFullCollections, testCanonicalEmptyCollectionExists, testCanonicalFullCollectionExists, testEqualsNull, testObjectEqualsSelf, testObjectHashCodeEqualsContract, testObjectHashCodeEqualsSelfHashCode, testSimpleSerialization, writeExternalFormToBytes, writeExternalFormToDisk
clone, ignoredTests, makeSuite, toString
public AbstractTestList(java.lang.String testName)
testName
- the test class namepublic boolean isSetSupported()
makeCollection()
and makeFullCollection()
support the set operation.
Default implementation returns true. Override if your collection
class does not support set.
public void verify()
verify
in class AbstractTestCollection
public boolean isEqualsCheckable()
isEqualsCheckable
in class AbstractTestCollection
public java.util.Collection makeConfirmedCollection()
ArrayList
.makeConfirmedCollection
in class AbstractTestCollection
public java.util.Collection makeConfirmedFullCollection()
ArrayList
.makeConfirmedFullCollection
in class AbstractTestCollection
public abstract java.util.List makeEmptyList()
List
to be used for testing.public java.util.List makeFullList()
List
to be used for testing.public final java.util.Collection makeCollection()
makeEmptyList()
.makeCollection
in class AbstractTestCollection
public final java.util.Collection makeFullCollection()
makeFullList()
.makeFullCollection
in class AbstractTestCollection
public java.util.List getList()
AbstractTestCollection.collection
field cast to a List
.public java.util.List getConfirmedList()
AbstractTestCollection.confirmed
field cast to a List
.public void testListAddByIndexBoundsChecking()
List.add(int, Object)
on an
empty list.public void testListAddByIndexBoundsChecking2()
List.add(int, Object)
on a
full list.public void testListAddByIndex()
List.add(int,Object)
.public void testListEquals()
List.equals(Object)
.public void testListHashCode()
List.hashCode()
.public void testListGetByIndex()
List.get(int)
.public void testListGetByIndexBoundsChecking()
List.get(int)
on an
empty list.public void testListGetByIndexBoundsChecking2()
List.get(int)
on a
full list.public void testListIndexOf()
List.indexOf(java.lang.Object)
.public void testListLastIndexOf()
List.lastIndexOf(java.lang.Object)
.public void testListSetByIndexBoundsChecking()
List.set(int,Object)
on an
empty list.public void testListSetByIndexBoundsChecking2()
List.set(int,Object)
on a
full list.public void testListSetByIndex()
List.set(int,Object)
.public void testUnsupportedSet()
isSetSupported()
returns false, tests that set operation
raises UnsupportedOperationException.
public void testListRemoveByIndexBoundsChecking()
List.remove(int)
on an
empty list.public void testListRemoveByIndexBoundsChecking2()
List.remove(int)
on a
full list.public void testListRemoveByIndex()
List.remove(int)
.public void testListListIterator()
List.listIterator()
.public void testListListIteratorByIndex()
List.listIterator(int)
.public void testListListIteratorPreviousRemoveNext()
public void testListListIteratorPreviousRemovePrevious()
public void testListListIteratorNextRemoveNext()
public void testListListIteratorNextRemovePrevious()
public void testListIteratorAdd()
ListIterator.add(Object)
method of the list
iterator.public void testListIteratorSet()
ListIterator.set(Object)
method of the list
iterator.public void testEmptyListSerialization() throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
public void testFullListSerialization() throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
public void testEmptyListCompatibility() throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
public void testFullListCompatibility() throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
public BulkTest bulkTestSubList()
BulkTest
for testing List.subList(int,int)
.
The returned bulk test will run through every 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.public void testListSubListFailFastOnAdd()
ConcurrentModificationException
if elements are added to the original list.public void testListSubListFailFastOnRemove()
ConcurrentModificationException
if elements are removed from the original list.protected void failFastAll(java.util.List list)
ConcurrentModificationException
.protected void failFastMethod(java.util.List list, java.lang.reflect.Method m)
ConcurrentModificationException
.
Unless the method happens to be the equals() method, in which case
the test is skipped. There seems to be a bug in
java.util.AbstractList.subList(int,int).equals(Object) -- it never
raises a ConcurrentModificationException.list
- the sublist to testm
- the method to invokepublic BulkTest bulkTestListIterator()
Copyright © 2001-2014 Apache Software Foundation. All Rights Reserved.