Search in sources :

Example 6 with AmqpReceive

use of com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpReceive in project azure-iot-sdk-java by Azure.

the class AmqpReceiveTest method receive_with_timout_zero_call_flow_ok.

// Tests_SRS_SERVICE_SDK_JAVA_AMQPRECEIVE_12_005: [The function shall initialize the Proton reactor object]
// Tests_SRS_SERVICE_SDK_JAVA_AMQPRECEIVE_12_006: [The function shall start the Proton reactor object]
// Tests_SRS_SERVICE_SDK_JAVA_AMQPRECEIVE_12_008: [The function shall stop and free the Proton reactor object ]
@Test
public void receive_with_timout_zero_call_flow_ok() throws IOException, InterruptedException {
    // Arrange
    String hostName = "aaa";
    String userName = "bbb";
    String sasToken = "ccc";
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    int timeoutMs = 0;
    AmqpReceive amqpReceive = new AmqpReceive(hostName, userName, sasToken, iotHubServiceClientProtocol);
    amqpReceive.open();
    // Assert
    new Expectations() {

        {
            reactor = proton.reactor(amqpReceive);
            reactor.start();
            reactor.stop();
            reactor.process();
            reactor.free();
        }
    };
    // Act
    amqpReceive.receive(timeoutMs);
}
Also used : Expectations(mockit.Expectations) AmqpReceive(com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpReceive) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) Test(org.junit.Test)

Example 7 with AmqpReceive

use of com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpReceive in project azure-iot-sdk-java by Azure.

the class AmqpReceiveTest method receiveWithTimout_non_zero_call_ok.

// Tests_SRS_SERVICE_SDK_JAVA_AMQPRECEIVE_12_005: [The function shall initialize the Proton reactor object]
// Tests_SRS_SERVICE_SDK_JAVA_AMQPRECEIVE_12_006: [The function shall start the Proton reactor object]
// Tests_SRS_SERVICE_SDK_JAVA_AMQPRECEIVE_12_008: [The function shall stop and free the Proton reactor object ]
@Test
public void receiveWithTimout_non_zero_call_ok() throws IOException, InterruptedException {
    // Arrange
    String hostName = "aaa";
    String userName = "bbb";
    String sasToken = "ccc";
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    int timeoutMs = 1;
    AmqpReceive amqpReceive = new AmqpReceive(hostName, userName, sasToken, iotHubServiceClientProtocol);
    amqpReceive.open();
    // Assert
    new Expectations() {

        {
            reactor = proton.reactor(amqpReceive);
            reactor.start();
            reactor.stop();
            reactor.process();
            reactor.free();
        }
    };
    // Act
    amqpReceive.receive(timeoutMs);
}
Also used : Expectations(mockit.Expectations) AmqpReceive(com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpReceive) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) Test(org.junit.Test)

Aggregations

IotHubServiceClientProtocol (com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol)7 AmqpReceive (com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpReceive)7 Test (org.junit.Test)7 Expectations (mockit.Expectations)5 FeedbackReceiver (com.microsoft.azure.sdk.iot.service.FeedbackReceiver)1