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