use of com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpSendHandler in project azure-iot-sdk-java by Azure.
the class AmqpSendHandlerTest method onLinkInit_call_flow_ok.
// Tests_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_12_015: [The event handler shall create a new Target (Proton) object using the given endpoint address]
// Tests_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_12_016: [The event handler shall get the Link (Proton) object and set its target to the created Target (Proton) object]
@Test
public void onLinkInit_call_flow_ok() {
// Arrange
String hostName = "aaa";
String userName = "bbb";
String sasToken = "ccc";
String hostAddr = hostName + ":5671";
String endpoint = "/messages/devicebound";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
AmqpSendHandler amqpSendHandler = new AmqpSendHandler(hostName, userName, sasToken, iotHubServiceClientProtocol);
// Assert
new Expectations() {
{
link = event.getLink();
target = new Target();
target.setAddress(endpoint);
}
};
// Act
amqpSendHandler.onLinkInit(event);
}
use of com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpSendHandler in project azure-iot-sdk-java by Azure.
the class AmqpSendHandlerTest method constructor_checks_if_sasToken_empty.
// Tests_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_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_sasToken_empty() {
// Arrange
String hostName = "aaa";
String userName = "bbb";
String sasToken = "";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
// Act
AmqpSendHandler amqpSend = new AmqpSendHandler(hostName, userName, sasToken, iotHubServiceClientProtocol);
}
use of com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpSendHandler 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);
}
use of com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpSendHandler in project azure-iot-sdk-java by Azure.
the class AmqpSendHandlerTest method constructor_checks_if_sasToken_null.
// Tests_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_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_sasToken_null() {
// Arrange
String hostName = "aaa";
String userName = "bbb";
String sasToken = null;
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
// Act
AmqpSendHandler amqpSend = new AmqpSendHandler(hostName, userName, sasToken, iotHubServiceClientProtocol);
}
use of com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpSendHandler in project azure-iot-sdk-java by Azure.
the class AmqpSendHandlerTest method sendComplete_throws_Connection_exception_if_found.
//Tests_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_25_031: [** The event handler shall get the exception from the response and throw is it is not null **]**
@Test(expected = IOException.class)
public void sendComplete_throws_Connection_exception_if_found(@Mocked final AmqpResponseVerification mockedVerification, @Mocked final IotHubException mockedIotHubException, @Mocked final Event mockedEvent) throws IotHubException, IOException {
// Arrange
String hostName = "aaa";
String userName = "bbb";
String sasToken = "ccc";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
AmqpSendHandler amqpSendHandler = new AmqpSendHandler(hostName, userName, sasToken, iotHubServiceClientProtocol);
amqpSendHandler.onTransportError(mockedEvent);
// Act
amqpSendHandler.sendComplete();
}
Aggregations