Search in sources :

Example 6 with AmqpMessage

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

Example 7 with AmqpMessage

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

Example 8 with AmqpMessage

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);
}
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 AmqpMessage

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);
}
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 AmqpMessage

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);
}
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

AmqpMessage (com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpMessage)14 Test (org.junit.Test)14 NonStrictExpectations (mockit.NonStrictExpectations)12 AmqpDeviceOperations (com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpDeviceOperations)5 ProvisioningAmqpOperations (com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.amqp.ProvisioningAmqpOperations)2 ProvisioningDeviceClientException (com.microsoft.azure.sdk.iot.provisioning.device.internal.exceptions.ProvisioningDeviceClientException)1 ProvisioningDeviceConnectionException (com.microsoft.azure.sdk.iot.provisioning.device.internal.exceptions.ProvisioningDeviceConnectionException)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1