org.unitils.database.transaction
Interface UnitilsTransactionManager

All Known Implementing Classes:
DefaultUnitilsTransactionManager

public interface UnitilsTransactionManager

Defines the contract for implementations that enable unit tests managed by unitils to be executed in a transaction.

Author:
Filip Neven, Tim Ducheyne

Method Summary
 void activateTransactionIfNeeded(Object testObject)
           
 void commit(Object testObject)
          Commits the currently active transaction.
 DataSource getTransactionalDataSource(DataSource dataSource)
          Wraps the given DataSource in a transactional proxy.
 void init(Set<UnitilsTransactionManagementConfiguration> transactionManagementConfigurations)
          Initialize the transaction manager
 void rollback(Object testObject)
          Rolls back the currently active transaction.
 void startTransaction(Object testObject)
          Starts a transaction.
 

Method Detail

init

void init(Set<UnitilsTransactionManagementConfiguration> transactionManagementConfigurations)
Initialize the transaction manager

Parameters:
transactionManagementConfigurations - Set of possible providers of a spring PlatformTransactionManager, not null

getTransactionalDataSource

DataSource getTransactionalDataSource(DataSource dataSource)
Wraps the given DataSource in a transactional proxy.

The DataSource returned will make sure that, for the duration of a transaction, the same java.sql.Connection is returned, and that invocations on the close() method of these connections are suppressed.

Parameters:
dataSource - The data source to wrap, not null
Returns:
A transactional data source, not null

startTransaction

void startTransaction(Object testObject)
Starts a transaction.

Parameters:
testObject - The test instance, not null

commit

void commit(Object testObject)
Commits the currently active transaction. This transaction must have been initiated by calling startTransaction(Object) with the same testObject within the same thread.

Parameters:
testObject - The test instance, not null

rollback

void rollback(Object testObject)
Rolls back the currently active transaction. This transaction must have been initiated by calling startTransaction(Object) with the same testObject within the same thread.

Parameters:
testObject - The test instance, not null

activateTransactionIfNeeded

void activateTransactionIfNeeded(Object testObject)


Copyright © 2011. All Rights Reserved.