From 263a32a83acd0512d357fd864bfffcc175b93611 Mon Sep 17 00:00:00 2001 From: Vishwas Babu A J Date: Tue, 21 Oct 2014 19:25:54 -0700 Subject: [PATCH] fixing failures for Hook integration test --- .../integrationtests/HookIntegrationTest.java | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/HookIntegrationTest.java b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/HookIntegrationTest.java index 6f8a2c0c0..2e7479f44 100644 --- a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/HookIntegrationTest.java +++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/HookIntegrationTest.java @@ -52,13 +52,26 @@ public class HookIntegrationTest { this.hookHelper.createHook(payloadURL); final Integer createdOfficeID = this.officeHelper.createOffice("01 January 2012"); try { - // sleep for a three seconds to increase the likelihood of the - // previous request for creating office completing - TimeUnit.SECONDS.sleep(3); - final String json = RestAssured.get(payloadURL.replace("?", "")).asString(); - final Integer notificationOfficeId = JsonPath.with(json).get("officeId"); - assertEquals("Equality check for created officeId and hook received payload officeId", createdOfficeID, notificationOfficeId); - System.out.println("Notification Office Id - " + notificationOfficeId); + + /** + * sleep for a three seconds after each failure to increase the + * likelihood of the previous request for creating office completing + **/ + + for (int i = 0; i < 6; i++) { + try { + final String json = RestAssured.get(payloadURL.replace("?", "")).asString(); + final Integer notificationOfficeId = JsonPath.with(json).get("officeId"); + assertEquals("Equality check for created officeId and hook received payload officeId", createdOfficeID, + notificationOfficeId); + System.out.println("Notification Office Id - " + notificationOfficeId); + i = 6; + } catch (Exception e) { + TimeUnit.SECONDS.sleep(3); + i++; + } + } + } catch (final Exception e) { if (e instanceof HttpHostConnectException) { fail("Failed to connect to https://echo-webhook.herokuapp.com platform"); @@ -67,5 +80,4 @@ public class HookIntegrationTest { } } - }