use of com.microsoft.azure.sdk.iot.service.FeedbackReceiver in project azure-iot-sdk-java by Azure.
the class FeedbackReceiverTest method constructor_input_sasToken_empty_without_deviceId.
// 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_without_deviceId() throws Exception {
// Arrange
String hostName = "xxx";
String userName = "xxx";
String sasToken = "";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
// Act
FeedbackReceiver feedbackReceiver = new FeedbackReceiver(hostName, userName, sasToken, iotHubServiceClientProtocol);
}
use of com.microsoft.azure.sdk.iot.service.FeedbackReceiver in project azure-iot-sdk-java by Azure.
the class FeedbackReceiverTest method close_async_without_deviceId.
// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_012: [The function shall create an async wrapper around the close() function call]
@Test
public void close_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.close();
feedbackReceiver.close();
}
};
// Act
CompletableFuture<Void> completableFuture = feedbackReceiver.closeAsync();
completableFuture.get();
}
use of com.microsoft.azure.sdk.iot.service.FeedbackReceiver in project azure-iot-sdk-java by Azure.
the class FeedbackReceiverTest method receive_with_timeout_receiver_null.
// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_009: [The function shall throw IOException if the member AMQPReceive object has not been initialized]
// Assert
@Test(expected = IOException.class)
public void receive_with_timeout_receiver_null() throws Exception {
// Arrange
long timeoutMs = 1000;
String hostName = "xxx";
String userName = "xxx";
String sasToken = "xxx";
String deviceId = "xxx";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
FeedbackReceiver feedbackReceiver = new FeedbackReceiver(hostName, userName, sasToken, iotHubServiceClientProtocol, deviceId);
Deencapsulation.setField(feedbackReceiver, "amqpReceive", null);
// Act
feedbackReceiver.receive(timeoutMs);
}
use of com.microsoft.azure.sdk.iot.service.FeedbackReceiver in project azure-iot-sdk-java by Azure.
the class FeedbackReceiverTest method close_receiver_null.
// 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() throws Exception {
// Arrange
String hostName = "xxx";
String userName = "xxx";
String sasToken = "xxx";
String deviceId = "xxx";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
FeedbackReceiver feedbackReceiver = new FeedbackReceiver(hostName, userName, sasToken, iotHubServiceClientProtocol, deviceId);
Deencapsulation.setField(feedbackReceiver, "amqpReceive", null);
// Act
feedbackReceiver.close();
}
use of com.microsoft.azure.sdk.iot.service.FeedbackReceiver in project azure-iot-sdk-java by Azure.
the class ServiceClientTest method getFeedbackReceiver_good_case_without_deviceid.
// Tests_SRS_SERVICE_SDK_JAVA_SERVICECLIENT_12_017: [The function shall create a FeedbackReceiver object and returns with it]
@Test
public void getFeedbackReceiver_good_case_without_deviceid() throws Exception {
// Arrange
String iotHubName = "IOTHUBNAME";
String hostName = "HOSTNAME";
String sharedAccessKeyName = "ACCESSKEYNAME";
String policyName = "SharedAccessKey";
String sharedAccessKey = "1234567890abcdefghijklmnopqrstvwxyz=";
String connectionString = "HostName=" + hostName + "." + iotHubName + ";SharedAccessKeyName=" + sharedAccessKeyName + ";" + policyName + "=" + sharedAccessKey;
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
ServiceClient serviceClient = ServiceClient.createFromConnectionString(connectionString, iotHubServiceClientProtocol);
// Assert
new Expectations() {
{
feedbackReceiver = new FeedbackReceiver(anyString, anyString, anyString, iotHubServiceClientProtocol);
}
};
// Act
FeedbackReceiver feedbackReceiver = serviceClient.getFeedbackReceiver();
// Assert
assertNotEquals(null, feedbackReceiver);
}
Aggregations