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 sendRegisterMessageSucceeds.
// SRS_ProvisioningAmqpOperations_07_010: [This method shall send the Register AMQP Provisioning message.]
// SRS_ProvisioningAmqpOperations_07_011: [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 sendRegisterMessageSucceeds() 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();
// 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 isAmqpConnectedSucceeds.
@Test
public void isAmqpConnectedSucceeds() 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.isConnected();
result = true;
}
};
// act
boolean isConnected = provisioningAmqpOperations.isAmqpConnected();
// assert
assertTrue(isConnected);
}
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 isAmqpConnectedNotConnectedSucceeds.
@Test
public void isAmqpConnectedNotConnectedSucceeds() throws Exception {
// arrange
ProvisioningAmqpOperations provisioningAmqpOperations = new ProvisioningAmqpOperations(TEST_SCOPE_ID, TEST_HOST_NAME);
// act
boolean isConnected = provisioningAmqpOperations.isAmqpConnected();
// assert
assertFalse(isConnected);
}
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 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.provisioning.device.internal.contract.amqp.ProvisioningAmqpOperations 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
}
Aggregations