mqttManager.disconnect();
mqttManager.disconnect();
@Test public void testDisconnectWhenNotConnected() throws Exception { MockMqttClient mockClient = new MockMqttClient(); AWSIotMqttManager testClient = new AWSIotMqttManager("test-client", Region.getRegion(Regions.US_EAST_1), TEST_ENDPOINT_PREFIX); testClient.setMqttClient(mockClient); mockClient.isConnected = false; testClient.disconnect(); assertEquals(0, mockClient.disconnectCalls); }
public void disconnectClick(final View view) { try { mqttManager.disconnect(); } catch (Exception e) { Log.e(LOG_TAG, "Disconnect error.", e); } }
public void disconnect(final View view) { try { mqttManager.disconnect(); } catch (Exception e) { Log.e(LOG_TAG, "Disconnect error.", e); } } }
mqttManager.disconnect(); Thread.sleep(3000);
mqttManager.disconnect(); Thread.sleep(3000);
@Test public void testPublishWithCallbackDisconnected() throws Exception { MockMqttClient mockClient = new MockMqttClient(); AWSIotMqttManager testClient = new AWSIotMqttManager("test-client", Region.getRegion(Regions.US_EAST_1), TEST_ENDPOINT_PREFIX); testClient.setMqttClient(mockClient); testClient.setOfflinePublishQueueBound(100); TestClientStatusCallback csb = new TestClientStatusCallback(); TestMessageDeliveryCallback mdcb = new TestMessageDeliveryCallback(); KeyStore testKeystore = AWSIotKeystoreHelper .getIotKeystore(CERT_ID, KEYSTORE_PATH, KEYSTORE_NAME, KEYSTORE_PASSWORD); testClient.connect(testKeystore, csb); mockClient.mockConnectSuccess(); testClient.disconnect(); testClient.publishString("test payload 0", "test/topic", AWSIotMqttQos.QOS0, mdcb, "TEST_TOKEN"); // we don't queue when Disconnected (user disconnect or auto-reconnect exhausted) assertEquals(0, testClient.getMqttMessageQueue().size()); // callback not called assertEquals(1, mdcb.statuses.size()); assertEquals(1, mdcb.userDatas.size()); }
@Test(expected = AmazonClientException.class) public void testPublishDisconnected() throws Exception { MockMqttClient mockClient = new MockMqttClient(); AWSIotMqttManager testClient = new AWSIotMqttManager("test-client", Region.getRegion(Regions.US_EAST_1), TEST_ENDPOINT_PREFIX); testClient.setMqttClient(mockClient); testClient.setOfflinePublishQueueBound(100); TestClientStatusCallback csb = new TestClientStatusCallback(); KeyStore testKeystore = AWSIotKeystoreHelper .getIotKeystore(CERT_ID, KEYSTORE_PATH, KEYSTORE_NAME, KEYSTORE_PASSWORD); testClient.connect(testKeystore, csb); mockClient.mockConnectSuccess(); testClient.disconnect(); testClient.publishString("test payload 0", "test/topic", AWSIotMqttQos.QOS0); // we don't queue when Disconnected (user disconnect or auto-reconnect exhausted) assertEquals(0, testClient.getMqttMessageQueue().size()); }
@Test public void testLostConnectUserDisconnect() throws Exception { MockMqttClient mockClient = new MockMqttClient(); AWSIotMqttManager testClient = new AWSIotMqttManager("test-client", Region.getRegion(Regions.US_EAST_1), TEST_ENDPOINT_PREFIX); testClient.setMqttClient(mockClient); TestClientStatusCallback csb = new TestClientStatusCallback(); KeyStore testKeystore = AWSIotKeystoreHelper.getIotKeystore(CERT_ID, KEYSTORE_PATH, KEYSTORE_NAME, KEYSTORE_PASSWORD); testClient.connect(testKeystore, csb); mockClient.mockConnectSuccess(); assertEquals(1, mockClient.connectCalls); assertTrue(mockClient.mostRecentOptions.isCleanSession()); testClient.disconnect(); mockClient.mockCallback.connectionLost(new Exception("test")); assertEquals(1, mockClient.connectCalls); } /*
@Test(expected = AmazonClientException.class) public void testDisconnectException() throws Exception { MockMqttClient mockClient = new MockMqttClient(); mockClient.throwsExceptionOnDisconnect = true; AWSIotMqttManager testClient = new AWSIotMqttManager("test-client", Region.getRegion(Regions.US_EAST_1), TEST_ENDPOINT_PREFIX); testClient.setMqttClient(mockClient); TestClientStatusCallback csb = new TestClientStatusCallback(); KeyStore testKeystore = AWSIotKeystoreHelper.getIotKeystore(CERT_ID, KEYSTORE_PATH, KEYSTORE_NAME, KEYSTORE_PASSWORD); testClient.connect(testKeystore, csb); mockClient.mockConnectSuccess(); assertEquals(MqttManagerConnectionState.Connected, testClient.getConnectionState()); testClient.disconnect(); }
mqttManager.disconnect();
mqttManager.disconnect();
mqttManager.disconnect();
mqttManager.disconnect();
mqttManager.disconnect();
@Test public void testDisconnect() throws Exception { MockMqttClient mockClient = new MockMqttClient(); AWSIotMqttManager testClient = new AWSIotMqttManager("test-client", Region.getRegion(Regions.US_EAST_1), TEST_ENDPOINT_PREFIX); testClient.setMqttClient(mockClient); TestClientStatusCallback csb = new TestClientStatusCallback(); KeyStore testKeystore = AWSIotKeystoreHelper.getIotKeystore(CERT_ID, KEYSTORE_PATH, KEYSTORE_NAME, KEYSTORE_PASSWORD); testClient.connect(testKeystore, csb); mockClient.mockConnectSuccess(); assertEquals(MqttManagerConnectionState.Connected, testClient.getConnectionState()); testClient.disconnect(); assertEquals(MqttManagerConnectionState.Disconnected, testClient.getConnectionState()); assertEquals(1, mockClient.connectCalls); assertEquals(1, mockClient.disconnectCalls); }
@Test public void testConnectDisconnectConnect() throws Exception { MockMqttClient mockClient = new MockMqttClient(); AWSIotMqttManager testClient = new AWSIotMqttManager("test-client", Region.getRegion(Regions.US_EAST_1), TEST_ENDPOINT_PREFIX); testClient.setMqttClient(mockClient); testClient.setAutoReconnect(false); TestClientStatusCallback csb = new TestClientStatusCallback(); KeyStore testKeystore = AWSIotKeystoreHelper.getIotKeystore(CERT_ID, KEYSTORE_PATH, KEYSTORE_NAME, KEYSTORE_PASSWORD); testClient.connect(testKeystore, csb); mockClient.mockConnectSuccess(); assertEquals(MqttManagerConnectionState.Connected, testClient.getConnectionState()); testClient.disconnect(); assertEquals(MqttManagerConnectionState.Disconnected, testClient.getConnectionState()); testClient.connect(testKeystore, csb); mockClient.mockConnectSuccess(); assertEquals(2, mockClient.connectCalls); }
testClient.disconnect(); assertEquals(MqttManagerConnectionState.Disconnected, testClient.getConnectionState());