use of org.mule.tck.testmodels.mule.TestTransactionFactory in project mule by mulesoft.
the class TransactionalExecutionTemplateTestCase method testActionAlwaysBeginAndCommitTxAndCommitNewTx.
@Test
public void testActionAlwaysBeginAndCommitTxAndCommitNewTx() throws Exception {
expectedException.expect(IllegalTransactionStateException.class);
TransactionCoordination.getInstance().bindTransaction(mockTransaction);
MuleTransactionConfig config = new MuleTransactionConfig(TransactionConfig.ACTION_ALWAYS_BEGIN);
ExecutionTemplate executionTemplate = createExecutionTemplate(config);
config.setFactory(new TestTransactionFactory(mockNewTransaction));
executionTemplate.execute(getEmptyTransactionCallback());
}
use of org.mule.tck.testmodels.mule.TestTransactionFactory 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.tck.testmodels.mule.TestTransactionFactory 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());
}
Aggregations