org.kuali.rice.test
Class BaselineTestCase

java.lang.Object
  extended by org.kuali.rice.test.BaseRiceTestCase
      extended by org.kuali.rice.test.RiceTestCase
          extended by org.kuali.rice.test.RiceInternalSuiteDataTestCase
              extended by org.kuali.rice.test.BaseModuleTestCase
                  extended by org.kuali.rice.test.BaselineTestCase
All Implemented Interfaces:
MethodAware

public class BaselineTestCase
extends BaseModuleTestCase

Test case which supports common styles of "baselining" the test environment before/after running a unit test. Currently supports three modes, which are specifyiable either via constructor, getMode() override, or by annotation:

NONE
No baselining is performed. Because the base RiceTestCase includes the ClearDatabaseLifecycle by default, this lifecycle is explicitly omitted
CLEAR_DB
The database is cleared for each test. The suite ClearDatabaseLifecycle is omitted (since it's getting cleared each test anyway)
ROLLBACK_CLEAR_DB
A TransactionalLifecycle is installed that wraps each test and rolls back data. The suite ClearDatabaseLifecycle will be invoked once initially, and subsequently if the test has detected that the environment has been left "dirty" by a previous test. After a successful rollback, the test environment is marked clean again.
A TransactionalLifecycle is installed that wraps each test and rolls back data.
The BaselineMode annotation can be used on a per-test-class basis to indicate to the base class which mode to use for test subclass. It accepts a BaselineTestCase.Mode value.

Author:
Kuali Rice Team (rice.collab@kuali.org)

Nested Class Summary
static interface BaselineTestCase.BaselineMode
           
static class BaselineTestCase.Mode
          Enum of "baselining" modes that this test case supports
 
Field Summary
protected static boolean dirty
          Whether the test environment is in a "dirty" state.
private  BaselineTestCase.Mode mode
           
 
Fields inherited from class org.kuali.rice.test.BaseModuleTestCase
LOG, moduleName
 
Fields inherited from class org.kuali.rice.test.RiceTestCase
DEFAULT_TEST_HARNESS_SPRING_BEANS, failedSuiteTestName, perTestLifeCycles, SUITE_LIFE_CYCLES_FAILED, SUITE_LIFE_CYCLES_RAN, suiteLifeCycles
 
Fields inherited from class org.kuali.rice.test.BaseRiceTestCase
log, method
 
Constructor Summary
BaselineTestCase(String moduleName)
           
BaselineTestCase(String moduleName, BaselineTestCase.Mode mode)
          Adds the ability to specify Mode
 
Method Summary
protected  List<Lifecycle> getClearDbPerTestLifecycles()
           
protected  BaselineTestCase.Mode getMode()
           
protected  List<Lifecycle> getPerTestLifecycles()
           
protected  List<String> getPerTestTablesNotToClear()
           
protected  List<String> getPerTestTablesToClear()
           
protected  List<Lifecycle> getRollbackClearDbPerTestLifecycles()
           
protected  List<Lifecycle> getRollbackTestLifecycles()
           
private  void readModeAnnotation()
           
 void setUp()
          Overridden to set dirty=true each time
 
Methods inherited from class org.kuali.rice.test.BaseModuleTestCase
getModuleName
 
Methods inherited from class org.kuali.rice.test.RiceInternalSuiteDataTestCase
getKIMDataLoadOrderFile, getKIMSqlFileBaseLocation, getKNSDefaultSuiteTestData, loadSuiteTestData
 
Methods inherited from class org.kuali.rice.test.RiceTestCase
configureLogging, dumpMemory, getBaseDir, getConfigLocations, getFullTestName, getLoadApplicationLifecycle, getModuleTestConfigLocation, getRiceMasterDefaultConfigFile, getSuiteLifecycles, getTestHarnessConfig, getTestHarnessSpringBeansLocation, getTestHarnessSpringResourceLoader, loadPerTestData, logAfterRun, logBeforeRun, report, setBaseDirSystemProperty, setClearTables, setModuleName, setUpInternal, startLifecycles, startSuiteDataLoaderLifecycles, stopLifecycles, tearDown
 
Methods inherited from class org.kuali.rice.test.BaseRiceTestCase
getName, getPerTestDataLoaderLifecycle, resetLogLevels, setLogLevel, setName, setTestMethod
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mode

private BaselineTestCase.Mode mode

dirty

protected static boolean dirty
Whether the test environment is in a "dirty" state. Each time the unit test starts up dirty is set to true. If a subclass installs the TransactionalLifecycle then it should clear the dirty flag. This flag can be used to perform cleanup in case a previous test left the test environment in a "dirty" state.

Constructor Detail

BaselineTestCase

public BaselineTestCase(String moduleName)

BaselineTestCase

public BaselineTestCase(String moduleName,
                        BaselineTestCase.Mode mode)
Adds the ability to specify Mode

Method Detail

readModeAnnotation

private void readModeAnnotation()

getMode

protected BaselineTestCase.Mode getMode()
Returns:
the configured mode

setUp

public void setUp()
           throws Exception
Overridden to set dirty=true each time

Overrides:
setUp in class RiceTestCase
Throws:
Exception
See Also:
RiceTestCase.setUp()

getPerTestLifecycles

protected List<Lifecycle> getPerTestLifecycles()
Overrides:
getPerTestLifecycles in class RiceTestCase
Returns:
Lifecycles run every test run

getClearDbPerTestLifecycles

protected List<Lifecycle> getClearDbPerTestLifecycles()
Returns:
the per-test lifecycles for clearing the database

getPerTestTablesToClear

protected List<String> getPerTestTablesToClear()

getPerTestTablesNotToClear

protected List<String> getPerTestTablesNotToClear()

getRollbackClearDbPerTestLifecycles

protected List<Lifecycle> getRollbackClearDbPerTestLifecycles()
Returns:
the per-test lifecycles for rolling back & clearing the database

getRollbackTestLifecycles

protected List<Lifecycle> getRollbackTestLifecycles()
Returns:
the per-test lifecycles for rolling back the database


Copyright © 2004-2011 The Kuali Foundation. All Rights Reserved.