use of com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol in project azure-iot-sdk-java by Azure.
the class AmqpReceiveTest method amqpReceive_init_ok.
// Tests_SRS_SERVICE_SDK_JAVA_AMQPRECEIVE_12_001: [The constructor shall copy all input parameters to private member variables for event processing]
@Test
public void amqpReceive_init_ok() {
// Arrange
String hostName = "aaa";
String userName = "bbb";
String sasToken = "ccc";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
// Act
AmqpReceive amqpReceive = new AmqpReceive(hostName, userName, sasToken, iotHubServiceClientProtocol);
String _hostName = Deencapsulation.getField(amqpReceive, "hostName");
String _userName = Deencapsulation.getField(amqpReceive, "userName");
String _sasToken = Deencapsulation.getField(amqpReceive, "sasToken");
// Assert
assertEquals(hostName, _hostName);
assertEquals(userName, _userName);
assertEquals(sasToken, _sasToken);
}
use of com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol in project azure-iot-sdk-java by Azure.
the class AmqpFileUploadNotificationReceiveTest method onFeedbackReceivedCallFlowOk.
// Tests_SRS_SERVICE_SDK_JAVA_AMQPFILEUPLOADNOTIFICATIONRECEIVE_25_010: [The function shall parse the received Json string to FeedbackBath object]
@Test
public void onFeedbackReceivedCallFlowOk(@Mocked FileUploadNotification mockedNotification) {
// Arrange
final String hostName = "aaa";
final String userName = "bbb";
final String sasToken = "ccc";
final String jsonData = "[]";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
AmqpFileUploadNotificationReceive amqpFileUploadNotificationReceive = new AmqpFileUploadNotificationReceive(hostName, userName, sasToken, iotHubServiceClientProtocol);
// Act
amqpFileUploadNotificationReceive.onFeedbackReceived(jsonData);
//assert
new Verifications() {
{
mockNotificationParser.getBlobName();
times = 1;
mockNotificationParser.getBlobSizeInBytesTag();
times = 1;
mockNotificationParser.getBlobUri();
times = 1;
mockNotificationParser.getDeviceId();
times = 1;
mockNotificationParser.getEnqueuedTimeUtc();
times = 1;
mockNotificationParser.getLastUpdatedTime();
times = 1;
}
};
}
use of com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol in project azure-iot-sdk-java by Azure.
the class AmqpFileUploadNotificationReceiveTest method onReactorInitCallFlowAndInitOk.
// Tests_SRS_SERVICE_SDK_JAVA_AMQPFILEUPLOADNOTIFICATIONRECEIVE_25_002: [The event handler shall set the member AmqpsReceiveHandler object to handle the given connection events]
// Tests_SRS_SERVICE_SDK_JAVA_AMQPFILEUPLOADNOTIFICATIONRECEIVE_25_003: [The function shall create an AmqpsReceiveHandler object to handle reactor events]
// Tests_SRS_SERVICE_SDK_JAVA_AMQPFILEUPLOADNOTIFICATIONRECEIVE_25_004: [The function shall invalidate the member AmqpsReceiveHandler object]
@Test
public void onReactorInitCallFlowAndInitOk() throws IOException {
// Arrange
final String hostName = "aaa";
final String userName = "bbb";
final String sasToken = "ccc";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
AmqpFileUploadNotificationReceive amqpFileUploadNotificationReceive = new AmqpFileUploadNotificationReceive(hostName, userName, sasToken, iotHubServiceClientProtocol);
amqpFileUploadNotificationReceive.open();
// Assert
new Expectations() {
{
reactor = event.getReactor();
connection = reactor.connection(Deencapsulation.getField(amqpFileUploadNotificationReceive, "amqpReceiveHandler"));
}
};
// Act
amqpFileUploadNotificationReceive.onReactorInit(event);
// Assert
assertNotNull(Deencapsulation.getField(amqpFileUploadNotificationReceive, "amqpReceiveHandler"));
// Clean up
amqpFileUploadNotificationReceive.close();
}
use of com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol in project azure-iot-sdk-java by Azure.
the class AmqpReceiveTest method onFeedbackReceived_call_flow_ok.
// Tests_SRS_SERVICE_SDK_JAVA_AMQPRECEIVE_12_010: [The function shall parse the received Json string to FeedbackBath object]
@Test
public void onFeedbackReceived_call_flow_ok() {
// Arrange
String hostName = "aaa";
String userName = "bbb";
String sasToken = "ccc";
String jsonData = "[]";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
AmqpReceive amqpReceive = new AmqpReceive(hostName, userName, sasToken, iotHubServiceClientProtocol);
// Assert
new Expectations() {
{
FeedbackBatchMessage.parse(jsonData);
}
};
// Act
amqpReceive.onFeedbackReceived(jsonData);
}
use of com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol in project azure-iot-sdk-java by Azure.
the class AmqpReceiveTest method receiveException_throw.
// Tests_SRS_SERVICE_SDK_JAVA_AMQPRECEIVE_12_008: [The function shall throw IOException if the send handler object is not initialized]
// Assert
@Test(expected = IOException.class)
public void receiveException_throw() throws IOException, InterruptedException {
// Arrange
String hostName = "aaa";
String userName = "bbb";
String sasToken = "ccc";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
int timeoutMs = 1;
AmqpReceive amqpReceive = new AmqpReceive(hostName, userName, sasToken, iotHubServiceClientProtocol);
// Act
amqpReceive.receive(timeoutMs);
}
Aggregations