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 constructorSucceeds.
// SRS_ContractAPIAmqp_07_001: [The constructor shall save the scope id and hostname.]
@Test
public void constructorSucceeds() throws ProvisioningDeviceClientException {
// arrange
// act
ProvisioningAmqpOperations provisioningAmqpOperations = new ProvisioningAmqpOperations(TEST_SCOPE_ID, TEST_HOST_NAME);
// assert
assertEquals(TEST_SCOPE_ID, Deencapsulation.getField(provisioningAmqpOperations, "idScope"));
assertEquals(TEST_HOST_NAME, Deencapsulation.getField(provisioningAmqpOperations, "hostName"));
}
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 sendStatusThrowsOnResponseCallbackNull.
// SRS_ProvisioningAmqpOperations_07_015: [sendStatusMessage shall throw ProvisioningDeviceClientException if either operationId or responseCallback are null or empty.]
@Test(expected = ProvisioningDeviceClientException.class)
public void sendStatusThrowsOnResponseCallbackNull() throws ProvisioningDeviceClientException, IOException, InterruptedException {
// arrange
ProvisioningAmqpOperations provisioningAmqpOperations = new ProvisioningAmqpOperations(TEST_SCOPE_ID, TEST_HOST_NAME);
// act
provisioningAmqpOperations.sendStatusMessage(TEST_OPERATION_ID, 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 openThrowsOnOpenFailure.
// SRS_ProvisioningAmqpOperations_07_004: [open shall throw ProvisioningDeviceClientException if either registrationId or sslContext are null or empty.]
@Test(expected = ProvisioningDeviceConnectionException.class)
public void openThrowsOnOpenFailure() throws ProvisioningDeviceClientException, IOException {
// arrange
ProvisioningAmqpOperations provisioningAmqpOperations = new ProvisioningAmqpOperations(TEST_SCOPE_ID, TEST_HOST_NAME);
new NonStrictExpectations() {
{
mockedAmqpConnection.setListener((AmqpListener) any);
mockedAmqpConnection.open();
result = new Exception();
}
};
// act
provisioningAmqpOperations.open(TEST_REGISTRATION_ID, mockedSSLContext, null, false);
}
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 sendRegisterMessageThrowsInterrruptedException.
// SRS_ProvisioningAmqpOperations_07_012: [This method shall throw ProvisioningDeviceClientException if any failure is encountered.]
@Test(expected = ProvisioningDeviceClientException.class)
public void sendRegisterMessageThrowsInterrruptedException() 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() {
{
mockedAmqpConnection.sendAmqpMessage(mockedAmqpMessage);
mockedAmqpConnection.isConnected();
result = new InterruptedException();
}
};
// 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 openThrowsOnNullRegistrationId.
// SRS_ProvisioningAmqpOperations_07_004: [open shall throw ProvisioningDeviceClientException if either registrationId or sslContext are null or empty.]
@Test(expected = ProvisioningDeviceConnectionException.class)
public void openThrowsOnNullRegistrationId() throws ProvisioningDeviceClientException {
// arrange
ProvisioningAmqpOperations provisioningAmqpOperations = new ProvisioningAmqpOperations(TEST_SCOPE_ID, TEST_HOST_NAME);
// act
provisioningAmqpOperations.open(null, mockedSSLContext, null, false);
// assert
}
Aggregations