use of com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpMessage in project azure-iot-sdk-java by Azure.
the class AmqpMessageTest method setBodySucceeds.
@Test
public void setBodySucceeds() {
AmqpMessage amqpMessage = new AmqpMessage(mockedMessageImpl);
new NonStrictExpectations() {
{
}
};
amqpMessage.setBody(mockedData);
}
use of com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpMessage in project azure-iot-sdk-java by Azure.
the class AmqpMessageTest method encodeThrowsOnDataNull.
@Test(expected = IllegalArgumentException.class)
public void encodeThrowsOnDataNull() throws IOException {
AmqpMessage amqpMessage = new AmqpMessage(mockedMessageImpl);
amqpMessage.encode(null, 0);
}
use of com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpMessage in project azure-iot-sdk-java by Azure.
the class AmqpDeviceOperationsTest method ReceiverMessageFromLinkWrongName.
@Test
public void ReceiverMessageFromLinkWrongName() throws IOException {
// Arrange
AmqpDeviceOperations amqpDeviceOperation = new AmqpDeviceOperations();
Deencapsulation.setField(amqpDeviceOperation, "receiverLink", mockedReceiverLink);
new NonStrictExpectations() {
{
mockedReceiverLink.current();
result = mockedDelivery;
mockedDelivery.isReadable();
result = true;
mockedDelivery.pending();
result = 10;
mockedReceiverLink.recv((byte[]) any, 0, anyInt);
mockedReceiverLink.advance();
mockedAmqpMessage.decode((byte[]) any, 0, anyInt);
}
};
// Act
AmqpMessage result = amqpDeviceOperation.receiverMessageFromLink("WRONG_LINK_NAME");
// assert
Assert.assertNull(result);
}
use of com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpMessage in project azure-iot-sdk-java by Azure.
the class AmqpDeviceOperationsTest method ReceiverMessageFromLinkSucceeds.
@Test
public void ReceiverMessageFromLinkSucceeds() throws IOException {
// Arrange
AmqpDeviceOperations amqpDeviceOperation = new AmqpDeviceOperations();
Deencapsulation.setField(amqpDeviceOperation, "receiverLink", mockedReceiverLink);
new NonStrictExpectations() {
{
mockedReceiverLink.current();
result = mockedDelivery;
mockedDelivery.isReadable();
result = true;
mockedDelivery.pending();
result = 10;
mockedReceiverLink.recv((byte[]) any, 0, anyInt);
mockedReceiverLink.advance();
mockedAmqpMessage.decode((byte[]) any, 0, anyInt);
}
};
// Act
AmqpMessage result = amqpDeviceOperation.receiverMessageFromLink(TEST_RECEIVER_LINK_NAME);
// assert
Assert.assertNotNull(result);
}
use of com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpMessage in project azure-iot-sdk-java by Azure.
the class AmqpDeviceOperationsTest method ReceiverMessageFromLinkReturnNullOnLinkNameNull.
@Test
public void ReceiverMessageFromLinkReturnNullOnLinkNameNull() throws IOException {
// Arrange
AmqpDeviceOperations amqpDeviceOperation = new AmqpDeviceOperations();
new NonStrictExpectations() {
{
}
};
// Act
AmqpMessage result = amqpDeviceOperation.receiverMessageFromLink(null);
// assert
Assert.assertNull(result);
}
Aggregations