use of org.mule.runtime.core.api.transaction.MuleTransactionConfig in project mule by mulesoft.
the class TransactionalExecutionTemplateTestCase method testActionJoinIfPossibleAndTx.
@Test
public void testActionJoinIfPossibleAndTx() throws Exception {
TransactionCoordination.getInstance().bindTransaction(mockTransaction);
MuleTransactionConfig config = new MuleTransactionConfig(TransactionConfig.ACTION_JOIN_IF_POSSIBLE);
ExecutionTemplate executionTemplate = createExecutionTemplate(config);
Object result = executionTemplate.execute(getEmptyTransactionCallback());
assertThat(result, is(RETURN_VALUE));
verify(mockTransaction, never()).commit();
verify(mockTransaction, never()).rollback();
assertThat((TestTransaction) TransactionCoordination.getInstance().getTransaction(), Is.is(mockTransaction));
}
use of org.mule.runtime.core.api.transaction.MuleTransactionConfig in project mule by mulesoft.
the class TransactionalExecutionTemplateTestCase method testActionBeginOrJoinAndTx.
@Test
public void testActionBeginOrJoinAndTx() throws Exception {
TransactionCoordination.getInstance().bindTransaction(mockTransaction);
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, never()).commit();
verify(mockTransaction, never()).rollback();
assertThat((TestTransaction) TransactionCoordination.getInstance().getTransaction(), is(mockTransaction));
}
use of org.mule.runtime.core.api.transaction.MuleTransactionConfig in project mule by mulesoft.
the class TransactionalExecutionTemplateTestCase method testActionNoneAndTxForCommit.
@Test
public void testActionNoneAndTxForCommit() throws Exception {
TransactionCoordination.getInstance().bindTransaction(mockTransaction);
MuleTransactionConfig config = new MuleTransactionConfig(TransactionConfig.ACTION_NONE);
ExecutionTemplate executionTemplate = createExecutionTemplate(config);
Object result = executionTemplate.execute(getEmptyTransactionCallback());
assertThat(result, is(RETURN_VALUE));
verify(mockTransaction, never()).commit();
verify(mockTransaction, never()).rollback();
}
use of org.mule.runtime.core.api.transaction.MuleTransactionConfig in project mule by mulesoft.
the class TransactionalExecutionTemplateTestCase method testActionAlwaysJoinAndNoTx.
@Test(expected = IllegalTransactionStateException.class)
public void testActionAlwaysJoinAndNoTx() throws Exception {
MuleTransactionConfig config = new MuleTransactionConfig(TransactionConfig.ACTION_ALWAYS_JOIN);
ExecutionTemplate executionTemplate = createExecutionTemplate(config);
executionTemplate.execute(getRollbackTransactionCallback());
}
use of org.mule.runtime.core.api.transaction.MuleTransactionConfig in project mule by mulesoft.
the class TransactionalExecutionTemplateTestCase method testActionAlwaysJoinAndTx.
@Test
public void testActionAlwaysJoinAndTx() throws Exception {
TransactionCoordination.getInstance().bindTransaction(mockTransaction);
MuleTransactionConfig config = new MuleTransactionConfig(TransactionConfig.ACTION_ALWAYS_JOIN);
ExecutionTemplate executionTemplate = createExecutionTemplate(config);
Object result = executionTemplate.execute(getRollbackTransactionCallback());
assertThat(result, is(RETURN_VALUE));
verify(mockTransaction, never()).commit();
verify(mockTransaction, never()).rollback();
assertThat((TestTransaction) TransactionCoordination.getInstance().getTransaction(), is(mockTransaction));
}
Aggregations