|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.junit.Assert
net.sf.molae.pipe.test.ObjectTest<B>
net.sf.molae.pipe.test.MapTest<B,K,V>
public class MapTest<B extends Map<K,V>,K,V>
Test methods to check the contract of map implementing classes.
Field Summary | |
---|---|
protected AbstractTransformer<Map.Entry<K,?>,K> |
TO_KEY_TRANSFORMER
Transforms a map entry to its key. |
protected AbstractTransformer<Map.Entry<?,V>,V> |
TO_VALUE_TRANSFORMER
Transforms a map entry to its value. |
Constructor Summary | |
---|---|
protected |
MapTest(B testObject)
Creates a new test with the specified candidate. |
Method Summary | ||
---|---|---|
void |
assertConsistency()
Checks consistency of all reading map methods. |
|
void |
assertImmutablity()
Calls all modifying methods of the underlying map and checks if they throw an UnsupportedOperationException . |
|
protected void |
checkConsistency()
This method is called at the start of the test cycle and after each modification of the test object. |
|
static
|
getInstance(Map<K,V> testObject)
Creates a new instance of this class with the specified testObject as test object. |
|
protected void |
performBulkCycle()
Method to test putAll . |
|
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. |
|
protected void |
performCycle(K key,
V subst)
Performs a test cycle for the specified key. |
|
void |
performIntegerTest()
Deprecated. Use setIntegerTestValues(net.sf.molae.pipe.test.MapTest, ? super java.lang.Integer, ? super java.lang.Integer>)
and performValuesTest() instead. |
|
void |
performValuesTest()
Method to test map implementations that support integers. |
|
static void |
setIntegerTestValues(MapTest<?,? super Integer,? super Integer> test)
|
|
void |
setTestValues(V elem1,
V elem2,
V elem3,
K key1,
K key2,
K key3)
Defines the test data to be used in performValuesTest() . |
Methods inherited from class net.sf.molae.pipe.test.ObjectTest |
---|
assertFalse, assertTestValuesSet, getTestObject, setTestValuesSet, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final AbstractTransformer<Map.Entry<K,?>,K> TO_KEY_TRANSFORMER
protected final AbstractTransformer<Map.Entry<?,V>,V> TO_VALUE_TRANSFORMER
Constructor Detail |
---|
protected MapTest(B testObject)
testObject
- the candidate of the test
NullPointerException
- if the specified test objects is
null
.Method Detail |
---|
public static final <K,V> MapTest<Map<K,V>,K,V> getInstance(Map<K,V> testObject)
testObject
- the candidate of the test
NullPointerException
- if the specified test objects is
null
.public void assertConsistency()
assertConsistency
in class ObjectTest<B extends Map<K,V>>
AssertionFailedError
- if the map contract is broken by
the tested map.public void assertImmutablity()
UnsupportedOperationException
.
AssertionFailedError
- if any of the called operations
did not throw an UnsupportedOperationException
protected void checkConsistency()
assertConsistency()
.
AssertionFailedError
- if the test object is not consistent.protected void performCycle(K key, V subst)
key
- the key of the map entry for which the cycle is performedsubst
- the value to which the map entry value is set during
the cycle
AssertionFailedError
- if the map contract is broken by
the tested map.
UnsupportedOperationException
- if any of the called
methods is not implemented.protected void performBulkCycle()
putAll
.
AssertionFailedError
- if the map contract is broken by
the tested map.
UnsupportedOperationException
- if
putAll
is not implemented.public void performCycle()
AssertionFailedError
- if the map contract is broken by
the tested map.
UnsupportedOperationException
- if any of the called
methods is not implemented.public void setTestValues(V elem1, V elem2, V elem3, K key1, K key2, K key3)
performValuesTest()
.
public static void setIntegerTestValues(MapTest<?,? super Integer,? super Integer> test)
public void performValuesTest()
HashMap
with the same entries.
AssertionFailedError
- if the test object does not pass the test.
IllegalStateException
- if test values have not been set.public void performIntegerTest()
setIntegerTestValues(net.sf.molae.pipe.test.MapTest, ? super java.lang.Integer, ? super java.lang.Integer>)
and performValuesTest()
instead.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |