|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object junit.framework.Assert junit.framework.TestCase org.springframework.test.AbstractSpringContextTests org.springframework.test.AbstractDependencyInjectionSpringContextTests org.springframework.test.AbstractTransactionalSpringContextTests
Convenient superclass for tests that should occur in a transaction, but normally will roll the transaction back on the completion of each test.
This is useful in a range of circumstances, allowing the following benefits:
This class is typically very fast, compared to traditional setup/teardown scripts.
If data should be left in the database, call the setComplete() method in each test. The defaultRollback() property, which defaults to true, determines whether transactions will complete by default. Requires a single bean in the context implementing the PlatformTransactionManager interface. This will be set by the superclass's Dependency Injection mechanism. If using the superclass's Field Injection mechanism, the implementation should be named "transactionManager". This mechanism allows the use of this superclass even when there's more than one transaction manager in the context.
Field Summary | |
protected PlatformTransactionManager |
transactionManager
|
protected TransactionStatus |
transactionStatus
TransactionStatus for this test. |
Fields inherited from class org.springframework.test.AbstractDependencyInjectionSpringContextTests |
applicationContext, managedVariableNames |
Fields inherited from class org.springframework.test.AbstractSpringContextTests |
logger |
Constructor Summary | |
AbstractTransactionalSpringContextTests()
|
Method Summary | |
protected void |
onSetUp()
Subclasses can override this method in place of the setUp() method, which is final in this class. |
protected void |
onSetUpInTransaction()
|
protected void |
onTearDown()
Subclasses can override this to add custom behavior on teardown. |
protected void |
onTearDownInTransaction()
Transaction is still open. |
protected void |
setComplete()
Cause the transaction to commit for this test method, even if default is set to rollback. |
void |
setDefaultRollback(boolean defaultRollback)
Subclasses can set this value in their constructor to change default, which is always to roll the transaction back |
void |
setTransactionManager(PlatformTransactionManager ptm)
Populated by dependency injection by superclass. |
Methods inherited from class org.springframework.test.AbstractDependencyInjectionSpringContextTests |
contextKey, getConfigLocations, getLoadCount, initManagedVariableNames, isPopulateProtectedVariables, loadContextLocations, populateProtectedVariables, setDirty, setPopulateProtectedVariables, setUp, tearDown |
Methods inherited from class org.springframework.test.AbstractSpringContextTests |
contextKeyString, getContext, hasCachedContext, loadContext, setDirty |
Methods inherited from class junit.framework.TestCase |
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString |
Methods inherited from class junit.framework.Assert |
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, 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 |
Field Detail |
protected TransactionStatus transactionStatus
protected PlatformTransactionManager transactionManager
Constructor Detail |
public AbstractTransactionalSpringContextTests()
Method Detail |
public void setDefaultRollback(boolean defaultRollback)
public void setTransactionManager(PlatformTransactionManager ptm)
protected final void onSetUp() throws java.lang.Exception
AbstractDependencyInjectionSpringContextTests
onSetUp
in class AbstractDependencyInjectionSpringContextTests
java.lang.Exception
protected void onSetUpInTransaction() throws java.lang.Exception
java.lang.Exception
protected final void onTearDown() throws java.lang.Exception
AbstractDependencyInjectionSpringContextTests
onTearDown
in class AbstractDependencyInjectionSpringContextTests
java.lang.Exception
protected void onTearDownInTransaction()
protected void setComplete()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |