net.sf.molae.pipe.test
Class IteratorTest

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

public class IteratorTest
extends ObjectTest

Test methods to check the contract of iterator implementing classes.


Constructor Summary
protected IteratorTest(Iterator testObject)
          Creates a new test with the specified candidate.
 
Method Summary
protected  void assertUnmodifying()
          Calls all modifying methods of the underlying iterator and checks if they throw an UnsupportedOperationException.
protected  void modifyAtStartTest()
          Asserts that a call of remove before next throws an IllegalStateException.
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
assertConsistency, 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

IteratorTest

protected IteratorTest(Iterator testObject)
Creates a new test with the specified candidate.
Parameters:
testObject - the candidate of the test
Throws:
NullPointerException - if the specified test objects is null.
Method Detail

assertUnmodifying

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

readTest

protected void readTest()
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.
Throws:
AssertionFailedError - if the test object does not pass the test.
NoSuchElementException - if next() returns no element although hasNext() was true.

modifyAtStartTest

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