use of com.microsoft.azure.sdk.iot.device.transport.NoRetry in project azure-iot-sdk-java by Azure.
the class SendMessagesErrInjTests method sendMessagesWithTcpConnectionDropNotifiesUserIfRetryExpires.
@Test
@ContinuousIntegrationTest
public void sendMessagesWithTcpConnectionDropNotifiesUserIfRetryExpires() throws Exception {
if (testInstance.protocol == HTTPS || (testInstance.protocol == MQTT_WS && testInstance.authenticationType != SAS) || testInstance.useHttpProxy) {
// MQTT_WS + x509 is not supported for sending messages
return;
}
this.testInstance.setup();
testInstance.identity.getClient().setRetryPolicy(new NoRetry());
Message tcpConnectionDropErrorInjectionMessageUnrecoverable = ErrorInjectionHelper.tcpConnectionDropErrorInjectionMessage(1, 100000);
IotHubServicesCommon.sendMessagesExpectingUnrecoverableConnectionLossAndTimeout(testInstance.identity.getClient(), testInstance.protocol, tcpConnectionDropErrorInjectionMessageUnrecoverable, testInstance.authenticationType);
// reset back to default
testInstance.identity.getClient().setRetryPolicy(new ExponentialBackoffWithJitter());
}
use of com.microsoft.azure.sdk.iot.device.transport.NoRetry in project azure-iot-sdk-java by Azure.
the class SendMessagesErrInjTests method errorInjectionTestFlowNoDisconnect.
private void errorInjectionTestFlowNoDisconnect(Message errorInjectionMessage, IotHubStatusCode expectedStatus, boolean noRetry) throws IOException, IotHubException, URISyntaxException, InterruptedException, ModuleClientException, GeneralSecurityException {
// Arrange
if (noRetry) {
testInstance.identity.getClient().setRetryPolicy(new NoRetry());
}
testInstance.identity.getClient().open();
// Act
MessageAndResult errorInjectionMsgAndRet = new MessageAndResult(errorInjectionMessage, IotHubStatusCode.OK_EMPTY);
IotHubServicesCommon.sendMessageAndWaitForResponse(testInstance.identity.getClient(), errorInjectionMsgAndRet, RETRY_MILLISECONDS, SEND_TIMEOUT_MILLISECONDS, this.testInstance.protocol);
// time for the error injection to take effect on the service side
Thread.sleep(2000);
MessageAndResult normalMessageAndExpectedResult = new MessageAndResult(new Message("test message"), expectedStatus);
IotHubServicesCommon.sendMessageAndWaitForResponse(testInstance.identity.getClient(), normalMessageAndExpectedResult, RETRY_MILLISECONDS, SEND_TIMEOUT_MILLISECONDS, this.testInstance.protocol);
testInstance.identity.getClient().closeNow();
}
use of com.microsoft.azure.sdk.iot.device.transport.NoRetry in project azure-iot-sdk-java by Azure.
the class TransportClientTest method setRetryPolicySetIfOneRegisteredDeviceClient.
// Tests_SRS_TRANSPORTCLIENT_28_002: [The function shall set the retry policies to all registered device clients.]
@Test
public void setRetryPolicySetIfOneRegisteredDeviceClient() {
// arrange
IotHubClientProtocol iotHubClientProtocol = IotHubClientProtocol.AMQPS;
TransportClient transportClient = new TransportClient(iotHubClientProtocol);
ArrayList<DeviceClient> deviceClientList = new ArrayList<>();
deviceClientList.add(mockDeviceClient);
Deencapsulation.setField(transportClient, "deviceClientList", deviceClientList);
new NonStrictExpectations() {
{
mockDeviceClient.getConfig();
result = mockDeviceClientConfig;
}
};
// act
transportClient.setRetryPolicy(new NoRetry());
// assert
new Verifications() {
{
mockDeviceClientConfig.setRetryPolicy((RetryPolicy) any);
times = 1;
}
};
}
use of com.microsoft.azure.sdk.iot.device.transport.NoRetry in project azure-iot-sdk-java by Azure.
the class TransportClientTest method setRetryPolicyDoNothingIfNoRegisteredDeviceClient.
// Tests_SRS_TRANSPORTCLIENT_28_001: [The function shall throw UnsupportedOperationException if there is no registered device client]
@Test(expected = UnsupportedOperationException.class)
public void setRetryPolicyDoNothingIfNoRegisteredDeviceClient() {
// arrange
IotHubClientProtocol iotHubClientProtocol = IotHubClientProtocol.AMQPS;
TransportClient transportClient = new TransportClient(iotHubClientProtocol);
ArrayList<DeviceClient> deviceClientList = new ArrayList<>();
Deencapsulation.setField(transportClient, "deviceClientList", deviceClientList);
// act
transportClient.setRetryPolicy(new NoRetry());
}
Aggregations