use of com.microsoft.azure.sdk.iot.service.FeedbackReceiver in project azure-iot-sdk-java by Azure.
the class FeedbackReceiverTest method receive_call_receive_timeout.
// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_008: [The function shall call receive(long timeoutMs) function with the default timeout]
@Test
public void receive_call_receive_timeout() 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);
// Assert
new Expectations() {
{
amqpReceive.receive(Deencapsulation.getField(feedbackReceiver, "DEFAULT_TIMEOUT_MS"));
}
};
// Act
feedbackReceiver.receive();
}
use of com.microsoft.azure.sdk.iot.service.FeedbackReceiver in project azure-iot-sdk-java by Azure.
the class FeedbackReceiverTest method close_call_receiver_close_without_deviceId.
// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_007: [The function shall call close() on the member AMQPReceive object]
@Test
public void close_call_receiver_close_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();
}
};
// Act
feedbackReceiver.close();
}
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_without_deviceId.
// 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_without_deviceId() throws Exception {
// Arrange
long timeoutMs = 1000;
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.receive(timeoutMs);
}
use of com.microsoft.azure.sdk.iot.service.FeedbackReceiver in project azure-iot-sdk-java by Azure.
the class ServiceClientTest method getFeedbackReceiver_good_case.
// 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() 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;
String deviceId = "XXX";
IotHubConnectionString iotHubConnectionString = IotHubConnectionStringBuilder.createConnectionString(connectionString);
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
ServiceClient serviceClient = ServiceClient.createFromConnectionString(connectionString, iotHubServiceClientProtocol);
// Assert
new Expectations() {
{
feedbackReceiver = new FeedbackReceiver(anyString, anyString, anyString, iotHubServiceClientProtocol, deviceId);
}
};
// Act
FeedbackReceiver feedbackReceiver = serviceClient.getFeedbackReceiver(deviceId);
// Assert
assertNotEquals(null, feedbackReceiver);
}
use of com.microsoft.azure.sdk.iot.service.FeedbackReceiver in project azure-iot-sdk-java by Azure.
the class FeedbackReceiverTest method open_receiver_null.
// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_004: [The function shall throw IOException if the member AMQPReceive object has not been initialized]
// Assert
@Test(expected = IOException.class)
public void open_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.open();
}
Aggregations