|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.unitils.database.transaction.impl.DefaultUnitilsTransactionManager
public class DefaultUnitilsTransactionManager
Implements transactions for unit tests, by delegating to a spring
PlatformTransactionManager
. The concrete implementation of
PlatformTransactionManager
that is used depends on the test
class. If a custom PlatformTransactionManager
was configured
in a spring ApplicationContext
, this one is used. If not, a
suitable subclass of PlatformTransactionManager
is created,
depending on the configuration of a test. E.g. if some ORM persistence unit
was configured on the test, a PlatformTransactionManager
that
can offer transactional behavior for such a persistence unit is used. If no
such configuration is found, a DataSourceTransactionManager
is
used.
Field Summary | |
---|---|
protected Map<Object,org.springframework.transaction.PlatformTransactionManager> |
testObjectPlatformTransactionManagerMap
ThreadLocal for holding the PlatformTransactionManager that is used by the current test |
protected Map<Object,Boolean> |
testObjectTransactionActiveMap
|
protected Map<Object,org.springframework.transaction.TransactionStatus> |
testObjectTransactionStatusMap
ThreadLocal for holding the TransactionStatus that keeps track of the current test's transaction status |
protected List<UnitilsTransactionManagementConfiguration> |
transactionManagementConfigurations
Set of possible providers of a spring PlatformTransactionManager , not null |
Constructor Summary | |
---|---|
DefaultUnitilsTransactionManager()
|
Method Summary | |
---|---|
void |
activateTransactionIfNeeded(Object testObject)
|
void |
commit(Object testObject)
Commits the transaction. |
protected org.springframework.transaction.TransactionDefinition |
createTransactionDefinition(Object testObject)
Returns a TransactionDefinition object containing the
necessary transaction parameters. |
protected void |
doStartTransaction(Object testObject,
UnitilsTransactionManagementConfiguration transactionManagementConfiguration)
|
DataSource |
getTransactionalDataSource(DataSource dataSource)
Returns the given datasource, wrapped in a spring TransactionAwareDataSourceProxy |
protected UnitilsTransactionManagementConfiguration |
getTransactionManagementConfiguration(Object testObject)
|
void |
init(Set<UnitilsTransactionManagementConfiguration> transactionManagementConfigurations)
Initialize the transaction manager |
void |
rollback(Object testObject)
Rolls back the transaction. |
protected void |
setTransactionManagementConfigurations(Set<UnitilsTransactionManagementConfiguration> transactionManagementConfigurationsSet)
|
void |
startTransaction(Object testObject)
Starts the transaction. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Map<Object,Boolean> testObjectTransactionActiveMap
protected Map<Object,org.springframework.transaction.TransactionStatus> testObjectTransactionStatusMap
protected Map<Object,org.springframework.transaction.PlatformTransactionManager> testObjectPlatformTransactionManagerMap
protected List<UnitilsTransactionManagementConfiguration> transactionManagementConfigurations
PlatformTransactionManager
, not null
Constructor Detail |
---|
public DefaultUnitilsTransactionManager()
Method Detail |
---|
public void init(Set<UnitilsTransactionManagementConfiguration> transactionManagementConfigurations)
UnitilsTransactionManager
init
in interface UnitilsTransactionManager
transactionManagementConfigurations
- Set of possible providers of a spring PlatformTransactionManager
, not nullpublic DataSource getTransactionalDataSource(DataSource dataSource)
TransactionAwareDataSourceProxy
getTransactionalDataSource
in interface UnitilsTransactionManager
dataSource
- The data source to wrap, not null
public void startTransaction(Object testObject)
startTransaction
in interface UnitilsTransactionManager
testObject
- The test object, not nullpublic void activateTransactionIfNeeded(Object testObject)
activateTransactionIfNeeded
in interface UnitilsTransactionManager
protected void doStartTransaction(Object testObject, UnitilsTransactionManagementConfiguration transactionManagementConfiguration)
public void commit(Object testObject)
commit
in interface UnitilsTransactionManager
testObject
- The test object, not nullpublic void rollback(Object testObject)
rollback
in interface UnitilsTransactionManager
testObject
- The test object, not nullprotected org.springframework.transaction.TransactionDefinition createTransactionDefinition(Object testObject)
TransactionDefinition
object containing the
necessary transaction parameters. Simply returns a default
DefaultTransactionDefinition
object with the 'propagation
required' attribute
testObject
- The test object, not null
protected UnitilsTransactionManagementConfiguration getTransactionManagementConfiguration(Object testObject)
protected void setTransactionManagementConfigurations(Set<UnitilsTransactionManagementConfiguration> transactionManagementConfigurationsSet)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |