Search in sources :

Example 1 with AmqpMessage

use of com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpMessage in project azure-iot-sdk-java by Azure.

the class ProvisioningAmqpOperationsTest method sendStatusMessageThrowsOnWaitLock.

// SRS_ProvisioningAmqpOperations_07_018: [This method shall throw ProvisioningDeviceClientException if any failure is encountered.]
@Test(expected = ProvisioningDeviceClientException.class)
public void sendStatusMessageThrowsOnWaitLock() throws Exception {
    // arrange
    ProvisioningAmqpOperations provisioningAmqpOperations = new ProvisioningAmqpOperations(TEST_SCOPE_ID, TEST_HOST_NAME);
    new NonStrictExpectations() {

        {
            mockedAmqpConnection.setListener((AmqpListener) any);
            mockedAmqpConnection.open();
        }
    };
    provisioningAmqpOperations.open(TEST_REGISTRATION_ID, mockedSSLContext, null, false);
    new NonStrictExpectations() {

        {
            new AmqpMessage();
            result = mockedAmqpMessage;
            mockedAmqpConnection.sendAmqpMessage(mockedAmqpMessage);
            mockedObjectLock.waitLock(anyLong);
            result = new InterruptedException();
        }
    };
    // act
    provisioningAmqpOperations.sendStatusMessage(TEST_OPERATION_ID, mockedResponseCallback, null);
// assert
}
Also used : NonStrictExpectations(mockit.NonStrictExpectations) AmqpMessage(com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpMessage) ProvisioningAmqpOperations(com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.amqp.ProvisioningAmqpOperations) Test(org.junit.Test)

Example 2 with AmqpMessage

use of com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpMessage in project azure-iot-sdk-java by Azure.

the class ProvisioningAmqpOperationsTest method sendStatusMessageThrowsOnSendAmqpMessage.

// SRS_ProvisioningAmqpOperations_07_018: [This method shall throw ProvisioningDeviceClientException if any failure is encountered.]
@Test(expected = ProvisioningDeviceClientException.class)
public void sendStatusMessageThrowsOnSendAmqpMessage() throws ProvisioningDeviceClientException, IOException, InterruptedException {
    // arrange
    ProvisioningAmqpOperations provisioningAmqpOperations = new ProvisioningAmqpOperations(TEST_SCOPE_ID, TEST_HOST_NAME);
    new NonStrictExpectations() {

        {
            mockedAmqpConnection.setListener((AmqpListener) any);
            mockedAmqpConnection.open();
        }
    };
    provisioningAmqpOperations.open(TEST_REGISTRATION_ID, mockedSSLContext, null, false);
    new NonStrictExpectations() {

        {
            new AmqpMessage();
            result = new Exception();
        }
    };
    // act
    provisioningAmqpOperations.sendStatusMessage(TEST_OPERATION_ID, mockedResponseCallback, null);
// assert
}
Also used : NonStrictExpectations(mockit.NonStrictExpectations) AmqpMessage(com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpMessage) ProvisioningDeviceConnectionException(com.microsoft.azure.sdk.iot.provisioning.device.internal.exceptions.ProvisioningDeviceConnectionException) IOException(java.io.IOException) ProvisioningDeviceClientException(com.microsoft.azure.sdk.iot.provisioning.device.internal.exceptions.ProvisioningDeviceClientException) ProvisioningAmqpOperations(com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.amqp.ProvisioningAmqpOperations) Test(org.junit.Test)

Example 3 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 ReceiverMessageFromLinkReturnNullOnLinkNameEmpty.

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

        {
        }
    };
    // Act
    AmqpMessage result = amqpDeviceOperation.receiverMessageFromLink("");
    // 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 4 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 decodeSucceeds.

@Test
public void decodeSucceeds() {
    AmqpMessage amqpMessage = new AmqpMessage(mockedMessageImpl);
    new NonStrictExpectations() {

        {
            mockedMessageImpl.decode((byte[]) any, 0, 10);
        }
    };
    byte[] data = new byte[10];
    amqpMessage.decode(data, 0, 10);
}
Also used : NonStrictExpectations(mockit.NonStrictExpectations) AmqpMessage(com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpMessage) Test(org.junit.Test)

Example 5 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 decodeThrowsOnDataNull.

@Test(expected = IllegalArgumentException.class)
public void decodeThrowsOnDataNull() {
    AmqpMessage amqpMessage = new AmqpMessage(mockedMessageImpl);
    amqpMessage.decode(null, 0, 10);
}
Also used : 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