net.sf.molae.pipe.test
Class SortedMapTest<B extends SortedMap<K,V>,K,V>

java.lang.Object
  extended by org.junit.Assert
      extended by net.sf.molae.pipe.test.ObjectTest<B>
          extended by net.sf.molae.pipe.test.MapTest<B,K,V>
              extended by net.sf.molae.pipe.test.SortedMapTest<B,K,V>

public class SortedMapTest<B extends SortedMap<K,V>,K,V>
extends MapTest<B,K,V>

Test methods to check the contract of SortedMap implementing classes.


Field Summary
 
Fields inherited from class net.sf.molae.pipe.test.MapTest
TO_KEY_TRANSFORMER, TO_VALUE_TRANSFORMER
 
Constructor Summary
protected SortedMapTest(B testObject)
          Creates a new test with the specified candidate.
 
Method Summary
 void addHeadMapTest(K toKey)
          Adds a head map test to the list of sub map tests that are performed simultaneously.
 void addSubMapTest(K fromKey, K toKey)
          Adds a subMap test to the list of sub map tests that are performed simultaneously.
 void addTailMapTest(K fromKey)
          Adds a tail map test to the list of sub map tests that are performed simultaneously.
 void assertConsistency()
          Checks consistency of reading SortedMap methods.
protected static void assertEqualSequence(String message, Iterator expected, Iterator actual)
          Compares the specified iterators.
static
<K,V> SortedMapTest<SortedMap<K,V>,K,V>
getInstance(SortedMap<K,V> testObject)
          Creates a new instance of this class with the specified testObject as test object.
 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()
          Deprecated. Use setIntegerTestValues(net.sf.molae.pipe.test.SortedMapTest) and MapTest.performValuesTest() instead.
static void setIntegerTestValues(SortedMapTest<?,? super Integer,? super Integer> test)
          Sets default values for the test values.
 
Methods inherited from class net.sf.molae.pipe.test.MapTest
assertImmutablity, checkConsistency, getInstance, performBulkCycle, performCycle, 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

SortedMapTest

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

assertEqualSequence

protected static void assertEqualSequence(String message,
                                          Iterator expected,
                                          Iterator actual)
Compares the specified iterators. Calls CollectionTest.assertEqualSequence(String,Iterator,Iterator).

Parameters:
message - the message to be displayed if the assertion fails
expected - expected value
actual - actual value

getInstance

public static final <K,V> SortedMapTest<SortedMap<K,V>,K,V> getInstance(SortedMap<K,V> 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.

assertConsistency

public void assertConsistency()
Checks consistency of reading SortedMap methods.

Overrides:
assertConsistency in class MapTest<B extends SortedMap<K,V>,K,V>
Throws:
AssertionFailedError - if the SortedMap contract is broken by the specified sorted map.

performCycle

public 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.

Overrides:
performCycle in class MapTest<B extends SortedMap<K,V>,K,V>
Throws:
AssertionFailedError - if the test object does not pass the test.

setIntegerTestValues

public static void setIntegerTestValues(SortedMapTest<?,? super Integer,? super Integer> test)
Sets default values for the test values.


performIntegerTest

public void performIntegerTest()
Deprecated. Use setIntegerTestValues(net.sf.molae.pipe.test.SortedMapTest) and MapTest.performValuesTest() instead.

Method to test sorted map implementations that support integers.

Overrides:
performIntegerTest in class MapTest<B extends SortedMap<K,V>,K,V>

addSubMapTest

public void addSubMapTest(K fromKey,
                          K toKey)
Adds a subMap test to the list of sub map tests that are performed simultaneously.

Parameters:
fromKey - low endpoint (inclusive) of the subMap.
toKey - high endpoint (exclusive) of the subMap.

addHeadMapTest

public void addHeadMapTest(K toKey)
Adds a head map test to the list of sub map tests that are performed simultaneously.

Parameters:
toKey - high endpoint (exclusive) of the subMap.

addTailMapTest

public void addTailMapTest(K fromKey)
Adds a tail map test to the list of sub map tests that are performed simultaneously.

Parameters:
fromKey - low endpoint (inclusive) of the tailMap.