Search in sources :

Example 16 with ServiceClient

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

the class ServiceClientTest method open_async_future_return_ok.

// Tests_SRS_SERVICE_SDK_JAVA_SERVICECLIENT_12_014: [The function shall create an async wrapper around the open() function call, handle the return value or delegate exception]
@Test
public void open_async_future_return_ok() throws Exception {
    // Arrange
    String iotHubName = "IOTHUBNAME";
    String hostName = "HOSTNAME";
    String sharedAccessKeyName = "ACCESSKEYNAME";
    String policyName = "SharedAccessKey";
    String sharedAccessKey = "1234567890abcdefghijklmnopqrstvwxyz=";
    String connectionString = "HostName=" + hostName + "." + iotHubName + ";SharedAccessKeyName=" + sharedAccessKeyName + ";" + policyName + "=" + sharedAccessKey;
    IotHubConnectionString iotHubConnectionString = IotHubConnectionStringBuilder.createConnectionString(connectionString);
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    ServiceClient serviceClient = ServiceClient.createFromConnectionString(connectionString, iotHubServiceClientProtocol);
    // Assert
    new Expectations() {

        {
            amqpSend.open();
            serviceClient.open();
        }
    };
    // Act
    CompletableFuture<Void> completableFuture = serviceClient.openAsync();
    completableFuture.get();
}
Also used : Expectations(mockit.Expectations) ServiceClient(com.microsoft.azure.sdk.iot.service.ServiceClient) IotHubConnectionString(com.microsoft.azure.sdk.iot.service.IotHubConnectionString) IotHubConnectionString(com.microsoft.azure.sdk.iot.service.IotHubConnectionString) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) Test(org.junit.Test)

Example 17 with ServiceClient

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

the class ServiceClientTest method getFeedbackReceiver_good_case_without_deviceid.

// Tests_SRS_SERVICE_SDK_JAVA_SERVICECLIENT_12_017: [The function shall create a FeedbackReceiver object and returns with it]
@Test
public void getFeedbackReceiver_good_case_without_deviceid() throws Exception {
    // Arrange
    String iotHubName = "IOTHUBNAME";
    String hostName = "HOSTNAME";
    String sharedAccessKeyName = "ACCESSKEYNAME";
    String policyName = "SharedAccessKey";
    String sharedAccessKey = "1234567890abcdefghijklmnopqrstvwxyz=";
    String connectionString = "HostName=" + hostName + "." + iotHubName + ";SharedAccessKeyName=" + sharedAccessKeyName + ";" + policyName + "=" + sharedAccessKey;
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    ServiceClient serviceClient = ServiceClient.createFromConnectionString(connectionString, iotHubServiceClientProtocol);
    // Assert
    new Expectations() {

        {
            feedbackReceiver = new FeedbackReceiver(anyString, anyString, anyString, iotHubServiceClientProtocol);
        }
    };
    // Act
    FeedbackReceiver feedbackReceiver = serviceClient.getFeedbackReceiver();
    // Assert
    assertNotEquals(null, feedbackReceiver);
}
Also used : Expectations(mockit.Expectations) ServiceClient(com.microsoft.azure.sdk.iot.service.ServiceClient) FeedbackReceiver(com.microsoft.azure.sdk.iot.service.FeedbackReceiver) IotHubConnectionString(com.microsoft.azure.sdk.iot.service.IotHubConnectionString) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) Test(org.junit.Test)

Aggregations

IotHubConnectionString (com.microsoft.azure.sdk.iot.service.IotHubConnectionString)17 IotHubServiceClientProtocol (com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol)17 ServiceClient (com.microsoft.azure.sdk.iot.service.ServiceClient)17 Test (org.junit.Test)17 Expectations (mockit.Expectations)10 Message (com.microsoft.azure.sdk.iot.service.Message)4 IOException (java.io.IOException)3 MockUp (mockit.MockUp)3 FeedbackReceiver (com.microsoft.azure.sdk.iot.service.FeedbackReceiver)2 IotHubServiceSasToken (com.microsoft.azure.sdk.iot.service.auth.IotHubServiceSasToken)1 AmqpSend (com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpSend)1