From 055b18fb7042984664c74cee11f45988216ebc2e Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Wed, 21 Oct 2009 12:13:41 +0000 Subject: [PATCH] Removed test's assumptions about the specific concurrency failure - Reduced retry count to 1 to prevent 40x40 retries each doing DB lock waits - Removed testNestedWithoutPropogationOuterFailing git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@17063 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../RetryingTransactionHelperTest.java | 47 ++----------------- 1 file changed, 5 insertions(+), 42 deletions(-) diff --git a/source/java/org/alfresco/repo/transaction/RetryingTransactionHelperTest.java b/source/java/org/alfresco/repo/transaction/RetryingTransactionHelperTest.java index 6b0db570e7..2dac52f9a1 100644 --- a/source/java/org/alfresco/repo/transaction/RetryingTransactionHelperTest.java +++ b/source/java/org/alfresco/repo/transaction/RetryingTransactionHelperTest.java @@ -47,6 +47,7 @@ import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.ApplicationContextHelper; import org.apache.commons.lang.mutable.MutableInt; import org.hibernate.SessionFactory; +import org.hibernate.engine.TransactionHelper; import org.springframework.context.ApplicationContext; import org.springframework.dao.ConcurrencyFailureException; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; @@ -376,6 +377,8 @@ public class RetryingTransactionHelperTest extends TestCase @SuppressWarnings("unchecked") public void testNestedWithoutPropogationConcurrentUntilFailure() { + final RetryingTransactionHelper txnHelperForTest = transactionService.getRetryingTransactionHelper(); + txnHelperForTest.setMaxRetries(1); RetryingTransactionCallback callback = new RetryingTransactionCallback() { public Long execute() throws Throwable @@ -389,13 +392,13 @@ public class RetryingTransactionHelperTest extends TestCase } }; incrementCheckValue(); - txnHelper.doInTransaction(callbackInner, false, true); + txnHelperForTest.doInTransaction(callbackInner, false, true); return getCheckValue(); } }; try { - txnHelper.doInTransaction(callback); + txnHelperForTest.doInTransaction(callback); fail("Concurrent nested access not leading to failure"); } catch (Throwable e) @@ -405,46 +408,6 @@ public class RetryingTransactionHelperTest extends TestCase } } - /** - * Checks nesting of two transactions with requiresNew == true, - * but where the inner transaction fails writes values that the outer transaction - * fails on. - */ - public void testNestedWithoutPropogationOuterFailing() - { - RetryingTransactionCallback callback = new RetryingTransactionCallback() - { - private int maxCalls = 3; - private int callCount = 0; - public Long execute() throws Throwable - { - callCount++; - RetryingTransactionCallback callbackInner = new RetryingTransactionCallback() - { - public Long execute() throws Throwable - { - for (int i = 0; i < 5; i++) - { - incrementCheckValue(); - } - return getCheckValue(); - } - }; - // Increment the value so that the outer transaction is bound to the particular - // version of the data - incrementCheckValue(); - // Don't execute the inner transaction the last time around - if (callCount < maxCalls) - { - txnHelper.doInTransaction(callbackInner, false, true); - } - return getCheckValue(); - } - }; - long checkValue = txnHelper.doInTransaction(callback); - assertEquals("Check value not incremented", 11, checkValue); - } - public void testLostConnectionRecovery() { RetryingTransactionCallback killConnectionCallback = new RetryingTransactionCallback()