use of org.mule.tck.testmodels.mule.TestTransaction in project mule by mulesoft.
the class TransactionAwareWorkQueueProcessingStrategyTestCase method tx.
@Test
@Override
@Description("Unlike with the MultiReactorProcessingStrategy, the TransactionAwareWorkQueueProcessingStrategy does not fail if a transaction " + "is active, but rather executes these events synchronously in the caller thread transparently.")
public void tx() throws Exception {
flow = flowBuilder.get().processors(cpuLightProcessor, cpuIntensiveProcessor, blockingProcessor).build();
flow.initialise();
flow.start();
TransactionCoordination.getInstance().bindTransaction(new TestTransaction(muleContext));
processFlow(testEvent());
assertThat(threads, hasSize(equalTo(1)));
assertThat(threads, not(hasItem(startsWith(CPU_LIGHT))));
assertThat(threads, not(hasItem(startsWith(IO))));
assertThat(threads, not(hasItem(startsWith(CPU_INTENSIVE))));
assertThat(threads, not(hasItem(startsWith(CUSTOM))));
}
use of org.mule.tck.testmodels.mule.TestTransaction in project mule by mulesoft.
the class TransactionAwareWorkQueueStreamProcessingStrategyTestCase method tx.
@Override
@Description("Unlike with the MultiReactorProcessingStrategy, the TransactionAwareWorkQueueProcessingStrategy does not fail if a transaction " + "is active, but rather executes these events synchronously in the caller thread transparently.")
public void tx() throws Exception {
flow = flowBuilder.get().processors(cpuLightProcessor, cpuIntensiveProcessor, blockingProcessor).build();
flow.initialise();
flow.start();
TransactionCoordination.getInstance().bindTransaction(new TestTransaction(muleContext));
processFlow(testEvent());
assertThat(threads, hasSize(equalTo(1)));
assertThat(threads, not(hasItem(startsWith(CPU_LIGHT))));
assertThat(threads, not(hasItem(startsWith(IO))));
assertThat(threads, not(hasItem(startsWith(CPU_INTENSIVE))));
assertThat(threads, not(hasItem(startsWith(CUSTOM))));
}
use of org.mule.tck.testmodels.mule.TestTransaction in project mule by mulesoft.
the class WorkQueueProcessingStrategyTestCase method tx.
@Override
@Description("When the WorkQueueProcessingStrategy 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());
}
use of org.mule.tck.testmodels.mule.TestTransaction in project mule by mulesoft.
the class TransactionCoordinationTestCase method testCommitCurrentTransactionWithSuspendedTransaction.
@Test
public void testCommitCurrentTransactionWithSuspendedTransaction() 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.commitCurrentTransaction();
tc.resumeSuspendedTransaction();
assertThat((TestTransaction) tc.getTransaction(), is(xaTx));
verify(xaTx, times(1)).suspend();
verify(xaTx, times(1)).resume();
verify(tx, times(1)).commit();
}
use of org.mule.tck.testmodels.mule.TestTransaction in project mule by mulesoft.
the class TransactionCoordinationTestCase method testResolveTransactionForCommit.
@Test
public void testResolveTransactionForCommit() throws Exception {
assertThat(tc.getTransaction(), nullValue());
TestTransaction tx = spy(new TestTransaction(muleContext));
tx.setXA(true);
tc.bindTransaction(tx);
tc.resolveTransaction();
assertThat(tc.getTransaction(), nullValue());
verify(tx, times(1)).commit();
}
Aggregations