@Test(expected = IllegalArgumentException.class) public void testCreateClientNullClientId() throws Exception { AWSIotMqttManager testClient = new AWSIotMqttManager(null, Region.getRegion(Regions.US_EAST_1), TEST_ENDPOINT_PREFIX); }
@Test(expected = IllegalArgumentException.class) public void testCreateClientNullEndpointPrefix() throws Exception { AWSIotMqttManager testClient = new AWSIotMqttManager("test-client", Region.getRegion(Regions.US_EAST_1), null); }
@Test(expected = IllegalArgumentException.class) public void testSetKeepAliveIllegalValue() throws Exception { AWSIotMqttManager testClient = new AWSIotMqttManager("test-client", Region.getRegion(Regions.US_EAST_1), TEST_ENDPOINT_PREFIX); testClient.setKeepAlive(-10); }
@Test(expected = IllegalArgumentException.class) public void testReconnectTimeoutException() throws Exception { AWSIotMqttManager testClient = new AWSIotMqttManager("test-client", Region.getRegion(Regions.US_EAST_1), TEST_ENDPOINT_PREFIX); testClient.setReconnectRetryLimits(10, 5); }
@Test public void mqttConnect_USEast1_ATS_Endpoint() throws Exception { DescribeEndpointRequest request = new DescribeEndpointRequest(); request.setEndpointType("iot:Data-ATS"); DescribeEndpointResult result = iotClient.describeEndpoint(request); endpointPrefix = result.getEndpointAddress().split("\\.")[0]; System.out.println("Endpoint prefix: " + endpointPrefix); String endpoint = endpointPrefix + ".iot." + Region.getRegion(Regions.US_EAST_1).getName() + ".amazonaws.com"; System.out.println("Endpoint: " + endpoint); AWSIotMqttManager mqttManager = new AWSIotMqttManager("int-test-w-certs", endpoint); mqttConnect(mqttManager); }
@Test public void mqttConnect_USEast1_EndpointPrefix_Region() throws Exception { DescribeEndpointRequest request = new DescribeEndpointRequest(); request.setEndpointType("iot:Data"); DescribeEndpointResult result = iotClient.describeEndpoint(request); endpointPrefix = result.getEndpointAddress().split("\\.")[0]; System.out.println("Endpoint prefix: " + endpointPrefix); AWSIotMqttManager mqttManager = new AWSIotMqttManager("int-test-w-certs", Region.getRegion(Regions.US_EAST_1), endpointPrefix); mqttConnect(mqttManager); }
@Test public void testGetOfflinePublishQueueBound() throws Exception { AWSIotMqttManager testClient = new AWSIotMqttManager("test-client", Region.getRegion(Regions.US_EAST_1), TEST_ENDPOINT_PREFIX); assertEquals(100, (int) testClient.getOfflinePublishQueueBound()); }
@Test public void testGetKeepAlive() throws Exception { AWSIotMqttManager testClient = new AWSIotMqttManager("test-client", Region.getRegion(Regions.US_EAST_1), TEST_ENDPOINT_PREFIX); assertEquals(300, testClient.getKeepAlive()); }
@Test public void testGetIsOfflinePublishQueueEnabled() throws Exception { AWSIotMqttManager testClient = new AWSIotMqttManager("test-client", Region.getRegion(Regions.US_EAST_1), TEST_ENDPOINT_PREFIX); assertTrue(testClient.isOfflinePublishQueueEnabled()); }
@Test public void testIsReadyToPublishFalseNull() throws Exception { AWSIotMqttManager testClient = new AWSIotMqttManager("test-client", Region.getRegion(Regions.US_EAST_1), TEST_ENDPOINT_PREFIX); testClient.setMqttClient(null); assertFalse(testClient.isReadyToPublish()); }
@Test public void testSetMaxAutoReconnectAttemptsForever() throws Exception { AWSIotMqttManager testClient = new AWSIotMqttManager("test-client", Region.getRegion(Regions.US_EAST_1), TEST_ENDPOINT_PREFIX); testClient.setMaxAutoReconnectAttepts(-1); // -1 = retry forever assertEquals(-1, testClient.getMaxAutoReconnectAttempts()); }
@Test(expected = IllegalArgumentException.class) public void testSetMaxAutoReconnectAttemptsIllegalValue() throws Exception { AWSIotMqttManager testClient = new AWSIotMqttManager("test-client", Region.getRegion(Regions.US_EAST_1), TEST_ENDPOINT_PREFIX); testClient.setMaxAutoReconnectAttepts(-5); assertEquals(6, testClient.getMaxAutoReconnectAttempts()); }
@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 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 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); }
@Test(expected = IllegalArgumentException.class) public void testConnectWebSocketNullCredentialsProvider() 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(); testClient.connect((AWSCredentialsProvider)null, csb); }
@Test(expected = IllegalArgumentException.class) public void testConnectNullKeyStore() 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(); testClient.connect((KeyStore) null, csb); assertEquals(0, mockClient.connectCalls); }
@Test public void testEnableMetricsCollection() { AWSIotMqttManager testClient = new AWSIotMqttManager("test-client", Region.getRegion(Regions.US_EAST_1), TEST_ENDPOINT_PREFIX); assertTrue(testClient.isMetricsEnabled()); testClient.setMetricsIsEnabled(false); assertFalse(testClient.isMetricsEnabled()); }
public void testLegalReconnectTimeEqual() throws Exception { AWSIotMqttManager testClient = new AWSIotMqttManager("test-client", Region.getRegion(Regions.US_EAST_1), null); assertEquals(4, testClient.getMaxReconnectRetryTime()); testClient.setReconnectRetryLimits(16, 16); assertEquals(16, testClient.getMinReconnectRetryTime()); assertEquals(16, testClient.getMaxReconnectRetryTime()); }
@Test public void testReconnectTimeout() throws Exception { AWSIotMqttManager testClient = new AWSIotMqttManager("test-client", Region.getRegion(Regions.US_EAST_1), TEST_ENDPOINT_PREFIX); assertEquals(4, testClient.getReconnectTimeout()); testClient.setReconnectTimeout(10); assertEquals(10, testClient.getReconnectTimeout()); testClient.setReconnectRetryLimits(20, 30); assertEquals(20, testClient.getMinReconnectRetryTime()); assertEquals(30, testClient.getMaxReconnectRetryTime()); }