use of com.microsoft.azure.sdk.iot.service.Message in project azure-iot-sdk-java by Azure.
the class AmqpSendTest method send_throwsIOException_when_open_has_not_been_called.
// Tests_SRS_SERVICE_SDK_JAVA_AMQPSEND_12_009: [The event handler shall throw IOException if the send handler object is not initialized]
// Assert
@Test(expected = IOException.class)
public void send_throwsIOException_when_open_has_not_been_called() 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);
// Act
amqpSend.send(deviceId, message);
}
use of com.microsoft.azure.sdk.iot.service.Message in project azure-iot-sdk-java by Azure.
the class AmqpSendTest method send_creates_ProtonMessage.
// Tests_SRS_SERVICE_SDK_JAVA_AMQPSEND_12_006: [The event handler shall create a Proton message with the given content]
@Test
public void send_creates_ProtonMessage() 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();
AmqpSendHandler handler = Deencapsulation.getField(amqpSend, "amqpSendHandler");
// Assert
new Expectations() {
{
Deencapsulation.invoke(handler, "createProtonMessage", deviceId, message);
}
};
// Act
amqpSend.send(deviceId, message);
}
Aggregations