use of cn.taketoday.transaction.MockCallbackPreferringTransactionManager in project today-infrastructure by TAKETODAY.
the class AbstractTransactionAspectTests method transactionExceptionPropagatedWithCallbackPreference.
@Test
public void transactionExceptionPropagatedWithCallbackPreference() throws Throwable {
TransactionAttribute txatt = new DefaultTransactionAttribute();
MapTransactionAttributeSource tas = new MapTransactionAttributeSource();
tas.register(exceptionalMethod, txatt);
MockCallbackPreferringTransactionManager ptm = new MockCallbackPreferringTransactionManager();
TestBean tb = new TestBean();
ITestBean itb = (ITestBean) advised(tb, ptm, tas);
checkTransactionStatus(false);
assertThatExceptionOfType(OptimisticLockingFailureException.class).isThrownBy(() -> itb.exceptional(new OptimisticLockingFailureException("")));
checkTransactionStatus(false);
assertThat(ptm.getDefinition()).isSameAs(txatt);
assertThat(ptm.getStatus().isRollbackOnly()).isFalse();
}
use of cn.taketoday.transaction.MockCallbackPreferringTransactionManager in project today-framework by TAKETODAY.
the class AbstractTransactionAspectTests method transactionShouldSucceedWithCallbackPreference.
/**
* Check that a transaction is created and committed using
* CallbackPreferringPlatformTransactionManager.
*/
@Test
public void transactionShouldSucceedWithCallbackPreference() throws Exception {
TransactionAttribute txatt = new DefaultTransactionAttribute();
MapTransactionAttributeSource tas = new MapTransactionAttributeSource();
tas.register(getNameMethod, txatt);
MockCallbackPreferringTransactionManager ptm = new MockCallbackPreferringTransactionManager();
TestBean tb = new TestBean();
ITestBean itb = (ITestBean) advised(tb, ptm, tas);
checkTransactionStatus(false);
itb.getName();
checkTransactionStatus(false);
assertThat(ptm.getDefinition()).isSameAs(txatt);
assertThat(ptm.getStatus().isRollbackOnly()).isFalse();
}
use of cn.taketoday.transaction.MockCallbackPreferringTransactionManager in project today-framework by TAKETODAY.
the class AbstractTransactionAspectTests method transactionExceptionPropagatedWithCallbackPreference.
@Test
public void transactionExceptionPropagatedWithCallbackPreference() throws Throwable {
TransactionAttribute txatt = new DefaultTransactionAttribute();
MapTransactionAttributeSource tas = new MapTransactionAttributeSource();
tas.register(exceptionalMethod, txatt);
MockCallbackPreferringTransactionManager ptm = new MockCallbackPreferringTransactionManager();
TestBean tb = new TestBean();
ITestBean itb = (ITestBean) advised(tb, ptm, tas);
checkTransactionStatus(false);
assertThatExceptionOfType(OptimisticLockingFailureException.class).isThrownBy(() -> itb.exceptional(new OptimisticLockingFailureException("")));
checkTransactionStatus(false);
assertThat(ptm.getDefinition()).isSameAs(txatt);
assertThat(ptm.getStatus().isRollbackOnly()).isFalse();
}
use of cn.taketoday.transaction.MockCallbackPreferringTransactionManager in project today-infrastructure by TAKETODAY.
the class AbstractTransactionAspectTests method transactionShouldSucceedWithCallbackPreference.
/**
* Check that a transaction is created and committed using
* CallbackPreferringPlatformTransactionManager.
*/
@Test
public void transactionShouldSucceedWithCallbackPreference() throws Exception {
TransactionAttribute txatt = new DefaultTransactionAttribute();
MapTransactionAttributeSource tas = new MapTransactionAttributeSource();
tas.register(getNameMethod, txatt);
MockCallbackPreferringTransactionManager ptm = new MockCallbackPreferringTransactionManager();
TestBean tb = new TestBean();
ITestBean itb = (ITestBean) advised(tb, ptm, tas);
checkTransactionStatus(false);
itb.getName();
checkTransactionStatus(false);
assertThat(ptm.getDefinition()).isSameAs(txatt);
assertThat(ptm.getStatus().isRollbackOnly()).isFalse();
}
Aggregations