Search in sources :

Example 6 with AmqpDeviceOperations

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);
}
Also used : AmqpDeviceOperations(com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpDeviceOperations) NonStrictExpectations(mockit.NonStrictExpectations) AmqpMessage(com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpMessage) Test(org.junit.Test)

Example 7 with AmqpDeviceOperations

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
}
Also used : AmqpDeviceOperations(com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpDeviceOperations) NonStrictExpectations(mockit.NonStrictExpectations) IOException(java.io.IOException) Test(org.junit.Test)

Example 8 with AmqpDeviceOperations

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);
}
Also used : AmqpDeviceOperations(com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpDeviceOperations) NonStrictExpectations(mockit.NonStrictExpectations) AmqpMessage(com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpMessage) Test(org.junit.Test)

Example 9 with AmqpDeviceOperations

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);
}
Also used : AmqpDeviceOperations(com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpDeviceOperations) NonStrictExpectations(mockit.NonStrictExpectations) AmqpMessage(com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpMessage) Test(org.junit.Test)

Example 10 with AmqpDeviceOperations

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);
}
Also used : AmqpDeviceOperations(com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpDeviceOperations) NonStrictExpectations(mockit.NonStrictExpectations) AmqpMessage(com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpMessage) Test(org.junit.Test)

Aggregations

AmqpDeviceOperations (com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpDeviceOperations)15 Test (org.junit.Test)15 NonStrictExpectations (mockit.NonStrictExpectations)12 AmqpMessage (com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpMessage)5 IOException (java.io.IOException)1 Symbol (org.apache.qpid.proton.amqp.Symbol)1 Target (org.apache.qpid.proton.amqp.messaging.Target)1