Search in sources :

Example 11 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 openLinksThrowsOnSessionNull.

@Test(expected = IllegalArgumentException.class)
public void openLinksThrowsOnSessionNull() throws IOException, IllegalArgumentException {
    // Arrange
    AmqpDeviceOperations amqpDeviceOperation = new AmqpDeviceOperations();
    new NonStrictExpectations() {

        {
        }
    };
    // Act
    amqpDeviceOperation.openLinks(null);
// assert
}
Also used : AmqpDeviceOperations(com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpDeviceOperations) NonStrictExpectations(mockit.NonStrictExpectations) Test(org.junit.Test)

Example 12 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 isRecieverLinkTagFalseSucceeds.

@Test
public void isRecieverLinkTagFalseSucceeds() throws IOException, IllegalArgumentException {
    // Arrange
    AmqpDeviceOperations amqpDeviceOperation = new AmqpDeviceOperations();
    // Act
    boolean result = amqpDeviceOperation.isReceiverLinkTag("");
    // assert
    Assert.assertFalse(result);
}
Also used : AmqpDeviceOperations(com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpDeviceOperations) Test(org.junit.Test)

Example 13 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 sendMessageSuccess.

@Test
public void sendMessageSuccess() throws IOException, IllegalArgumentException {
    // Arrange
    AmqpDeviceOperations amqpDeviceOperation = new AmqpDeviceOperations();
    Deencapsulation.setField(amqpDeviceOperation, "senderLink", mockedSenderLink);
    new NonStrictExpectations() {

        {
            mockedSenderLink.delivery((byte[]) any);
        }
    };
    byte[] tag = new byte[10];
    byte[] data = new byte[10];
    // Act
    amqpDeviceOperation.sendMessage(tag, data, 128, 0);
// assert
}
Also used : AmqpDeviceOperations(com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpDeviceOperations) NonStrictExpectations(mockit.NonStrictExpectations) Test(org.junit.Test)

Example 14 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 closeLinksSuccess.

@Test
public void closeLinksSuccess() throws IOException, IllegalArgumentException {
    // Arrange
    AmqpDeviceOperations amqpDeviceOperation = new AmqpDeviceOperations();
    Deencapsulation.setField(amqpDeviceOperation, "receiverLink", mockedReceiverLink);
    Deencapsulation.setField(amqpDeviceOperation, "senderLink", mockedSenderLink);
    new NonStrictExpectations() {

        {
            mockedReceiverLink.close();
            mockedSenderLink.close();
        }
    };
    // Act
    amqpDeviceOperation.closeLinks();
// assert
}
Also used : AmqpDeviceOperations(com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpDeviceOperations) NonStrictExpectations(mockit.NonStrictExpectations) Test(org.junit.Test)

Example 15 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 openLinksSucceeds.

@Test
public void openLinksSucceeds() throws IOException, IllegalArgumentException {
    // Arrange
    AmqpDeviceOperations amqpDeviceOperation = new AmqpDeviceOperations();
    new NonStrictExpectations() {

        {
            mockedSession.receiver(anyString);
            result = mockedReceiverLink;
            mockedReceiverLink.setProperties((Map<Symbol, Object>) any);
            mockedReceiverLink.open();
            mockedSession.sender(anyString);
            result = mockedSenderLink;
            mockedSenderLink.setProperties((Map<Symbol, Object>) any);
            mockedSenderLink.open();
        }
    };
    // Act
    amqpDeviceOperation.openLinks(mockedSession);
// assert
}
Also used : Symbol(org.apache.qpid.proton.amqp.Symbol) AmqpDeviceOperations(com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpDeviceOperations) NonStrictExpectations(mockit.NonStrictExpectations) 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