Search in sources :

Example 26 with MuleTransactionConfig

use of org.mule.runtime.core.api.transaction.MuleTransactionConfig in project mule by mulesoft.

the class TransactionalExecutionTemplateTestCase method testActionBeginOrJoinAndNoTx.

@Test
public void testActionBeginOrJoinAndNoTx() throws Exception {
    MuleTransactionConfig config = new MuleTransactionConfig(TransactionConfig.ACTION_BEGIN_OR_JOIN);
    ExecutionTemplate executionTemplate = createExecutionTemplate(config);
    config.setFactory(new TestTransactionFactory(mockTransaction));
    Object result = executionTemplate.execute(getEmptyTransactionCallback());
    assertThat(result, is(RETURN_VALUE));
    verify(mockTransaction).commit();
    verify(mockTransaction, never()).rollback();
    assertThat(TransactionCoordination.getInstance().getTransaction(), IsNull.<Object>nullValue());
}
Also used : TestTransactionFactory(org.mule.tck.testmodels.mule.TestTransactionFactory) MuleTransactionConfig(org.mule.runtime.core.api.transaction.MuleTransactionConfig) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 27 with MuleTransactionConfig

use of org.mule.runtime.core.api.transaction.MuleTransactionConfig in project mule by mulesoft.

the class TransactionalExecutionTemplateTestCase method testActionIndifferentConfig.

@Test
public void testActionIndifferentConfig() throws Exception {
    MuleTransactionConfig config = new MuleTransactionConfig(TransactionConfig.ACTION_INDIFFERENT);
    ExecutionTemplate executionTemplate = createExecutionTemplate(config);
    Object result = executionTemplate.execute(getEmptyTransactionCallback());
    assertThat(result, is(RETURN_VALUE));
    assertThat(TransactionCoordination.getInstance().getTransaction(), IsNull.<Object>nullValue());
}
Also used : MuleTransactionConfig(org.mule.runtime.core.api.transaction.MuleTransactionConfig) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 28 with MuleTransactionConfig

use of org.mule.runtime.core.api.transaction.MuleTransactionConfig in project mule by mulesoft.

the class TransactionalExecutionTemplateTestCase method testActionNoneAndNoTx.

@Test
public void testActionNoneAndNoTx() throws Exception {
    MuleTransactionConfig config = new MuleTransactionConfig(TransactionConfig.ACTION_NONE);
    ExecutionTemplate executionTemplate = createExecutionTemplate(config);
    Object result = executionTemplate.execute(getEmptyTransactionCallback());
    assertThat(result, is(RETURN_VALUE));
}
Also used : MuleTransactionConfig(org.mule.runtime.core.api.transaction.MuleTransactionConfig) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Aggregations

MuleTransactionConfig (org.mule.runtime.core.api.transaction.MuleTransactionConfig)28 Test (org.junit.Test)23 SmallTest (org.mule.tck.size.SmallTest)20 TestTransactionFactory (org.mule.tck.testmodels.mule.TestTransactionFactory)7 TransactionalExecutionTemplate (org.mule.runtime.core.api.execution.TransactionalExecutionTemplate)4 ExecutionCallback (org.mule.runtime.core.api.execution.ExecutionCallback)3 ExecutionTemplate (org.mule.runtime.core.api.execution.ExecutionTemplate)3 TransactionConfig (org.mule.runtime.core.api.transaction.TransactionConfig)3 XaTransactionFactory (org.mule.runtime.core.privileged.transaction.xa.XaTransactionFactory)3 Transaction (javax.transaction.Transaction)2 ExternalTransactionAwareTransactionFactory (org.mule.runtime.core.api.transaction.ExternalTransactionAwareTransactionFactory)2 XaTransaction (org.mule.runtime.core.privileged.transaction.XaTransaction)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 DefaultMuleException (org.mule.runtime.api.exception.DefaultMuleException)1 MuleException (org.mule.runtime.api.exception.MuleException)1 SchedulerBusyException (org.mule.runtime.api.scheduler.SchedulerBusyException)1 TransactionType (org.mule.runtime.api.tx.TransactionType)1 MuleContext (org.mule.runtime.core.api.MuleContext)1 FlowConstruct (org.mule.runtime.core.api.construct.FlowConstruct)1 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)1