public abstract class CdmTransactionalIntegrationTest extends CdmIntegrationTest
CdmItegrationTest
by transactions management features.Modifier and Type | Field and Description |
---|---|
protected static Logger |
logger |
protected org.springframework.transaction.TransactionDefinition |
transactionDefinition
Transaction definition used by this test class: by default, a plain
DefaultTransactionDefinition.
|
protected org.springframework.transaction.TransactionStatus |
transactionStatus
TransactionStatus for this test.
|
dataSource, termLoadingTables, txDefinition
Constructor and Description |
---|
CdmTransactionalIntegrationTest() |
Modifier and Type | Method and Description |
---|---|
static void |
beforeClass() |
void |
clearAuthentication() |
protected void |
commit()
Commit and end transaction
|
protected void |
commitAndStartNewTransaction() |
protected void |
commitAndStartNewTransaction(java.lang.String[] tableNames) |
protected void |
endTransaction()
Immediately force a commit or rollback of the transaction, according to
the
complete and rollback flags. |
protected boolean |
isDefaultRollback()
Get the default rollback flag for this test.
|
protected boolean |
isRollback()
Determines whether or not to rollback transactions for the current test.
|
void |
onSetUp()
This implementation creates a transaction before test execution.
|
protected void |
onSetUpBeforeTransaction()
Subclasses can override this method to perform any setup operations, such
as populating a database table, before the transaction created by
this class.
|
protected void |
onSetUpInTransaction()
Subclasses can override this method to perform any setup operations, such
as populating a database table, within the transaction created by
this class.
|
void |
onTearDown()
This implementation ends the transaction after test execution.
|
protected void |
onTearDownAfterTransaction()
Subclasses can override this method to perform cleanup after a
transaction here.
|
protected void |
onTearDownInTransaction()
Subclasses can override this method to run invariant tests here.
|
protected void |
preventTransaction()
Call this method in an overridden
#runBare() method to prevent
transactional execution. |
protected void |
rollback() |
protected void |
setComplete()
Cause the transaction to commit for this test method, even if the test
method is configured to
rollback . |
void |
setDefaultRollback(boolean defaultRollback)
Subclasses can set this value in their constructor to change the default,
which is always to roll the transaction back.
|
protected void |
setTransactionDefinition(org.springframework.transaction.TransactionDefinition customDefinition)
Call this method in an overridden
#runBare() method to override
the transaction attributes that will be used, so that #setUp()
and #tearDown() behavior is modified. |
protected void |
startNewTransaction()
Start a new transaction.
|
createTestDataSet, existsInCollection, getConnection, getEntityFromCollection, printDataSet, printDataSet, printDataSet, printDataSetWithNull, printDataSetWithNull, printDataSetWithNull, printDtd, printTableNames, setTransactionManager, startH2Server, transformSourceToString, writeDbUnitDataSetFile, writeDbUnitDataSetFile
protected static final Logger logger
protected org.springframework.transaction.TransactionDefinition transactionDefinition
protected org.springframework.transaction.TransactionStatus transactionStatus
protected boolean isDefaultRollback()
setDefaultRollback(boolean)
public void setDefaultRollback(boolean defaultRollback)
protected boolean isRollback()
Determines whether or not to rollback transactions for the current test.
The default implementation delegates to isDefaultRollback()
.
Subclasses can override as necessary.
protected void preventTransaction()
#runBare()
method to prevent
transactional execution.protected void setTransactionDefinition(org.springframework.transaction.TransactionDefinition customDefinition)
#runBare()
method to override
the transaction attributes that will be used, so that #setUp()
and #tearDown()
behavior is modified.customDefinition
- the custom transaction definitionpublic static void beforeClass()
public void onSetUp() throws java.lang.Exception
Override onSetUpBeforeTransaction()
and/or
onSetUpInTransaction()
to add custom set-up behavior for
transactional execution. Alternatively, override this method for general
set-up behavior, calling super.onSetUp()
as part of your
method implementation.
java.lang.Exception
- simply let any exception propagateonTearDown()
public void clearAuthentication()
protected void onSetUpBeforeTransaction() throws java.lang.Exception
preventTransaction()
has not been invoked in an overridden
#runTest()
method.java.lang.Exception
- simply let any exception propagateprotected void onSetUpInTransaction() throws java.lang.Exception
NB: Not called if there is no transaction management, due to no transaction manager being provided in the context.
If any Throwable
is thrown, the transaction that has been started
prior to the execution of this method will be
ended
(or rather an attempt will be made to
end it gracefully
); The offending
Throwable
will then be rethrown.
java.lang.Exception
- simply let any exception propagatepublic void onTearDown() throws java.lang.Exception
Override onTearDownInTransaction()
and/or
onTearDownAfterTransaction()
to add custom tear-down behavior
for transactional execution. Alternatively, override this method for
general tear-down behavior, calling super.onTearDown()
as
part of your method implementation.
Note that onTearDownInTransaction()
will only be called if a
transaction is still active at the time of the test shutdown. In
particular, it will not be called if the transaction has been
completed with an explicit endTransaction()
call before.
java.lang.Exception
- simply let any exception propagateonSetUp()
protected void onTearDownInTransaction() throws java.lang.Exception
NB: Not called if there is no actual transaction, for example due to no transaction manager being provided in the application context.
java.lang.Exception
- simply let any exception propagateprotected void onTearDownAfterTransaction() throws java.lang.Exception
java.lang.Exception
- simply let any exception propagateprotected void setComplete()
rollback
.java.lang.IllegalStateException
- if the operation cannot be set to complete
as no transaction manager was providedprotected void endTransaction()
complete
and rollback
flags.
Can be used to explicitly let the transaction end early, for example to check whether lazy associations of persistent objects work outside of a transaction (that is, have been initialized properly).
setComplete()
protected void rollback()
protected void startNewTransaction() throws org.springframework.transaction.TransactionException
endTransaction()
has been called. setComplete()
can be
used again in the new transaction. The fate of the new transaction, by
default, will be the usual rollback.org.springframework.transaction.TransactionException
- if starting the transaction failedprotected void commitAndStartNewTransaction()
protected void commitAndStartNewTransaction(java.lang.String[] tableNames)
tableNames
- the tables supplied by this array will be printed after the transaction has committed
and ended only if the logging level is set to debug, e.g.:
log4j.logger.eu.etaxonomy.cdm.test.integration=DEBUG
protected void commit()
Copyright © 2007-2020 EDIT. All Rights Reserved.