use of com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.amqp.ProvisioningAmqpOperations in project azure-iot-sdk-java by Azure.
the class ProvisioningAmqpOperationsTest method openThrowsOnNullSSLContext.
// SRS_ProvisioningAmqpOperations_07_004: [open shall throw ProvisioningDeviceClientException if either registrationId or sslContext are null or empty.]
@Test(expected = ProvisioningDeviceConnectionException.class)
public void openThrowsOnNullSSLContext() throws ProvisioningDeviceClientException {
// arrange
ProvisioningAmqpOperations provisioningAmqpOperations = new ProvisioningAmqpOperations(TEST_SCOPE_ID, TEST_HOST_NAME);
// act
provisioningAmqpOperations.open(TEST_REGISTRATION_ID, null, null, false);
// assert
}
use of com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.amqp.ProvisioningAmqpOperations in project azure-iot-sdk-java by Azure.
the class ProvisioningAmqpOperationsTest method closeSucceeds.
// SRS_ProvisioningAmqpOperations_07_007: [If amqpConnection is null, this method shall do nothing.]
// SRS_ProvisioningAmqpOperations_07_008: [This method shall call close on amqpConnection.]
@Test
public void closeSucceeds() throws ProvisioningDeviceClientException, IOException {
// 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);
// act
provisioningAmqpOperations.close();
// assert
new Verifications() {
{
mockedAmqpConnection.close();
times = 1;
}
};
}
use of com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.amqp.ProvisioningAmqpOperations in project azure-iot-sdk-java by Azure.
the class ProvisioningAmqpOperationsTest method openSucceeds.
// SRS_ProvisioningAmqpOperations_07_005: [This method shall construct the Link Address with /<scopeId>/registrations/<registrationId>.]
@Test
public void openSucceeds() throws ProvisioningDeviceClientException, IOException {
// arrange
ProvisioningAmqpOperations provisioningAmqpOperations = new ProvisioningAmqpOperations(TEST_SCOPE_ID, TEST_HOST_NAME);
new NonStrictExpectations() {
{
mockedAmqpConnection.setListener((AmqpListener) any);
mockedAmqpConnection.open();
}
};
// act
provisioningAmqpOperations.open(TEST_REGISTRATION_ID, mockedSSLContext, null, false);
// assert
new Verifications() {
{
mockedAmqpConnection.open();
times = 1;
}
};
}
use of com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.amqp.ProvisioningAmqpOperations in project azure-iot-sdk-java by Azure.
the class ProvisioningAmqpOperationsTest method closeThrowsIoException.
@Test(expected = IOException.class)
public void closeThrowsIoException() throws ProvisioningDeviceClientException, IOException {
// 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() {
{
mockedAmqpConnection.setListener((AmqpListener) any);
mockedAmqpConnection.close();
result = new IOException();
}
};
// act
provisioningAmqpOperations.close();
// assert
}
use of com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.amqp.ProvisioningAmqpOperations in project azure-iot-sdk-java by Azure.
the class ProvisioningAmqpOperationsTest method MessageReceivedSucceeds.
// SRS_ProvisioningAmqpOperations_07_013: [This method shall add the message to a message queue.]
// SRS_ProvisioningAmqpOperations_07_014: [This method shall then Notify the receiveLock.]
@Test
public void MessageReceivedSucceeds() throws ProvisioningDeviceClientException, IOException, InterruptedException {
// arrange
ProvisioningAmqpOperations provisioningAmqpOperations = new ProvisioningAmqpOperations(TEST_SCOPE_ID, TEST_HOST_NAME);
// act
provisioningAmqpOperations.messageReceived(mockedAmqpMessage);
// assert
new Verifications() {
{
mockedObjectLock.notifyLock();
times = 1;
}
};
}
Aggregations