net.sf.molae.pipe.test
Class ListTest

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

public class ListTest
extends CollectionTest

Test methods to check the contract of list implementing classes.


Inner Class Summary
static class ListTest.SubListTest
          Test methods to check the contract of sub lists.
 
Constructor Summary
protected ListTest(List 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 l)
          This implementation uses List.equals(Object).
static ListTest getInstance(List 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, Object subst)
          Checks consistency of all list methods.
 
Methods inherited from class net.sf.molae.pipe.test.CollectionTest
assertAddProhibited, assertEqualContent, assertEqualSequence, checkConsistency, getInstance, performBulkCycle, performIntegerTest
 
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

ListTest

protected ListTest(List 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 ListTest getInstance(List 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 l)
This implementation uses List.equals(Object).
Overrides:
checkAddAll in class CollectionTest
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
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
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
Throws:
AssertionFailedError - if any of the called operations did not throw an UnsupportedOperationException

performCycle

protected void performCycle(int index,
                            Object 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
Throws:
AssertionFailedError - if the list contract is broken by the specified list.
UnsupportedOperationException - if any of the called methods is not implemented.