class TransactionContext
extends java.lang.Object
TestContext
.Transactional
,
TransactionalTestExecutionListener
Modifier and Type | Field and Description |
---|---|
private boolean |
defaultRollback |
private boolean |
flaggedForRollback |
private static Log |
logger |
private TestContext |
testContext |
private TransactionDefinition |
transactionDefinition |
private PlatformTransactionManager |
transactionManager |
private int |
transactionsStarted |
private TransactionStatus |
transactionStatus |
Constructor and Description |
---|
TransactionContext(TestContext testContext,
PlatformTransactionManager transactionManager,
TransactionDefinition transactionDefinition,
boolean defaultRollback) |
Modifier and Type | Method and Description |
---|---|
(package private) void |
endTransaction()
Immediately force a commit or rollback of the transaction
for the configured test context, according to
the rollback flag.
|
(package private) TransactionStatus |
getTransactionStatus() |
(package private) boolean |
isFlaggedForRollback()
Has the current transaction been flagged for rollback?
|
(package private) void |
setFlaggedForRollback(boolean flaggedForRollback) |
(package private) void |
startTransaction()
Start a new transaction for the configured test context.
|
private static final Log logger
private final TestContext testContext
private final TransactionDefinition transactionDefinition
private final PlatformTransactionManager transactionManager
private final boolean defaultRollback
private boolean flaggedForRollback
private TransactionStatus transactionStatus
private volatile int transactionsStarted
TransactionContext(TestContext testContext, PlatformTransactionManager transactionManager, TransactionDefinition transactionDefinition, boolean defaultRollback)
TransactionStatus getTransactionStatus()
boolean isFlaggedForRollback()
In other words, should we roll back or commit the current transaction upon completion of the current test?
void setFlaggedForRollback(boolean flaggedForRollback)
void startTransaction()
Only call this method if endTransaction()
has been called or if no
transaction has been previously started.
TransactionException
- if starting the transaction failsvoid endTransaction()