Search in sources :

Example 16 with TestTransaction

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();
}
Also used : TestTransaction(org.mule.tck.testmodels.mule.TestTransaction) TestTransaction(org.mule.tck.testmodels.mule.TestTransaction) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 17 with TestTransaction

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();
}
Also used : TestTransaction(org.mule.tck.testmodels.mule.TestTransaction) TestTransaction(org.mule.tck.testmodels.mule.TestTransaction) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 18 with TestTransaction

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());
}
Also used : DefaultMuleException(org.mule.runtime.api.exception.DefaultMuleException) TestTransaction(org.mule.tck.testmodels.mule.TestTransaction) Description(io.qameta.allure.Description)

Aggregations

TestTransaction (org.mule.tck.testmodels.mule.TestTransaction)18 Test (org.junit.Test)12 SmallTest (org.mule.tck.size.SmallTest)9 Description (io.qameta.allure.Description)7 DefaultMuleException (org.mule.runtime.api.exception.DefaultMuleException)3 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)1 Transaction (org.mule.runtime.core.api.transaction.Transaction)1