net.sf.molae.pipe.test
Class ListIteratorTest

java.lang.Object
  |
  +--junit.framework.Assert
        |
        +--net.sf.molae.pipe.test.ObjectTest
              |
              +--net.sf.molae.pipe.test.IteratorTest
                    |
                    +--net.sf.molae.pipe.test.ListIteratorTest

public class ListIteratorTest
extends IteratorTest

Test methods to check the contract of list iterator implementing classes.


Constructor Summary
protected ListIteratorTest(List list)
          Creates a new test from the specified base list.
protected ListIteratorTest(List list, int index)
          Creates a new test from the specified base list.
 
Method Summary
 void assertConsistency()
          Checks consistency of list iterator without moving the cursor.
protected  void assertUnmodifying()
          Calls all modifying methods of the underlying iterator and checks if they throw an UnsupportedOperationException.
protected  void checkConsistency()
          This method is called at the start of the test cycle and after each modification of the test object.
protected  void modifyAtStartTest()
          Asserts that a call of set before next throws an IllegalStateException.
protected  void performCycle()
          Calls set, remove and add.
protected  void readTest()
          Performs all tests that do not change the collection underlying the iterator.
 
Methods inherited from class net.sf.molae.pipe.test.ObjectTest
assertFalse, getTestObject, toString
 
Methods inherited from class junit.framework.Assert
assert, assert, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertNotNull, assertNotNull, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ListIteratorTest

protected ListIteratorTest(List list)
Creates a new test from the specified base list.
Parameters:
list - the base list of the list iterator to test
Throws:
NullPointerException - if the specified test objects is null.

ListIteratorTest

protected ListIteratorTest(List list,
                           int index)
Creates a new test from the specified base list.
Parameters:
list - the base list of the list iterator to test
index - index of first element to be returned from the list iterator (by a call to the next method).
Throws:
IndexOutOfBoundsException - index < 0 || index > size() of base list.
NullPointerException - if the specified test objects is null.
Method Detail

assertConsistency

public void assertConsistency()
Checks consistency of list iterator without moving the cursor.
Overrides:
assertConsistency in class ObjectTest
Throws:
AssertionFailedError - if the test object does not pass the test.

assertUnmodifying

protected void assertUnmodifying()
Calls all modifying methods of the underlying iterator and checks if they throw an UnsupportedOperationException.
Overrides:
assertUnmodifying in class IteratorTest
Throws:
AssertionFailedError - if any of the called operations did not throw an UnsupportedOperationException

readTest

protected void readTest()
Description copied from class: IteratorTest
Performs all tests that do not change the collection underlying the iterator. For a simple iterator this is testing that trying to call next at the end throws an NoSuchElementException.
Overrides:
readTest in class IteratorTest
Following copied from class: net.sf.molae.pipe.test.IteratorTest
Throws:
AssertionFailedError - if the test object does not pass the test.
NoSuchElementException - if next() returns no element although hasNext() was true.

checkConsistency

protected void checkConsistency()
This method is called at the start of the test cycle and after each modification of the test object. This implementation calls readTest().
Throws:
AssertionFailedError - if the test object is not consistent.

performCycle

protected void performCycle()
Calls set, remove and add.
Throws:
AssertionFailedError - if the test object is not consistent.
UnsupportedOperationException - if any of the called methods is not implemented.

modifyAtStartTest

protected void modifyAtStartTest()
Asserts that a call of set before next throws an IllegalStateException.
Overrides:
modifyAtStartTest in class IteratorTest
Throws:
AssertionFailedError - if the test object does not pass the test.