net.sf.molae.pipe.test
Class IteratorTest<B extends Iterator<?>>

java.lang.Object
  extended by org.junit.Assert
      extended by net.sf.molae.pipe.test.ObjectTest<B>
          extended by net.sf.molae.pipe.test.IteratorTest<B>
Direct Known Subclasses:
ListIteratorTest

public class IteratorTest<B extends Iterator<?>>
extends ObjectTest<B>

Test methods to check the contract of iterator implementing classes.


Constructor Summary
protected IteratorTest(B 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 static IteratorTest<Iterator<?>> getInstance(Iterator<?> testObject)
          Creates a new test with the specified candidate.
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, assertTestValuesSet, getTestObject, setTestValuesSet, toString
 
Methods inherited from class org.junit.Assert
assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertThat, assertThat, 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(B 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

getInstance

protected static IteratorTest<Iterator<?>> getInstance(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.

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.