use of com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol in project azure-iot-sdk-java by Azure.
the class AmqpSendTest method onReactorInit_invalidates_SendHandler.
// Tests_SRS_SERVICE_SDK_JAVA_AMQPSEND_12_005: [The event handler shall invalidate the member AmqpsSendHandler object]
@Test
public void onReactorInit_invalidates_SendHandler() throws IOException {
// Arrange
String hostName = "aaa";
String userName = "bbb";
String sasToken = "ccc";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
AmqpSend amqpSend = new AmqpSend(hostName, userName, sasToken, iotHubServiceClientProtocol);
amqpSend.open();
amqpSend.onReactorInit(event);
// Act
amqpSend.close();
// Assert
assertNull(Deencapsulation.getField(amqpSend, "amqpSendHandler"));
}
use of com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol in project azure-iot-sdk-java by Azure.
the class AmqpSendTest method send_initializes_Reactor.
// Tests_SRS_SERVICE_SDK_JAVA_AMQPSEND_12_007: [The event handler shall initialize the Proton reactor object]
// Tests_SRS_SERVICE_SDK_JAVA_AMQPSEND_12_008: [The event handler shall start the Proton reactor object]
@Test
public void send_initializes_Reactor() throws Exception {
// Arrange
String hostName = "aaa";
String userName = "bbb";
String sasToken = "ccc";
String deviceId = "deviceId";
String content = "abcdefghijklmnopqrst";
Message message = new Message(content);
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
AmqpSend amqpSend = new AmqpSend(hostName, userName, sasToken, iotHubServiceClientProtocol);
amqpSend.open();
// Assert
new Expectations() {
{
reactor = proton.reactor(amqpSend);
reactor.run();
}
};
// Act
amqpSend.send(deviceId, message);
}
use of com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol in project azure-iot-sdk-java by Azure.
the class AmqpSendTest method constructor_copies_params_to_members_amqps.
// Tests_SRS_SERVICE_SDK_JAVA_AMQPSEND_12_002: [The constructor shall copy all input parameters to private member variables for event processing]
@Test
public void constructor_copies_params_to_members_amqps() {
// Arrange
String hostName = "aaa";
String userName = "bbb";
String sasToken = "ccc";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
// Act
AmqpSend amqpSend = new AmqpSend(hostName, userName, sasToken, iotHubServiceClientProtocol);
String _hostName = Deencapsulation.getField(amqpSend, "hostName");
String _userName = Deencapsulation.getField(amqpSend, "userName");
String _sasToken = Deencapsulation.getField(amqpSend, "sasToken");
IotHubServiceClientProtocol _ioIotHubServiceClientProtocol = Deencapsulation.getField(amqpSend, "iotHubServiceClientProtocol");
// Assert
assertEquals(hostName, _hostName);
assertEquals(userName, _userName);
assertEquals(sasToken, _sasToken);
assertEquals(iotHubServiceClientProtocol, _ioIotHubServiceClientProtocol);
}
use of com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol in project azure-iot-sdk-java by Azure.
the class AmqpSendTest method constructor_checks_if_userName_null.
// Tests_SRS_SERVICE_SDK_JAVA_AMQPSEND_12_001: [The constructor shall throw IllegalArgumentException if any of the input parameter is null or empty]
// Assert
@Test(expected = IllegalArgumentException.class)
public void constructor_checks_if_userName_null() {
// Arrange
String hostName = "aaa";
String userName = null;
String sasToken = "ccc";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
// Act
AmqpSend amqpSend = new AmqpSend(hostName, userName, sasToken, iotHubServiceClientProtocol);
}
use of com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol in project azure-iot-sdk-java by Azure.
the class FileUploadNotificationReceiverTest method receiveCallReceiveTimeout.
// Tests_SRS_SERVICE_SDK_JAVA_FILEUPLOADNOTIFICATIONRECEIVER_25_007: [ The function shall call receive(long timeoutMs) function with the default timeout ]
@Test
public void receiveCallReceiveTimeout() 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
fileUploadNotificationReceiver.receive();
// Assert
new Verifications() {
{
amqpFileUploadNotificationReceive.receive(Deencapsulation.getField(fileUploadNotificationReceiver, "DEFAULT_TIMEOUT_MS"));
times = 1;
}
};
}
Aggregations