Search in sources :

Example 6 with TransactionListenerAdapter

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));
}
Also used : UserTransaction(javax.transaction.UserTransaction) TransactionListenerAdapter(org.alfresco.util.transaction.TransactionListenerAdapter) RetryingTransactionCallback(org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback) BaseSpringTest(org.alfresco.util.BaseSpringTest) Test(org.junit.Test)

Aggregations

TransactionListenerAdapter (org.alfresco.util.transaction.TransactionListenerAdapter)6 RetryingTransactionCallback (org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback)5 UnknownHostException (java.net.UnknownHostException)2 Date (java.util.Date)2 Action (org.alfresco.service.cmr.action.Action)2 ActionServiceTransientException (org.alfresco.service.cmr.action.ActionServiceTransientException)2 CancellableAction (org.alfresco.service.cmr.action.CancellableAction)2 NodeRef (org.alfresco.service.cmr.repository.NodeRef)2 UserTransaction (javax.transaction.UserTransaction)1 RetryingTransactionHelper (org.alfresco.repo.transaction.RetryingTransactionHelper)1 BaseSpringTest (org.alfresco.util.BaseSpringTest)1 Pair (org.alfresco.util.Pair)1 Test (org.junit.Test)1 JobDetail (org.quartz.JobDetail)1 SchedulerException (org.quartz.SchedulerException)1 Trigger (org.quartz.Trigger)1 MimeMessageHelper (org.springframework.mail.javamail.MimeMessageHelper)1