public abstract class AbstractListTest extends AbstractCollectionTest
Those wishing to test their list implementations for the basic functionality provided by lists should extend this class and implement the abstract methods, which will serve as a questionaire about the optional functionalities of the List interface.
Abstract methods must also be overridden in order to construct the list that is being tested. Two basic construction methods are used: null constructor and a constructor with a Collection. If neither constructor is supported by your List implementation then it may not be possible to use this class to test your list implementation. Subclasses of this class may also override the "isNullArgumentConstructorSupported" or "isCollectionArgumentConstructorSupported" methods if the list does not support one of the constructors.
Constructor and Description |
---|
AbstractListTest() |
Modifier and Type | Method and Description |
---|---|
protected Collection |
createCollection()
This overrides the abstract methods on the Collection test
|
protected Collection |
createCollection(Collection input)
This overrides the abstract methods on the Collection test
|
protected abstract List |
createList()
Subclasses must override this method in order to construct
an empty list with the null argument constructor.
|
protected abstract List |
createList(Collection input)
Subclasses must override this method in order to construct
a list with the elements found in the (possibly null) Collection.
|
protected boolean |
doesListIteratorSupportAdd()
Subclasses should override this method if the
ListIterator returned from this list does not
support the optional add operation
|
protected boolean |
doesListIteratorSupportSet()
Subclasses should override this method if the
ListIterator returned from this list does not
support the optional set operation
|
void |
testAddAllWithIndex()
Tests that addAll with an index works properly
|
void |
testAddToBeginningOfNonEmptyList() |
void |
testAddWithBadHighIndexThrows()
Tests that add with an bad index (too high) fails
|
void |
testAddWithBadLowIndexThrows()
Tests that add with an bad index (-1) fails
|
void |
testAddWithIndex()
Tests that add with an index works
|
void |
testAllElementsOfCollectionInConstructedList()
Tests that the elements of the original collection are
in the new List in the proper order
|
void |
testCanAddToAList()
Tests that a single element can be added to the list
|
void |
testCanCollectionHaveNullAndNonNullElements()
Tests that lists can have null elements interspersed
with non-null elements
|
void |
testCanCollectionHaveNullElements()
Tests that the list functions properly with
a null element added
|
void |
testCollectionToArrayWithCollectionOfMultipleItems()
In a List the order in the array is guaranteed, so test
that here
|
void |
testIndexOf()
Tests indexOf functionality
|
void |
testLastIndexOf()
Tests lastIndexOf functionality
|
void |
testListIteratorAddAfterNext()
Tests we can go forward with the ListIterator,
using the index version of listIterator, from
the middle of the list
|
void |
testListIteratorAddAfterPrevious()
Tests we can go forward with the ListIterator,
using the index version of listIterator, from
the middle of the list
|
void |
testListIteratorBackwardAndForward()
Tests we can go backward and forward with the ListIterator,
using the index version of listIterator
|
void |
testListIteratorBackwardFromMiddle()
Tests we can go backward with the ListIterator,
using the index version of listIterator, from
the middle of the list
|
void |
testListIteratorForwardAndBack()
Tests we can go backward and forward with the ListIterator
|
void |
testListIteratorForwardFromMiddle()
Tests we can go forward with the ListIterator,
using the index version of listIterator, from
the middle of the list
|
void |
testListIteratorOnEmptyList()
Tests a ListIterator on an empty list
|
void |
testListIteratorRemoveAfterNext()
Tests the ListIterators remove operation
|
void |
testListIteratorRemoveAfterPrevious()
Tests the ListIterators remove operation
|
void |
testListIteratorSetAfterNext()
Tests we can go forward with the ListIterator,
using the index version of listIterator, from
the middle of the list
|
void |
testListIteratorSetAfterPrevious()
Tests we can go forward with the ListIterator,
using the index version of listIterator, from
the middle of the list
|
void |
testListIteratorSetThrowsIfAfterAdd()
Tests the ListIterators remove operation
|
void |
testListIteratorSetThrowsIfAfterRemove()
Tests the ListIterators remove operation
|
void |
testListIteratorSetThrowsIfNeverMoved()
Tests the ListIterators remove operation
|
void |
testListIteratorThrowsIfNeverMoved()
Tests the ListIterators remove operation
|
void |
testListIteratorWithBadIndexHighThrows() |
void |
testListIteratorWithBadIndexLowThrows() |
void |
testMultipleItemIterator()
Tests that an iterator from a list with
more than one element returns the proper values
in the proper order
|
void |
testPreviousGoneTooFar() |
void |
testPreviousOnEmptyListThrows() |
void |
testRemoveWithIndex()
Tests that remove with an index works
|
void |
testRemoveWithIndexThrowsOnBadIndex()
Tests that add with an index works
|
void |
testSecondElementIsPutAtEndOfList() |
void |
testSetWithBadHighIndex()
Tests that set with a bad (high) index works
|
void |
testSetWithBadLowIndex()
Tests that set with a bad (-1) index works
|
void |
testSetWithIndex()
Tests that set with an index works
|
void |
testSubList()
Tests basic functionality of subList
|
void |
testSubListAffectsUnderlyingList()
Tests basic functionality of subList
|
doesCollectionAllowNullElements, doesCollectionDelegateFromOriginalCollection, doesCollectionsIteratorSupportRemove, doesCollectionSupportDuplicateElements, doesCollectionSupportEmpty, doesCollectionSupportRemove, doesCollectionSupportRetainAll, getElement, isCollectionArgumentConstructorSupported, isNullArgumentConstructorSupported, testAddAllThrows, testAddAllWithEmptyCollectionAndEmptyInput, testAddAllWithNonEmptyCollectionAndEmptyInput, testAddAllWithNonEmptyCollectionAndNonEmptyInputDups, testAddAllWithNonEmptyCollectionAndNonEmptyInputNoDups, testAddOneThousandEntries, testAddReturnsProperValueForDuplicateAdd, testAddReturnsProperValueForNonDuplicateAdd, testCanAddToCollection, testClearWorksOnEmptyCollection, testClearWorksOnNonEmptyCollection, testCollectionFromCollectionConstructorHasZeroSize, testCollectionFromNullConstructorHasZeroSize, testCollectionToArrayWithArgumentWithCollectionOfMultipleItems, testCollectionToArrayWithArgumentWithCollectionOfOneItem, testCollectionToArrayWithArgumentWithEmptyCollection, testCollectionToArrayWithArgumentWithNullThrows, testCollectionToArrayWithCollectionOfOneItem, testCollectionToArrayWithEmptyCollection, testContainsAfterAdd, testContainsAllThrows, testContainsAllWithEmptyCollectionAndEmptyInput, testContainsAllWithNonEmptyCollectionAndCorrectInput, testContainsAllWithNonEmptyCollectionAndEmptyInput, testContainsAllWithNonEmptyCollectionAndIncorrectInput, testDoubleIteratorRemoveThrows, testFallingOffEndOfEmptyIteratorThrows, testFallingOffEndOfNonEmptyIteratorThrows, testIteratorRemoveOnEmptyIteratorThrows, testIteratorReturnedFromEmptyList, testListColnstructedWithNullCollectionThrows, testModifyingOriginalCollectionDoesNotAffectNewCollection, testMultipleItemIteratorRemoval, testRemoveAllThrows, testRemoveAllWithEmptyCollectionAndEmptyInput, testRemoveAllWithNonEmptyCollectionAndEmptyInput, testRemoveAllWithNonEmptyCollectionAndNonEmptyInput, testRemoveAllWithNonEmptyCollectionAndNonEmptyInputWithExtras, testRemoveFirstThingFromMultiElementList, testRemoveFromEmptyList, testRemoveFromOneElementList, testRemoveLastThingFromMultiElementList, testRemoveMiddleThingFromMultiElementList, testRetainAllThrows, testRetainAllWithEmptyCollectionAndEmptyInput, testRetainAllWithNonEmptyCollectionAndEmptyInput, testRetainAllWithNonEmptyCollectionAndNonEmptyInput, testRetainAllWithNonEmptyCollectionAndNonEmptyInputWithExtras, testSingleItemIterator, testSingleItemIteratorRemoval, testUnsupporedRemoveIteratorThrows, testUnsupportedClearThrows, testUnsupportedRetainAllThrowsProperException
protected boolean doesListIteratorSupportSet()
protected boolean doesListIteratorSupportAdd()
protected abstract List createList()
protected abstract List createList(Collection input)
input
- A possibly null and possibly empty collection of items
to seed the list withprotected Collection createCollection()
createCollection
in class AbstractCollectionTest
protected Collection createCollection(Collection input)
createCollection
in class AbstractCollectionTest
input
- A possibly null and possibly empty collection of items
to seed the list withpublic void testCanAddToAList()
public void testSecondElementIsPutAtEndOfList()
public void testAddToBeginningOfNonEmptyList()
public void testAllElementsOfCollectionInConstructedList()
public void testCanCollectionHaveNullElements()
testCanCollectionHaveNullElements
in class AbstractCollectionTest
public void testCanCollectionHaveNullAndNonNullElements()
testCanCollectionHaveNullAndNonNullElements
in class AbstractCollectionTest
public void testMultipleItemIterator()
testMultipleItemIterator
in class AbstractCollectionTest
public void testCollectionToArrayWithCollectionOfMultipleItems()
testCollectionToArrayWithCollectionOfMultipleItems
in class AbstractCollectionTest
public void testAddAllWithIndex()
public void testSetWithIndex()
public void testSetWithBadLowIndex()
public void testSetWithBadHighIndex()
public void testAddWithIndex()
public void testAddWithBadLowIndexThrows()
public void testAddWithBadHighIndexThrows()
public void testRemoveWithIndex()
public void testRemoveWithIndexThrowsOnBadIndex()
public void testIndexOf()
public void testLastIndexOf()
public void testListIteratorOnEmptyList()
public void testListIteratorForwardAndBack()
public void testListIteratorBackwardAndForward()
public void testListIteratorForwardFromMiddle()
public void testListIteratorBackwardFromMiddle()
public void testListIteratorWithBadIndexLowThrows()
public void testListIteratorWithBadIndexHighThrows()
public void testPreviousGoneTooFar()
public void testPreviousOnEmptyListThrows()
public void testListIteratorRemoveAfterNext()
public void testListIteratorRemoveAfterPrevious()
public void testListIteratorThrowsIfNeverMoved()
public void testListIteratorSetAfterNext()
public void testListIteratorSetAfterPrevious()
public void testListIteratorSetThrowsIfNeverMoved()
public void testListIteratorSetThrowsIfAfterRemove()
public void testListIteratorSetThrowsIfAfterAdd()
public void testListIteratorAddAfterNext()
public void testListIteratorAddAfterPrevious()
public void testSubList()
public void testSubListAffectsUnderlyingList()
Copyright © 2009-2017, Oracle and/or its affiliates. All Rights Reserved.