use of jakarta.transaction.NotSupportedException in project spring-framework by spring-projects.
the class JtaTransactionManagerTests method jtaTransactionManagerWithNotSupportedExceptionOnNestedBegin.
@Test
public void jtaTransactionManagerWithNotSupportedExceptionOnNestedBegin() throws Exception {
UserTransaction ut = mock(UserTransaction.class);
given(ut.getStatus()).willReturn(Status.STATUS_ACTIVE);
willThrow(new NotSupportedException("not supported")).given(ut).begin();
assertThatExceptionOfType(NestedTransactionNotSupportedException.class).isThrownBy(() -> {
JtaTransactionManager ptm = newJtaTransactionManager(ut);
TransactionTemplate tt = new TransactionTemplate(ptm);
tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_NESTED);
tt.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
// something transactional
}
});
});
}
Aggregations