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 sendRegisterMessageThrowsIfSendMessageFails.
@Test(expected = ProvisioningDeviceClientException.class)
public void sendRegisterMessageThrowsIfSendMessageFails() throws Exception {
// arrange
ProvisioningAmqpOperations provisioningAmqpOperations = new ProvisioningAmqpOperations(TEST_SCOPE_ID, TEST_HOST_NAME);
new NonStrictExpectations() {
{
mockedAmqpConnection.setListener((AmqpListener) any);
mockedAmqpConnection.open();
mockedAmqpConnection.isConnected();
result = true;
}
};
provisioningAmqpOperations.open(TEST_REGISTRATION_ID, mockedSSLContext, null, false);
setupSendReceiveMocks();
Deencapsulation.setField(provisioningAmqpOperations, "messageSendFailedExceptionMessage", "someError");
// act
provisioningAmqpOperations.sendRegisterMessage(mockedResponseCallback, null, 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 sendRegisterMessageThrowsOnResponseCallbackNull.
// SRS_ProvisioningAmqpOperations_07_009: [sendRegisterMessage shall throw ProvisioningDeviceClientException if either responseCallback is null.]
@Test(expected = ProvisioningDeviceClientException.class)
public void sendRegisterMessageThrowsOnResponseCallbackNull() throws ProvisioningDeviceClientException, IOException, InterruptedException {
// arrange
ProvisioningAmqpOperations provisioningAmqpOperations = new ProvisioningAmqpOperations(TEST_SCOPE_ID, TEST_HOST_NAME);
// act
provisioningAmqpOperations.sendRegisterMessage(null, null, 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 openThrowsOnEmptyRegistrationId.
// SRS_ProvisioningAmqpOperations_07_004: [open shall throw ProvisioningDeviceClientException if either registrationId or sslContext are null or empty.]
@Test(expected = ProvisioningDeviceConnectionException.class)
public void openThrowsOnEmptyRegistrationId() throws ProvisioningDeviceClientException {
// arrange
ProvisioningAmqpOperations provisioningAmqpOperations = new ProvisioningAmqpOperations(TEST_SCOPE_ID, TEST_HOST_NAME);
// act
provisioningAmqpOperations.open("", mockedSSLContext, 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 openOpensAmqpConnectionSynchronouslyWithoutSaslHandler.
// SRS_ProvisioningAmqpOperations_34_020: [If the provided sasl handler is null, this function shall open the underlying amqpConnection synchronously.]
@Test
public void openOpensAmqpConnectionSynchronouslyWithoutSaslHandler() throws ProvisioningDeviceClientException, IOException {
// arrange
ProvisioningAmqpOperations provisioningAmqpOperations = new ProvisioningAmqpOperations(TEST_SCOPE_ID, TEST_HOST_NAME);
// act
provisioningAmqpOperations.open(TEST_REGISTRATION_ID, mockedSSLContext, null, false);
// assert
new Verifications() {
{
mockedAmqpConnection.open();
times = 1;
mockedAmqpConnection.openAmqpAsync();
times = 0;
}
};
}
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 sendStatusThrowsOnOperationIdNull.
// SRS_ProvisioningAmqpOperations_07_015: [sendStatusMessage shall throw ProvisioningDeviceClientException if either operationId or responseCallback are null or empty.]
@Test(expected = ProvisioningDeviceClientException.class)
public void sendStatusThrowsOnOperationIdNull() throws ProvisioningDeviceClientException, IOException, InterruptedException {
// arrange
ProvisioningAmqpOperations provisioningAmqpOperations = new ProvisioningAmqpOperations(TEST_SCOPE_ID, TEST_HOST_NAME);
// act
provisioningAmqpOperations.sendStatusMessage(null, mockedResponseCallback, null);
// assert
}
Aggregations