use of com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpDeviceOperations 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.AmqpDeviceOperations in project azure-iot-sdk-java by Azure.
the class AmqpDeviceOperationsTest method initLinkThrowsOnGetName.
@Test(expected = Exception.class)
public void initLinkThrowsOnGetName() throws IOException, IllegalArgumentException {
// Arrange
AmqpDeviceOperations amqpDeviceOperation = new AmqpDeviceOperations();
new NonStrictExpectations() {
{
mockedLink.getName();
result = new Exception();
}
};
// Act
amqpDeviceOperation.initLink(mockedLink);
// assert
}
use of com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpDeviceOperations 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.AmqpDeviceOperations 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);
}
use of com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpDeviceOperations in project azure-iot-sdk-java by Azure.
the class AmqpDeviceOperationsTest method ReceiverMessageFromLinkReceiverLinkNull.
@Test
public void ReceiverMessageFromLinkReceiverLinkNull() throws IOException {
// Arrange
AmqpDeviceOperations amqpDeviceOperation = new AmqpDeviceOperations();
new NonStrictExpectations() {
{
}
};
// Act
AmqpMessage result = amqpDeviceOperation.receiverMessageFromLink(TEST_SENDER_LINK_NAME);
// assert
Assert.assertNull(result);
}
Aggregations