possible fix for hooks related integration test failure

This commit is contained in:
Vishwas Babu A J
2014-10-18 16:19:45 -07:00
parent 733656685d
commit 21c4cdf002
@@ -8,6 +8,8 @@ package org.mifosplatform.integrationtests;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import java.util.concurrent.TimeUnit;
import org.apache.http.conn.HttpHostConnectException; import org.apache.http.conn.HttpHostConnectException;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@@ -43,16 +45,19 @@ public class HookIntegrationTest {
@Test @Test
public void shouldSendOfficeCreationNotification() { public void shouldSendOfficeCreationNotification() {
//Subject to https://echo-webhook.herokuapp.com being up // Subject to https://echo-webhook.herokuapp.com being up
//See http://www.jamesward.com/2014/06/11/testing-webhooks-was-a-pain-so-i-fixed-the-glitch // See
// http://www.jamesward.com/2014/06/11/testing-webhooks-was-a-pain-so-i-fixed-the-glitch
final String payloadURL = "http://echo-webhook.herokuapp.com:80/Z7RXoCBdLSFMDrpn?"; final String payloadURL = "http://echo-webhook.herokuapp.com:80/Z7RXoCBdLSFMDrpn?";
this.hookHelper.createHook(payloadURL); this.hookHelper.createHook(payloadURL);
final Integer createdOfficeID = this.officeHelper.createOffice("01 January 2012"); final Integer createdOfficeID = this.officeHelper.createOffice("01 January 2012");
try { 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 String json = RestAssured.get(payloadURL.replace("?", "")).asString();
final Integer notificationOfficeId = JsonPath.with(json).get("officeId"); final Integer notificationOfficeId = JsonPath.with(json).get("officeId");
assertEquals("Equality check for created officeId and hook received payload officeId", assertEquals("Equality check for created officeId and hook received payload officeId", createdOfficeID, notificationOfficeId);
createdOfficeID, notificationOfficeId);
System.out.println("Notification Office Id - " + notificationOfficeId); System.out.println("Notification Office Id - " + notificationOfficeId);
} catch (final Exception e) { } catch (final Exception e) {
if (e instanceof HttpHostConnectException) { if (e instanceof HttpHostConnectException) {