use of org.mule.tck.testmodels.mule.TestTransaction in project mule by mulesoft.
the class TransactionCoordinationTestCase method testRollbackCurrentTransactionWithSuspendedTransaction.
@Test
public void testRollbackCurrentTransactionWithSuspendedTransaction() throws Exception {
assertThat(tc.getTransaction(), nullValue());
TestTransaction xaTx = spy(new TestTransaction(muleContext));
xaTx.setXA(true);
Transaction tx = spy(new TestTransaction(muleContext));
tc.bindTransaction(xaTx);
tc.suspendCurrentTransaction();
tc.bindTransaction(tx);
tc.rollbackCurrentTransaction();
tc.resumeSuspendedTransaction();
assertThat((TestTransaction) tc.getTransaction(), is(xaTx));
verify(xaTx, times(1)).suspend();
verify(xaTx, times(1)).resume();
verify(tx, times(1)).rollback();
}
use of org.mule.tck.testmodels.mule.TestTransaction in project mule by mulesoft.
the class TransactionCoordinationTestCase method testResumeXaTransactionIfAvailableWithNoTx.
@Test
public void testResumeXaTransactionIfAvailableWithNoTx() throws Exception {
assertThat(tc.getTransaction(), nullValue());
tc.resumeXaTransactionIfAvailable();
Transaction tx = spy(new TestTransaction(muleContext));
tc.bindTransaction(tx);
tc.resumeXaTransactionIfAvailable();
verify(tx, times(0)).resume();
}
use of org.mule.tck.testmodels.mule.TestTransaction in project mule by mulesoft.
the class ProactorStreamProcessingStrategyTestCase method tx.
@Override
@Description("When the ProactorProcessingStrategy is configured and a transaction is active processing fails with an error")
public void tx() throws Exception {
flow = flowBuilder.get().processors(cpuLightProcessor, cpuIntensiveProcessor, blockingProcessor).build();
flow.initialise();
flow.start();
TransactionCoordination.getInstance().bindTransaction(new TestTransaction(muleContext));
expectedException.expect(MessagingException.class);
expectedException.expectCause(instanceOf(DefaultMuleException.class));
expectedException.expectCause(hasMessage(equalTo(TRANSACTIONAL_ERROR_MESSAGE)));
processFlow(testEvent());
}
Aggregations