|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
org.apache.commons.collections.BulkTest
org.apache.commons.collections.AbstractTestObject
org.apache.commons.collections.collection.AbstractTestCollection
org.apache.commons.collections.list.AbstractTestList
public abstract class AbstractTestList
Abstract test class for List
methods and contracts.
To use, simply extend this class, and implement
the makeEmptyList()
method.
If your AbstractTestList.BulkTestSubList
fails one of these tests by design,
you may still use this base set of cases. Simply override the
test case (method) your AbstractTestList.BulkTestSubList
fails or override one of the
protected methods from AbstractTestCollection.
Nested Class Summary | |
---|---|
static class |
AbstractTestList.BulkTestSubList
|
class |
AbstractTestList.TestListIterator
|
Field Summary |
---|
Fields inherited from class org.apache.commons.collections.collection.AbstractTestCollection |
---|
collection, confirmed |
Fields inherited from class org.apache.commons.collections.AbstractTestObject |
---|
COLLECTIONS_MAJOR_VERSION |
Constructor Summary | |
---|---|
AbstractTestList(java.lang.String testName)
JUnit constructor. |
Method Summary | |
---|---|
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 AbstractTestList.BulkTestSubList . |
java.util.List |
getList()
Returns the AbstractTestCollection.collection field cast to a AbstractTestList.BulkTestSubList . |
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 AbstractTestList.BulkTestSubList to be used for testing. |
java.util.Collection |
makeFullCollection()
Returns makeFullList() . |
java.util.List |
makeFullList()
Return a new, full AbstractTestList.BulkTestSubList 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 Object.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 Object.hashCode() . |
void |
testListIndexOf()
Tests List#indexOf . |
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 . |
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. |
Methods inherited from class org.apache.commons.collections.BulkTest |
---|
clone, ignoredTests, makeSuite, toString |
Methods inherited from class junit.framework.TestCase |
---|
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown |
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 |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public AbstractTestList(java.lang.String testName)
testName
- the test class nameMethod Detail |
---|
public 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()
AbstractTestList.BulkTestSubList
to be used for testing.
public java.util.List makeFullList()
AbstractTestList.BulkTestSubList
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 AbstractTestList.BulkTestSubList
.
public java.util.List getConfirmedList()
AbstractTestCollection.confirmed
field cast to a AbstractTestList.BulkTestSubList
.
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()
Object.equals(Object)
.
public void testListHashCode()
Object.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
.
public void testListLastIndexOf()
List#lastIndexOf
.
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()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |