use of tests.integration.com.microsoft.azure.sdk.iot.device.Success in project azure-iot-sdk-java by Azure.
the class SendMessagesIT method SendMessagesOverHttps.
@Test
public void SendMessagesOverHttps() throws URISyntaxException, IOException {
String messageString = "Java client e2e test message over Https protocol";
Message msg = new Message(messageString);
DeviceClient client = new DeviceClient(DeviceConnectionString.get(iotHubConnectionString, deviceHttps), IotHubClientProtocol.HTTPS);
client.open();
for (int i = 0; i < NUM_MESSAGES_PER_CONNECTION; ++i) {
try {
Success messageSent = new Success();
EventCallback callback = new EventCallback();
client.sendEventAsync(msg, callback, messageSent);
Integer waitDuration = 0;
while (!messageSent.getResult()) {
Thread.sleep(RETRY_MILLISECONDS);
if ((waitDuration += RETRY_MILLISECONDS) > SEND_TIMEOUT_MILLISECONDS) {
break;
}
}
if (!messageSent.getResult()) {
Assert.fail("Sending message over HTTPS protocol failed");
}
} catch (Exception e) {
Assert.fail("Sending message over HTTPS protocol failed");
}
}
client.closeNow();
}
use of tests.integration.com.microsoft.azure.sdk.iot.device.Success in project azure-iot-sdk-java by Azure.
the class SendMessagesIT method SendMessagesOverAmqps.
@Test
public void SendMessagesOverAmqps() throws URISyntaxException, IOException, InterruptedException {
String messageString = "Java client e2e test message over Amqps protocol";
Message msg = new Message(messageString);
DeviceClient client = new DeviceClient(DeviceConnectionString.get(iotHubConnectionString, deviceAmqps), IotHubClientProtocol.AMQPS);
client.open();
for (int i = 0; i < NUM_MESSAGES_PER_CONNECTION; ++i) {
try {
Success messageSent = new Success();
EventCallback callback = new EventCallback();
client.sendEventAsync(msg, callback, messageSent);
Integer waitDuration = 0;
while (!messageSent.getResult()) {
Thread.sleep(RETRY_MILLISECONDS);
if ((waitDuration += RETRY_MILLISECONDS) > SEND_TIMEOUT_MILLISECONDS) {
break;
}
}
if (!messageSent.getResult()) {
Assert.fail("Sending message over AMQPS protocol failed");
}
} catch (Exception e) {
Assert.fail("Sending message over AMQPS protocol failed");
}
}
client.closeNow();
}
use of tests.integration.com.microsoft.azure.sdk.iot.device.Success in project azure-iot-sdk-java by Azure.
the class SendMessagesIT method SendMessagesOverMqtt.
@Test
public void SendMessagesOverMqtt() throws URISyntaxException, IOException {
String messageString = "Java client e2e test message over Mqtt protocol";
Message msg = new Message(messageString);
DeviceClient client = new DeviceClient(DeviceConnectionString.get(iotHubConnectionString, deviceMqtt), IotHubClientProtocol.MQTT);
client.open();
for (int i = 0; i < NUM_MESSAGES_PER_CONNECTION; ++i) {
try {
Success messageSent = new Success();
EventCallback callback = new EventCallback();
client.sendEventAsync(msg, callback, messageSent);
Integer waitDuration = 0;
while (!messageSent.getResult()) {
Thread.sleep(RETRY_MILLISECONDS);
if ((waitDuration += RETRY_MILLISECONDS) > SEND_TIMEOUT_MILLISECONDS) {
break;
}
}
if (!messageSent.getResult()) {
Assert.fail("Sending message over MQTT protocol failed");
}
} catch (Exception e) {
Assert.fail("Sending message over MQTT protocol failed");
}
}
client.closeNow();
}
Aggregations