From 63d70eecee42b0ad77dc35c3dca093f8369dff05 Mon Sep 17 00:00:00 2001 From: Alan Davis Date: Wed, 12 Feb 2014 08:00:32 +0000 Subject: [PATCH] Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud) 59746: Merged V4.2-BUG-FIX (4.2.2) to HEAD-BUG-FIX (Cloud/4.3) 59561: Merged DEV to V4.2-BUG-FIX (4.2.1) 59104: MNT-10197 : Intermittent test failure: RenditionServicePermissionsTest.userWithoutDeleteAccessTo(etc) Implemented a retry mechanism to solve the intermittent test failures. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@62185 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../RenditionServicePermissionsTest.java | 41 ++++++++++++------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/source/test-java/org/alfresco/repo/rendition/RenditionServicePermissionsTest.java b/source/test-java/org/alfresco/repo/rendition/RenditionServicePermissionsTest.java index 339cb5a2c6..1939c7c3f9 100644 --- a/source/test-java/org/alfresco/repo/rendition/RenditionServicePermissionsTest.java +++ b/source/test-java/org/alfresco/repo/rendition/RenditionServicePermissionsTest.java @@ -19,10 +19,6 @@ package org.alfresco.repo.rendition; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.io.Serializable; import java.util.List; import java.util.Map; @@ -74,6 +70,8 @@ import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.rules.RuleChain; +import static org.junit.Assert.*; + /** * @author Neil McErlean * @since 3.3 @@ -419,19 +417,34 @@ public class RenditionServicePermissionsTest return null; } }); - - // FIXME Yuck. Sleeping to wait for the completion of the above async action. - Thread.sleep(2000); - - // Now to check that the node has no renditions as the previous one should have been deleted. - transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + + int waitTime = 200; + int numRetries = 20; + // Try and retry for 200ms up to 4s + for (int i = 1 ; i <= numRetries; i++) { - public Void execute() throws Throwable + Thread.sleep(waitTime * i); + + // Now to check that the node has no renditions as the previous one should have been deleted. + Boolean hasNoRenditions = transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() { - assertTrue(renditionService.getRenditions(imgNode).isEmpty()); - return null; + public Boolean execute() throws Throwable + { + return renditionService.getRenditions(imgNode).isEmpty(); + } + }); + + if (hasNoRenditions) + { + //test passed + break; } - }); + else if (i == numRetries) + { + // the last try, time to fail + fail("The node should have no renditions."); + } + } } /**