@Test public void testSetOfflinePublishQueueBound() throws Exception { AWSIotMqttManager testClient = new AWSIotMqttManager("test-client", Region.getRegion(Regions.US_EAST_1), TEST_ENDPOINT_PREFIX); testClient.setOfflinePublishQueueBound(50); assertEquals(50, (int) testClient.getOfflinePublishQueueBound()); }
@Test(expected = IllegalArgumentException.class) public void testSetOfflinePublishQueueBoundNegative() throws Exception { AWSIotMqttManager testClient = new AWSIotMqttManager("test-client", Region.getRegion(Regions.US_EAST_1), TEST_ENDPOINT_PREFIX); testClient.setOfflinePublishQueueBound(-5); assertEquals(100, (int) testClient.getOfflinePublishQueueBound()); }
@Test public void testPublishWithCallbackConnecting() 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); assertEquals(AWSIotMqttClientStatusCallback.AWSIotMqttClientStatus.Connecting, csb.statuses.get(0)); // publish, though not yet connected 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 testPublishConnecting() 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); assertEquals(AWSIotMqttClientStatusCallback.AWSIotMqttClientStatus.Connecting, csb.statuses.get(0)); // publish, though not yet connected 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 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()); }
Region.getRegion(Regions.US_EAST_1), TEST_ENDPOINT_PREFIX); testClient.setMqttClient(mockClient); testClient.setOfflinePublishQueueBound(10); testClient.setFullQueueToKeepOldestMessages();
Region.getRegion(Regions.US_EAST_1), TEST_ENDPOINT_PREFIX); testClient.setMqttClient(mockClient); testClient.setOfflinePublishQueueBound(10);
Region.getRegion(Regions.US_EAST_1), TEST_ENDPOINT_PREFIX); testClient.setMqttClient(mockClient); testClient.setOfflinePublishQueueBound(10); testClient.setFullQueueToKeepOldestMessages();
testClient.setConnectionStabilityTime(25); testClient.setOfflinePublishQueueEnabled(false); testClient.setOfflinePublishQueueBound(50);