net.sf.molae.pipe.test
Class ListTest<B extends List<E>,E>

java.lang.Object
  extended by org.junit.Assert
      extended by net.sf.molae.pipe.test.ObjectTest<B>
          extended by net.sf.molae.pipe.test.CollectionTest<B,E>
              extended by net.sf.molae.pipe.test.ListTest<B,E>
Direct Known Subclasses:
ListTest.SubListTest

public class ListTest<B extends List<E>,E>
extends CollectionTest<B,E>

Test methods to check the contract of list implementing classes.


Nested Class Summary
static class ListTest.SubListTest<E>
          Test methods to check the contract of sub lists.
 
Constructor Summary
protected ListTest(B testObject)
          Creates a new test with the specified candidate.
 
Method Summary
 void assertConsistency()
          Checks consistency of all reading list methods.
 void assertImmutability()
          Calls all modifying methods of the underlying list and checks if they throw an UnsupportedOperationException.
protected  void assertValidArray(String message, Object[] a)
          Checks if the specified array is a valid result of the toArray() or toArray(Object[]) operation, respectively.
protected  void checkAddAll(String message, List<E> l)
          This implementation uses List.equals(Object).
static
<E> ListTest<List<E>,E>
getInstance(List<E> testObject)
          Creates a new instance of this class with the specified testObject as test object.
 void performCycle()
          Checks consistency of all list methods.
protected  void performCycle(int index, E subst)
          Checks consistency of all list methods.
 
Methods inherited from class net.sf.molae.pipe.test.CollectionTest
assertAddProhibited, assertEqualContent, assertEqualSequence, checkConsistency, getInstance, getTestValue, performBulkCycle, performIntegerTest, performValuesTest, setIntegerTestValues, setTestValues
 
Methods inherited from class net.sf.molae.pipe.test.ObjectTest
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

ListTest

protected ListTest(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

public static final <E> ListTest<List<E>,E> getInstance(List<E> testObject)
Creates a new instance of this class with the specified testObject as test object.

Parameters:
testObject - the candidate of the test
Returns:
an instance of this class with the specified testObject as test object.
Throws:
NullPointerException - if the specified test objects is null.

checkAddAll

protected void checkAddAll(String message,
                           List<E> l)
This implementation uses List.equals(Object).

Overrides:
checkAddAll in class CollectionTest<B extends List<E>,E>
Parameters:
message - the message to be displayed if the assertion fails
l - the list to compare
Throws:
AssertionFailedError - if the specified list is not equal to the test object.

assertValidArray

protected void assertValidArray(String message,
                                Object[] a)

Checks if the specified array is a valid result of the toArray() or toArray(Object[]) operation, respectively.

This implementation uses List.equals(Object).

Overrides:
assertValidArray in class CollectionTest<B extends List<E>,E>
Parameters:
message - the message to be displayed if the assertion fails
a - the result of a toArray() operation.
Throws:
AssertionFailedError - if the specified array is not a valid result.

assertConsistency

public void assertConsistency()
Checks consistency of all reading list methods.

Overrides:
assertConsistency in class CollectionTest<B extends List<E>,E>
Throws:
AssertionFailedError - if the list contract is broken by the tested list.

assertImmutability

public void assertImmutability()
Calls all modifying methods of the underlying list and checks if they throw an UnsupportedOperationException.

Overrides:
assertImmutability in class CollectionTest<B extends List<E>,E>
Throws:
AssertionFailedError - if any of the called operations did not throw an UnsupportedOperationException

performCycle

protected void performCycle(int index,
                            E subst)
Checks consistency of all list methods.

Parameters:
index - the index of the element that is tested
subst - a value to which the list entry is set during the cycle.
Throws:
AssertionFailedError - if the list contract is broken by the specified list.
UnsupportedOperationException - if any of the called methods is not implemented.

performCycle

public void performCycle()
Checks consistency of all list methods.

Overrides:
performCycle in class CollectionTest<B extends List<E>,E>
Throws:
AssertionFailedError - if the list contract is broken by the specified list.
UnsupportedOperationException - if any of the called methods is not implemented.