use of org.springframework.transaction.PlatformTransactionManager in project cucumber-jvm by cucumber.
the class SpringTransactionHooksTest method setUp.
@Before
public void setUp() {
target = new SpringTransactionHooks() {
@Override
public PlatformTransactionManager obtainPlatformTransactionManager() {
return mockedPlatformTransactionManager;
}
};
target.setBeanFactory(mockedBeanFactory);
}
use of org.springframework.transaction.PlatformTransactionManager in project grails-core by grails.
the class ChainedTransactionManager method commit.
/*
* (non-Javadoc)
* @see org.springframework.transaction.PlatformTransactionManager#commit(org.springframework.transaction.TransactionStatus)
*/
public void commit(TransactionStatus status) throws TransactionException {
MultiTransactionStatus multiTransactionStatus = (MultiTransactionStatus) status;
boolean commit = true;
Exception commitException = null;
PlatformTransactionManager commitExceptionTransactionManager = null;
for (PlatformTransactionManager transactionManager : reverse(transactionManagers)) {
if (commit) {
try {
multiTransactionStatus.commit(transactionManager);
} catch (Exception ex) {
commit = false;
commitException = ex;
commitExceptionTransactionManager = transactionManager;
}
} else {
try {
multiTransactionStatus.rollback(transactionManager);
} catch (Exception ex) {
LOGGER.warn("Rollback exception (after commit) (" + transactionManager + ") " + ex.getMessage(), ex);
}
}
}
if (multiTransactionStatus.isNewSynchonization()) {
synchronizationManager.clearSynchronization();
}
if (commitException != null) {
boolean firstTransactionManagerFailed = commitExceptionTransactionManager == getLastTransactionManager();
int transactionState = firstTransactionManagerFailed ? HeuristicCompletionException.STATE_ROLLED_BACK : HeuristicCompletionException.STATE_MIXED;
throw new HeuristicCompletionException(transactionState, commitException);
}
}
use of org.springframework.transaction.PlatformTransactionManager in project grails-core by grails.
the class ChainedTransactionManagerTests method shouldCompleteSuccessfully.
@Test
public void shouldCompleteSuccessfully() throws Exception {
PlatformTransactionManager transactionManager = createNonFailingTransactionManager("single");
setupTransactionManagers(transactionManager);
createAndCommitTransaction();
assertThat(transactionManager, isCommitted());
}
use of org.springframework.transaction.PlatformTransactionManager in project grails-core by grails.
the class ChainedTransactionManagerTests method shouldCommitAllRegisteredTransactionManagers.
@Test
public void shouldCommitAllRegisteredTransactionManagers() {
PlatformTransactionManager first = createNonFailingTransactionManager("first");
PlatformTransactionManager second = createNonFailingTransactionManager("second");
setupTransactionManagers(first, second);
createAndCommitTransaction();
assertThat(first, isCommitted());
assertThat(second, isCommitted());
}
use of org.springframework.transaction.PlatformTransactionManager in project grails-core by grails.
the class ChainedTransactionManagerTests method shouldCommitInReverseOrder.
@Test
public void shouldCommitInReverseOrder() {
PlatformTransactionManager first = createNonFailingTransactionManager("first");
PlatformTransactionManager second = createNonFailingTransactionManager("second");
setupTransactionManagers(first, second);
createAndCommitTransaction();
assertThat("second tm commited before first ", commitTime(first) >= commitTime(second), is(true));
}
Aggregations