|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--junit.framework.Assert
|
+--net.sf.molae.pipe.test.ObjectTest
|
+--net.sf.molae.pipe.test.CollectionTest
Test methods to check the contract of collection implementing classes.
| Constructor Summary | |
protected |
CollectionTest(Collection testObject)
Creates a new test with the specified candidate. |
| Method Summary | |
protected void |
assertAddProhibited()
This method asserts that that the specifed collection does not implement add or
addAll. |
void |
assertConsistency()
Checks consistency of all reading collection methods. |
void |
assertEqualContent(String message,
Collection col)
Checks if the specified collection has the same elements as the tested collection. |
static void |
assertEqualSequence(String message,
Iterator expected,
Iterator actual)
Compares the specified iterators. |
void |
assertImmutability()
Calls all modifying methods of the underlying collection 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 method is used to check the result of an addAll() call on an empty
collection. |
protected void |
checkConsistency()
This method is called at the start of the test cycle and after each modification of the test object. |
static CollectionTest |
getInstance(Collection testObject)
Creates a new instance of this class with the specified testObject as test object. |
protected void |
performBulkCycle()
Performs a test cycle of methods that take collections as argument ( Collection.removeAll(Collection),
Collection.retainAll(Collection) and
Collection.addAll(Collection)). |
void |
performCycle()
Performs a test cycle that uses modifying methods but is expected to leave the test object in an equal state as at the start - if everything works fine. |
void |
performIntegerTest()
Method to test collection implementations that support integers. |
| 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 |
protected CollectionTest(Collection testObject)
testObject - the candidate of the testNullPointerException - if the specified test objects is
null.| Method Detail |
public static final void assertEqualSequence(String message,
Iterator expected,
Iterator actual)
message - the message to be displayed if the assertion failsexpected - expected valueactual - actual valueAssertionFailedError - if the specified iterators are not
equal in the defined way.public static final CollectionTest getInstance(Collection testObject)
testObject - the candidate of the testNullPointerException - if the specified test objects is
null.
public final void assertEqualContent(String message,
Collection col)
message - the message to be displayed if the assertion failscol - the collection to be comparedAssertionFailedError - if the specified collection and the tested
collection do not contain the same elements with the same cardinality.
protected void checkAddAll(String message,
List l)
This method is used to check the result of an
addAll() call on an empty
collection.
Must be overwritten for subclasses that have a more specific contract
concerning addAll.
This implementation checks that both collections contain the other one.
message - the message to be displayed if the assertion failsl - the list to compareAssertionFailedError - if the specified list is not equal in the
described sense.
protected void assertValidArray(String message,
Object[] a)
Checks if the specified array is a valid result of the
toArray() or
toArray(Object[])
operation, respectively.
Must be overwritten for subclasses that have a more specific contract concerning lists.
This implementatin calls
assertEqualContent(String,Collection) with a list
version of the array.
message - the message to be displayed if the assertion failsa - the result of a toArray() operation.AssertionFailedError - if the specified array is not a valid
result.public void assertConsistency()
assertConsistency in class ObjectTestAssertionFailedError - if the collection contract is broken by
the test object.public void assertImmutability()
UnsupportedOperationException.AssertionFailedError - if any of the called operations
did not throw an UnsupportedOperationExceptionprotected void assertAddProhibited()
add or
addAll.
Used by MapTest.AssertionFailedError - if the specified collection implements
an adding method.protected void checkConsistency()
assertConsistency().AssertionFailedError - if the test object is not consistent.protected void performBulkCycle()
Collection.removeAll(Collection),
Collection.retainAll(Collection) and
Collection.addAll(Collection)).AssertionFailedError - if the set contract is broken by
the specified set.UnsupportedOperationException - if any of the called
methods is not implemented.public void performCycle()
performBulkCycle().AssertionFailedError - if the test object does not pass the test.UnsupportedOperationException - if any of the called
methods is not implemented.public void performIntegerTest()
ArrayList with the same elements.AssertionFailedError - if the test object does not pass the test.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||