use of org.alfresco.util.transaction.TransactionListenerAdapter in project alfresco-repository by Alfresco.
the class RetryingTransactionHelperTest method testStartNewTransaction.
@Test
public void testStartNewTransaction() throws Exception {
// MNT-10096
class CustomListenerAdapter extends TransactionListenerAdapter {
private String newTxnId;
@Override
public void afterRollback() {
newTxnId = txnHelper.doInTransaction(new RetryingTransactionCallback<String>() {
@Override
public String execute() throws Throwable {
return AlfrescoTransactionSupport.getTransactionId();
}
}, true, false);
}
}
UserTransaction txn = transactionService.getUserTransaction();
txn.begin();
String txnId = AlfrescoTransactionSupport.getTransactionId();
CustomListenerAdapter listener = new CustomListenerAdapter();
AlfrescoTransactionSupport.bindListener(listener);
txn.rollback();
assertFalse("New transaction has not started", txnId.equals(listener.newTxnId));
}
Aggregations