From a8b4699cb917e43857a3213850c403b9ddd5cc29 Mon Sep 17 00:00:00 2001 From: sinthuja Date: Fri, 23 Jun 2017 11:05:32 +0530 Subject: [PATCH] Fixing intermittent NPE in mobile QSG --- .../iot/integration/samples/MobileQSGTestCase.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/samples/MobileQSGTestCase.java b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/samples/MobileQSGTestCase.java index 0ea78ebc..bcc8bd6d 100644 --- a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/samples/MobileQSGTestCase.java +++ b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/samples/MobileQSGTestCase.java @@ -46,6 +46,7 @@ public class MobileQSGTestCase extends TestBase { super.init(TestUserMode.SUPER_TENANT_ADMIN); username1 = "alex"; username2 = "chris"; + this.client = new RestClient(backendHTTPSURL, Constants.APPLICATION_JSON, accessTokenString); } @Test(description = "This test case tests the execution of QSG script, whether it executes without any exceptions") @@ -57,7 +58,6 @@ public class MobileQSGTestCase extends TestBase { Runtime.getRuntime().exec(cmdArray, null, scriptFile); // Allow some time to finish its execution Thread.sleep(10000); - this.client = new RestClient(backendHTTPSURL, Constants.APPLICATION_JSON, accessTokenString); } @Test(description = "This test case tests whether user and roles are created as expected", dependsOnMethods = @@ -104,9 +104,11 @@ public class MobileQSGTestCase extends TestBase { @AfterClass(alwaysRun = true) public void tearDown() throws Exception { - String url = Constants.UserManagement.USER_ENDPOINT + "/" + username1; - client.delete(url); - url = Constants.UserManagement.USER_ENDPOINT + "/" + username2; - client.delete(url); + if (client != null) { + String url = Constants.UserManagement.USER_ENDPOINT + "/" + username1; + client.delete(url); + url = Constants.UserManagement.USER_ENDPOINT + "/" + username2; + client.delete(url); + } } }