Search in sources :

Example 1 with IotHubGatewayTimeoutException

use of com.microsoft.azure.sdk.iot.service.exceptions.IotHubGatewayTimeoutException in project azure-iot-sdk-java by Azure.

the class DeviceMethodIT method invokeMethod_recoverFromTimeout_succeed.

@Test
public void invokeMethod_recoverFromTimeout_succeed() throws Exception {
    // Arrange
    TestDevice testDevice = devices.get(0);
    try {
        methodServiceClient.invoke(testDevice.getDeviceId(), METHOD_DELAY_IN_MILLISECONDS, (long) 5, CONNECTION_TIMEOUT, "7000");
        assert true;
    } catch (IotHubGatewayTimeoutException expected) {
    //Don't do anything. Expected throw.
    }
    // Act
    MethodResult result = methodServiceClient.invoke(testDevice.getDeviceId(), METHOD_DELAY_IN_MILLISECONDS, RESPONSE_TIMEOUT, CONNECTION_TIMEOUT, "100");
    testDevice.waitIotHub(1, 10);
    // Assert
    assertNotNull(result);
    assertEquals((long) METHOD_SUCCESS, (long) result.getStatus());
    assertEquals(METHOD_DELAY_IN_MILLISECONDS + ":succeed", result.getPayload());
    assertEquals(0, testDevice.getStatusError());
}
Also used : IotHubGatewayTimeoutException(com.microsoft.azure.sdk.iot.service.exceptions.IotHubGatewayTimeoutException) MethodResult(com.microsoft.azure.sdk.iot.service.devicetwin.MethodResult) Test(org.junit.Test)

Aggregations

MethodResult (com.microsoft.azure.sdk.iot.service.devicetwin.MethodResult)1 IotHubGatewayTimeoutException (com.microsoft.azure.sdk.iot.service.exceptions.IotHubGatewayTimeoutException)1 Test (org.junit.Test)1