From 976bdb229272a785d518feb8db05a95139748c71 Mon Sep 17 00:00:00 2001 From: megala21 Date: Tue, 23 May 2017 12:03:05 +0530 Subject: [PATCH] Fixing issues --- .../common/MqttSubscriberClient.java | 29 ++++++- .../iot/integration/user/UserManagement.java | 12 +-- .../src/test/resources/testng.xml | 78 +------------------ 3 files changed, 32 insertions(+), 87 deletions(-) diff --git a/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/MqttSubscriberClient.java b/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/MqttSubscriberClient.java index cb8c2b6d..7df49ded 100644 --- a/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/MqttSubscriberClient.java +++ b/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/MqttSubscriberClient.java @@ -1,8 +1,29 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + package org.wso2.iot.integration.common; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.eclipse.paho.client.mqttv3.*; +import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; +import org.eclipse.paho.client.mqttv3.MqttCallback; +import org.eclipse.paho.client.mqttv3.MqttClient; +import org.eclipse.paho.client.mqttv3.MqttConnectOptions; +import org.eclipse.paho.client.mqttv3.MqttException; +import org.eclipse.paho.client.mqttv3.MqttMessage; import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; import java.util.ArrayList; @@ -11,7 +32,6 @@ import java.util.ArrayList; * This is a mqtt subscriber client to receive . */ public class MqttSubscriberClient implements MqttCallback { - private static Log log = LogFactory.getLog(MqttSubscriberClient.class); private ArrayList mqttMessages; @Override @@ -46,6 +66,7 @@ public class MqttSubscriberClient implements MqttCallback { connectOptions.setUserName(accessToken); connectOptions.setPassword("".toCharArray()); connectOptions.setCleanSession(true); + connectOptions.setKeepAliveInterval(300); client.connect(connectOptions); client.subscribe(topicName); } diff --git a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/user/UserManagement.java b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/user/UserManagement.java index d92f6733..53d672a7 100644 --- a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/user/UserManagement.java +++ b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/user/UserManagement.java @@ -34,11 +34,7 @@ import org.wso2.iot.integration.common.PayloadGenerator; import org.wso2.iot.integration.common.RestClient; import org.wso2.iot.integration.common.TestBase; import org.wso2.iot.integration.samples.VirtualFireAlarmTestCase; - -import java.sql.Timestamp; - -import static org.wso2.iot.integration.samples.VirtualFireAlarmTestCase.deviceId1; -import static org.wso2.iot.integration.samples.VirtualFireAlarmTestCase.deviceId2; +import static org.wso2.iot.integration.samples.VirtualFireAlarmTestCase.*; /** * This class contains integration tests for user management backend services. @@ -175,11 +171,15 @@ public class UserManagement extends TestBase { @Test(description = "Test whether data that is published is stored in analytics event table", dependsOnMethods = {"testRemoveUser"} ) public void testBatchDataPersistence() throws Exception { + String deviceId1 = + this.userMode == TestUserMode.TENANT_ADMIN ? tenantDeviceId1 : VirtualFireAlarmTestCase.deviceId1; + String deviceId2 = + this.userMode == TestUserMode.TENANT_ADMIN ? tenantDeviceId2 : VirtualFireAlarmTestCase.deviceId2; + long MilliSecondDifference = System.currentTimeMillis() - VirtualFireAlarmTestCase.currentTime; if (MilliSecondDifference < 300000) { Thread.sleep(300000 - MilliSecondDifference); } - Timestamp timestamp = new Timestamp(System.currentTimeMillis() - 7200000); String url = Constants.VirtualFireAlarmConstants.STATS_ENDPOINT + "/" + deviceId1; url += "?from=" + (VirtualFireAlarmTestCase.currentTime - 300000)/1000 + "&to=" + System.currentTimeMillis() /1000; diff --git a/modules/integration/tests-integration/src/test/resources/testng.xml b/modules/integration/tests-integration/src/test/resources/testng.xml index 60f425a0..2c08cfc8 100644 --- a/modules/integration/tests-integration/src/test/resources/testng.xml +++ b/modules/integration/tests-integration/src/test/resources/testng.xml @@ -33,6 +33,7 @@ + @@ -41,87 +42,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -