diff --git a/source/test-java/org/alfresco/repo/web/scripts/tagging/TaggingServiceTest.java b/source/test-java/org/alfresco/repo/web/scripts/tagging/TaggingServiceTest.java index 48ef418b26..4dc8816b98 100644 --- a/source/test-java/org/alfresco/repo/web/scripts/tagging/TaggingServiceTest.java +++ b/source/test-java/org/alfresco/repo/web/scripts/tagging/TaggingServiceTest.java @@ -195,6 +195,7 @@ public class TaggingServiceTest extends BaseWebScriptTest public void testTagCountSearch() throws Exception { + int TAGS_NUM = 1200; boolean removeTestFolder = false; boolean removeTagScope = false; FileInfo testFolderInfo = null; @@ -213,7 +214,7 @@ public class TaggingServiceTest extends BaseWebScriptTest //generate content with tag UserTransaction transaction = transactionService.getUserTransaction(); transaction.begin(); - for (int i = 0; i < 1200; i++) + for (int i = 0; i < TAGS_NUM; i++) { FileInfo file = this.fileFolderService.create(testFolderInfo.getNodeRef(), "testDoc" + i + ".txt", ContentModel.TYPE_CONTENT); this.taggingService.addTag(file.getNodeRef(), tagName); @@ -251,12 +252,22 @@ public class TaggingServiceTest extends BaseWebScriptTest } // tag count via tagScope API - response = sendRequest(new GetRequest("api/tagscopes/node/" + testRoot.toString().replace(":/", "") + "/tags"), 200); - jsonObj = new JSONObject(response.getContentAsString()); - tagsArr = jsonObj.getJSONArray("tags"); - number = getTagNumber(tagName, tagsArr); - assertEquals("Checking a search via tagScope API: Tag number must be 1200, because node is a tag scope.", 1200, number); - + int BREAK_COUNT = 80; + int counter = 1; + do + { + response = sendRequest(new GetRequest("api/tagscopes/node/" + testRoot.toString().replace(":/", "") + "/tags"), 200); + jsonObj = new JSONObject(response.getContentAsString()); + tagsArr = jsonObj.getJSONArray("tags"); + number = getTagNumber(tagName, tagsArr); + if (number == TAGS_NUM) + { + break; + } + Thread.sleep(500); + } + while (counter ++ <= BREAK_COUNT); + assertEquals("Checking a search via tagScope API: Tag number must be "+ TAGS_NUM + ", because node is a tag scope.", TAGS_NUM, number); } finally {