Search in sources :

Example 1 with TestTransaction

use of org.mule.tck.testmodels.mule.TestTransaction in project mule by mulesoft.

the class TransactionCoordinationTestCase method testRollbackCurrentTransaction.

@Test
public void testRollbackCurrentTransaction() throws Exception {
    assertThat(tc.getTransaction(), nullValue());
    tc.commitCurrentTransaction();
    TestTransaction testTransaction = spy(new TestTransaction(muleContext));
    tc.bindTransaction(testTransaction);
    tc.rollbackCurrentTransaction();
    assertThat(tc.getTransaction(), nullValue());
    verify(testTransaction, times(1)).rollback();
}
Also used : TestTransaction(org.mule.tck.testmodels.mule.TestTransaction) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 2 with TestTransaction

use of org.mule.tck.testmodels.mule.TestTransaction in project mule by mulesoft.

the class TransactionCoordinationTestCase method testResumeXaTransactionTwice.

@Test(expected = IllegalTransactionStateException.class)
public void testResumeXaTransactionTwice() throws Exception {
    assertThat(tc.getTransaction(), nullValue());
    TestTransaction tx = spy(new TestTransaction(muleContext));
    tx.setXA(true);
    tc.bindTransaction(tx);
    tc.resumeSuspendedTransaction();
    tc.resumeSuspendedTransaction();
}
Also used : TestTransaction(org.mule.tck.testmodels.mule.TestTransaction) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 3 with TestTransaction

use of org.mule.tck.testmodels.mule.TestTransaction in project mule by mulesoft.

the class TransactionCoordinationTestCase method testResumeXaTransactionIfAvailableWithTx.

@Test
public void testResumeXaTransactionIfAvailableWithTx() throws Exception {
    assertThat(tc.getTransaction(), nullValue());
    tc.resumeXaTransactionIfAvailable();
    TestTransaction tx = spy(new TestTransaction(muleContext));
    tx.setXA(true);
    tc.bindTransaction(tx);
    tc.suspendCurrentTransaction();
    tc.resumeXaTransactionIfAvailable();
    verify(tx, times(1)).suspend();
    verify(tx, times(1)).resume();
}
Also used : TestTransaction(org.mule.tck.testmodels.mule.TestTransaction) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 4 with TestTransaction

use of org.mule.tck.testmodels.mule.TestTransaction in project mule by mulesoft.

the class TransactionCoordinationTestCase method testCommitCurrentTransaction.

@Test
public void testCommitCurrentTransaction() throws Exception {
    assertThat(tc.getTransaction(), nullValue());
    tc.commitCurrentTransaction();
    TestTransaction testTransaction = spy(new TestTransaction(muleContext));
    tc.bindTransaction(testTransaction);
    tc.commitCurrentTransaction();
    assertThat(tc.getTransaction(), nullValue());
    verify(testTransaction, times(1)).commit();
}
Also used : TestTransaction(org.mule.tck.testmodels.mule.TestTransaction) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 5 with TestTransaction

use of org.mule.tck.testmodels.mule.TestTransaction in project mule by mulesoft.

the class TransactionCoordinationTestCase method testResolveTransactionForRollback.

@Test
public void testResolveTransactionForRollback() throws Exception {
    assertThat(tc.getTransaction(), nullValue());
    TestTransaction tx = spy(new TestTransaction(muleContext));
    tx.setXA(true);
    tc.bindTransaction(tx);
    tx.setRollbackOnly();
    tc.resolveTransaction();
    assertThat(tc.getTransaction(), nullValue());
    verify(tx, times(1)).rollback();
}
Also used : TestTransaction(org.mule.tck.testmodels.mule.TestTransaction) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

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