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 sendStatusThrowsOnOperationIdEmpty.
// SRS_ProvisioningAmqpOperations_07_015: [sendStatusMessage shall throw ProvisioningDeviceClientException if either operationId or responseCallback are null or empty.]
@Test(expected = ProvisioningDeviceClientException.class)
public void sendStatusThrowsOnOperationIdEmpty() throws ProvisioningDeviceClientException, IOException, InterruptedException {
// arrange
ProvisioningAmqpOperations provisioningAmqpOperations = new ProvisioningAmqpOperations(TEST_SCOPE_ID, TEST_HOST_NAME);
// act
provisioningAmqpOperations.sendStatusMessage("", mockedResponseCallback, null);
// 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 sendStatusMessageSucceeds.
// SRS_ProvisioningAmqpOperations_07_016: [This method shall send the Operation Status AMQP Provisioning message.]
// SRS_ProvisioningAmqpOperations_07_017: [This method shall wait for the response of this message for MAX_WAIT_TO_SEND_MSG and call the responseCallback with the reply.]
@Test
public void sendStatusMessageSucceeds() 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);
setupSendReceiveMocks();
// act
provisioningAmqpOperations.sendStatusMessage(TEST_OPERATION_ID, mockedResponseCallback, null);
// 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 sendStatusMessageThrowsIfSendFails.
@Test(expected = ProvisioningDeviceClientException.class)
public void sendStatusMessageThrowsIfSendFails() 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);
setupSendReceiveMocks();
Deencapsulation.setField(provisioningAmqpOperations, "messageSendFailedExceptionMessage", "someError");
// act
provisioningAmqpOperations.sendStatusMessage(TEST_OPERATION_ID, mockedResponseCallback, null);
}
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 openOpensAmqpConnectionAsynchronouslyWithSaslHandler.
// SRS_ProvisioningAmqpOperations_34_019: [If the provided sasl handler is not null, this function shall open the underlying amqpConnection asynchronously.]
@Test
public void openOpensAmqpConnectionAsynchronouslyWithSaslHandler() throws ProvisioningDeviceClientException, IOException {
// arrange
ProvisioningAmqpOperations provisioningAmqpOperations = new ProvisioningAmqpOperations(TEST_SCOPE_ID, TEST_HOST_NAME);
// act
provisioningAmqpOperations.open(TEST_REGISTRATION_ID, mockedSSLContext, mockedSaslHandler, false);
// assert
new Verifications() {
{
mockedAmqpConnection.open();
times = 0;
mockedAmqpConnection.openAmqpAsync();
times = 1;
}
};
}
Aggregations