Search in sources :

Example 1 with IotHubServiceClientProtocol

use of com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol in project azure-iot-sdk-java by Azure.

the class FeedbackReceiverTest method open_receiver_null_without_deviceId.

// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_004: [The function shall throw IOException if the member AMQPReceive object has not been initialized]
// Assert
@Test(expected = IOException.class)
public void open_receiver_null_without_deviceId() throws Exception {
    // Arrange
    String hostName = "xxx";
    String userName = "xxx";
    String sasToken = "xxx";
    String deviceId = "xxx";
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    FeedbackReceiver feedbackReceiver = new FeedbackReceiver(hostName, userName, sasToken, iotHubServiceClientProtocol);
    Deencapsulation.setField(feedbackReceiver, "amqpReceive", null);
    // Act
    feedbackReceiver.open();
}
Also used : FeedbackReceiver(com.microsoft.azure.sdk.iot.service.FeedbackReceiver) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) Test(org.junit.Test)

Example 2 with IotHubServiceClientProtocol

use of com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol in project azure-iot-sdk-java by Azure.

the class FeedbackReceiverTest method receive_async_without_deviceId.

// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_013: [The function shall create an async wrapper around the receive() function call]
@Test
public void receive_async_without_deviceId() throws Exception {
    // Arrange
    String hostName = "xxx";
    String userName = "xxx";
    String sasToken = "xxx";
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    FeedbackReceiver feedbackReceiver = new FeedbackReceiver(hostName, userName, sasToken, iotHubServiceClientProtocol);
    // Assert
    new Expectations() {

        {
            amqpReceive.receive(Deencapsulation.getField(feedbackReceiver, "DEFAULT_TIMEOUT_MS"));
            feedbackReceiver.receive();
        }
    };
    // Act
    CompletableFuture<FeedbackBatch> completableFuture = feedbackReceiver.receiveAsync();
    completableFuture.get();
}
Also used : Expectations(mockit.Expectations) FeedbackReceiver(com.microsoft.azure.sdk.iot.service.FeedbackReceiver) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) FeedbackBatch(com.microsoft.azure.sdk.iot.service.FeedbackBatch) Test(org.junit.Test)

Example 3 with IotHubServiceClientProtocol

use of com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol in project azure-iot-sdk-java by Azure.

the class FeedbackReceiverTest method constructor_input_sasToken_null.

// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_001: [The constructor shall throw IllegalArgumentException if any the input string is null or empty]
// Assert
@Test(expected = IllegalArgumentException.class)
public void constructor_input_sasToken_null() throws Exception {
    // Arrange
    String hostName = "xxx";
    String userName = "xxx";
    String sasToken = null;
    String deviceId = "xxx";
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    // Act
    FeedbackReceiver feedbackReceiver = new FeedbackReceiver(hostName, userName, sasToken, iotHubServiceClientProtocol, deviceId);
}
Also used : FeedbackReceiver(com.microsoft.azure.sdk.iot.service.FeedbackReceiver) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) Test(org.junit.Test)

Example 4 with IotHubServiceClientProtocol

use of com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol in project azure-iot-sdk-java by Azure.

the class FeedbackReceiverTest method receive_with_timout_call_receive_timeout_without_deviceId.

// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_010: [The function shall call receive() on the member AMQPReceive object and return with the result]
@Test
public void receive_with_timout_call_receive_timeout_without_deviceId() throws Exception {
    // Arrange
    long timeoutMs = 1000;
    String hostName = "xxx";
    String userName = "xxx";
    String sasToken = "xxx";
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    FeedbackReceiver feedbackReceiver = new FeedbackReceiver(hostName, userName, sasToken, iotHubServiceClientProtocol);
    // Assert
    new Expectations() {

        {
            amqpReceive.receive(timeoutMs);
        }
    };
    // Act
    feedbackReceiver.receive(timeoutMs);
}
Also used : Expectations(mockit.Expectations) FeedbackReceiver(com.microsoft.azure.sdk.iot.service.FeedbackReceiver) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) Test(org.junit.Test)

Example 5 with IotHubServiceClientProtocol

use of com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol in project azure-iot-sdk-java by Azure.

the class FeedbackReceiverTest method constructor_input_deviceId_null.

// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_001: [The constructor shall throw IllegalArgumentException if any the input string is null or empty]
// Assert
@Test(expected = IllegalArgumentException.class)
public void constructor_input_deviceId_null() throws Exception {
    // Arrange
    String hostName = "xxx";
    String userName = "xxx";
    String sasToken = "xxx";
    String deviceId = null;
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    // Act
    FeedbackReceiver feedbackReceiver = new FeedbackReceiver(hostName, userName, sasToken, iotHubServiceClientProtocol, deviceId);
}
Also used : FeedbackReceiver(com.microsoft.azure.sdk.iot.service.FeedbackReceiver) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) Test(org.junit.Test)

Aggregations

IotHubServiceClientProtocol (com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol)137 Test (org.junit.Test)137 Expectations (mockit.Expectations)60 FeedbackReceiver (com.microsoft.azure.sdk.iot.service.FeedbackReceiver)40 AmqpSendHandler (com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpSendHandler)20 IotHubConnectionString (com.microsoft.azure.sdk.iot.service.IotHubConnectionString)19 FileUploadNotificationReceiver (com.microsoft.azure.sdk.iot.service.FileUploadNotificationReceiver)17 ServiceClient (com.microsoft.azure.sdk.iot.service.ServiceClient)17 AmqpSend (com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpSend)15 Verifications (mockit.Verifications)11 Message (com.microsoft.azure.sdk.iot.service.Message)7 AmqpFileUploadNotificationReceive (com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpFileUploadNotificationReceive)7 AmqpReceive (com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpReceive)7 AmqpFeedbackReceivedHandler (com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpFeedbackReceivedHandler)6 FeedbackBatch (com.microsoft.azure.sdk.iot.service.FeedbackBatch)4 WebSocketImpl (com.microsoft.azure.sdk.iot.deps.ws.impl.WebSocketImpl)3 IOException (java.io.IOException)3 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)3 MockUp (mockit.MockUp)3 Symbol (org.apache.qpid.proton.amqp.Symbol)3