use of com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol in project azure-iot-sdk-java by Azure.
the class FeedbackReceiverTest method constructor_save_properties.
// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_002: [The constructor shall store deviceId]
// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_003: [The constructor shall create a new instance of AmqpReceive object]
@Test
public void constructor_save_properties() throws Exception {
// Arrange
String hostName = "aaa";
String userName = "bbb";
String sasToken = "ccc";
String deviceId = "xxx";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
new Expectations() {
{
amqpReceive = new AmqpReceive(anyString, anyString, anyString, iotHubServiceClientProtocol);
}
};
// Act
FeedbackReceiver feedbackReceiver = new FeedbackReceiver(hostName, userName, sasToken, iotHubServiceClientProtocol, deviceId);
// Assert
assertEquals(deviceId, Deencapsulation.getField(feedbackReceiver, "deviceId"));
}
use of com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol in project azure-iot-sdk-java by Azure.
the class FeedbackReceiverTest method close_receiver_null_without_deviceId.
// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_006: [The function shall throw IOException if the member AMQPReceive object has not been initialized]
// Assert
@Test(expected = IOException.class)
public void close_receiver_null_without_deviceId() throws Exception {
// Arrange
String hostName = "xxx";
String userName = "xxx";
String sasToken = "xxx";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
FeedbackReceiver feedbackReceiver = new FeedbackReceiver(hostName, userName, sasToken, iotHubServiceClientProtocol);
Deencapsulation.setField(feedbackReceiver, "amqpReceive", null);
// Act
feedbackReceiver.close();
}
use of com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol in project azure-iot-sdk-java by Azure.
the class FeedbackReceiverTest method open_async_without_deviceId.
// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_011: [The function shall create an async wrapper around the open() function call]
@Test
public void open_async_without_deviceId() throws Exception {
// Arrange
String hostName = "xxx";
String userName = "xxx";
String sasToken = "xxx";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
FeedbackReceiver feedbackReceiver = new FeedbackReceiver(hostName, userName, sasToken, iotHubServiceClientProtocol);
// Assert
new Expectations() {
{
amqpReceive.open();
feedbackReceiver.open();
}
};
// Act
CompletableFuture<Void> completableFuture = feedbackReceiver.openAsync();
completableFuture.get();
}
use of com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol in project azure-iot-sdk-java by Azure.
the class FeedbackReceiverTest method constructor_input_sasToken_empty.
// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_001: [The constructor shall throw IllegalArgumentException if any the input string is null or empty]
// Assert
@Test(expected = IllegalArgumentException.class)
public void constructor_input_sasToken_empty() throws Exception {
// Arrange
String hostName = "xxx";
String userName = "xxx";
String sasToken = "";
String deviceId = "xxx";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
// Act
FeedbackReceiver feedbackReceiver = new FeedbackReceiver(hostName, userName, sasToken, iotHubServiceClientProtocol, deviceId);
}
use of com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol in project azure-iot-sdk-java by Azure.
the class FileUploadNotificationReceiverTest method openAsync.
// Tests_SRS_SERVICE_SDK_JAVA_FILEUPLOADNOTIFICATIONRECEIVER_25_010: [ The function shall create an async wrapper around the open() function call ]
@Test
public void openAsync() throws Exception {
// Arrange
final String hostName = "xxx";
final String userName = "xxx";
final String sasToken = "xxx";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
FileUploadNotificationReceiver fileUploadNotificationReceiver = Deencapsulation.newInstance(FileUploadNotificationReceiver.class, hostName, userName, sasToken, iotHubServiceClientProtocol);
// Act
CompletableFuture<Void> completableFuture = fileUploadNotificationReceiver.openAsync();
completableFuture.get();
// Assert
new Verifications() {
{
amqpFileUploadNotificationReceive.open();
times = 1;
fileUploadNotificationReceiver.open();
times = 1;
}
};
}
Aggregations