use of org.mule.runtime.core.privileged.transaction.xa.IllegalTransactionStateException in project mule by mulesoft.
the class TransactionCoordinationTestCase method testBindTransactionWithAlreadyBound.
@Test
public void testBindTransactionWithAlreadyBound() throws Exception {
assertThat(tc.getTransaction(), nullValue());
Transaction tx = mock(Transaction.class);
tc.bindTransaction(tx);
assertEquals(tx, tc.getTransaction());
try {
Transaction tx2 = mock(Transaction.class);
tc.bindTransaction(tx2);
fail();
} catch (IllegalTransactionStateException e) {
// expected
}
tc.unbindTransaction(tx);
}
use of org.mule.runtime.core.privileged.transaction.xa.IllegalTransactionStateException in project mule by mulesoft.
the class ValidateTransactionalStateInterceptorTestCase method testTransactionalState.
@Test
public void testTransactionalState() throws Exception {
boolean shouldThrowException = resultMap.get(hasTransactionInContext).get(transactionConfig);
Exception thrownException = null;
CoreEvent result = null;
if (hasTransactionInContext) {
TransactionCoordination.getInstance().bindTransaction(mockTransaction);
}
ValidateTransactionalStateInterceptor<CoreEvent> interceptor = new ValidateTransactionalStateInterceptor<>(new ExecuteCallbackInterceptor<CoreEvent>(), transactionConfig, false);
try {
result = interceptor.execute(() -> mockMuleEvent, new ExecutionContext());
} catch (IllegalTransactionStateException e) {
thrownException = e;
}
if (shouldThrowException) {
assertThat(thrownException, notNullValue());
assertThat(thrownException, instanceOf(IllegalTransactionStateException.class));
} else {
assertThat(result, is(mockMuleEvent));
}
}
Aggregations