net.sf.molae.pipe.test
Class CubeTest<B extends Cube<E,T>,E,T>

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

public class CubeTest<B extends Cube<E,T>,E,T>
extends ObjectTest<B>

Test methods to check the contract of cube implementing classes.

Since:
1.1

Nested Class Summary
static class CubeTest.ProjectionTest<E,T>
          Test methods to check the contract of projections.
 
Constructor Summary
protected CubeTest(B testObject)
          Creates a new test with the specified candidate.
 
Method Summary
 void assertConsistency()
          Checks consistency of all reading cube methods.
protected  void assertConsistency(List<E> key)
          Checks consistency of all reading cube methods regarding the element at the specified key.
protected  void checkConsistency()
          This method is called at the start of the test cycle and after each modification of the test object.
protected  void checkConsistency(List<E> key)
          This method is called at the start of the test cycle and after each modification of the element at the specified key.
static
<E,T> CubeTest<Cube<E,T>,E,T>
getInstance(Cube<E,T> testObject)
          Creates a new instance of this class with the specified testObject as test object.
 void performCycle()
          Performs a test cycle.
protected  void performCycle(List<E> key)
          Puts the specified key/value pair and restores the old value.
 void performIntegerTest()
          Deprecated. Use setStringTestValues(net.sf.molae.pipe.test.CubeTest) and performValuesTest() instead.
 void performValuesTest()
          Fills the test object with three entries and runs tests with it.
static void setStringTestValues(CubeTest<?,? super String,? super String> test)
          Sets default values for the test values.
 void setTestValue(T testValue)
          Sets the test value to the specified value.
 void setTestValues(E e1, E e2, T value1, T value2, T value3)
          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 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

CubeTest

protected CubeTest(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,T> CubeTest<Cube<E,T>,E,T> getInstance(Cube<E,T> 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

protected void assertConsistency(List<E> key)
Checks consistency of all reading cube methods regarding the element at the specified key.

Parameters:
key - key of the element to check
Throws:
AssertionFailedError - if the cube contract is broken by the tested cube.

assertConsistency

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

Overrides:
assertConsistency in class ObjectTest<B extends Cube<E,T>>
Throws:
AssertionFailedError - if the cube contract is broken by the tested cube.

checkConsistency

protected void checkConsistency(List<E> key)
This method is called at the start of the test cycle and after each modification of the element at the specified key. This implementation calls assertConsistency(List).

Parameters:
key - key of the element to check
Throws:
AssertionFailedError - if the test object is not consistent.

checkConsistency

protected void checkConsistency()
This method is called at the start of the test cycle and after each modification of the test object. This implementation calls assertConsistency().

Throws:
AssertionFailedError - if the test object is not consistent.

setTestValue

public void setTestValue(T testValue)
Sets the test value to the specified value. The test value is used for testing the put method.

Parameters:
testValue - new value of the test value.

performCycle

protected void performCycle(List<E> key)
Puts the specified key/value pair and restores the old value.

Parameters:
key - key of the cube entry to be modified
Throws:
AssertionFailedError - if the cube contract is broken by the tested cube.

performCycle

public void performCycle()
Performs a test cycle.

Throws:
AssertionFailedError - if the cube contract is broken by the tested cube.

setTestValues

public void setTestValues(E e1,
                          E e2,
                          T value1,
                          T value2,
                          T value3)
Defines the test data to be used in performValuesTest().


setStringTestValues

public static void setStringTestValues(CubeTest<?,? super String,? super String> test)
Sets default values for the test values.


performValuesTest

public void performValuesTest()
Fills the test object with three entries and runs tests with it.

Throws:
AssertionFailedError - if the test object does not pass the test.
IllegalStateException - if test values have not been set.

performIntegerTest

public void performIntegerTest()
Deprecated. Use setStringTestValues(net.sf.molae.pipe.test.CubeTest) and performValuesTest() instead.

Method to test cube implementations that support strings.