Search in sources :

Example 61 with IotHubConnectionString

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

the class IotHubConnectionStringTest method getUrlModuleDeviceNameNull.

// Tests_SRS_SERVICE_SDK_JAVA_IOTHUBCONNECTIONSTRING_28_001: [The function shall throw IllegalArgumentException if the deviceId string is empty or null]
// assert
@Test(expected = IllegalArgumentException.class)
public void getUrlModuleDeviceNameNull() throws IOException, IllegalArgumentException {
    // arrange
    final String deviceId = null;
    final String moduleId = "somemodule";
    final String iotHubName = "b.c.d";
    final String hostName = "HOSTNAME." + iotHubName;
    final String sharedAccessKeyName = "ACCESSKEYNAME";
    final String policyName = "SharedAccessKey";
    final String sharedAccessKey = "1234567890abcdefghijklmnopqrstvwxyz=";
    final String connectionString = "HostName=" + hostName + ";SharedAccessKeyName=" + sharedAccessKeyName + ";" + policyName + "=" + sharedAccessKey;
    final IotHubConnectionString iotHubConnectionString = IotHubConnectionStringBuilder.createConnectionString(connectionString);
    // act
    iotHubConnectionString.getUrlModule(deviceId, moduleId);
}
Also used : IotHubConnectionString(com.microsoft.azure.sdk.iot.service.IotHubConnectionString) IotHubConnectionString(com.microsoft.azure.sdk.iot.service.IotHubConnectionString) Test(org.junit.Test)

Example 62 with IotHubConnectionString

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

the class IotHubConnectionStringTest method getUrlDeviceDeviceNameNull.

// Tests_SRS_SERVICE_SDK_JAVA_IOTHUBCONNECTIONSTRING_12_002: [The function shall throw IllegalArgumentException if the input string is empty or null]
// assert
@Test(expected = IllegalArgumentException.class)
public void getUrlDeviceDeviceNameNull() throws IOException, IllegalArgumentException {
    // arrange
    final String deviceId = null;
    final String iotHubName = "b.c.d";
    final String hostName = "HOSTNAME." + iotHubName;
    final String sharedAccessKeyName = "ACCESSKEYNAME";
    final String policyName = "SharedAccessKey";
    final String sharedAccessKey = "1234567890abcdefghijklmnopqrstvwxyz=";
    final String connectionString = "HostName=" + hostName + ";SharedAccessKeyName=" + sharedAccessKeyName + ";" + policyName + "=" + sharedAccessKey;
    final IotHubConnectionString iotHubConnectionString = IotHubConnectionStringBuilder.createConnectionString(connectionString);
    // act
    iotHubConnectionString.getUrlDevice(deviceId);
}
Also used : IotHubConnectionString(com.microsoft.azure.sdk.iot.service.IotHubConnectionString) IotHubConnectionString(com.microsoft.azure.sdk.iot.service.IotHubConnectionString) Test(org.junit.Test)

Example 63 with IotHubConnectionString

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

the class IotHubConnectionStringTest method getUrlModuleOnDeviceDeviceNameEmpty.

// Tests_SRS_SERVICE_SDK_JAVA_IOTHUBCONNECTIONSTRING_28_008: [The function shall throw IllegalArgumentException if the moduleId string is empty or null]
// assert
@Test(expected = IllegalArgumentException.class)
public void getUrlModuleOnDeviceDeviceNameEmpty() throws IOException, IllegalArgumentException {
    // arrange
    final String deviceId = "";
    final String iotHubName = "b.c.d";
    final String hostName = "HOSTNAME." + iotHubName;
    final String sharedAccessKeyName = "ACCESSKEYNAME";
    final String policyName = "SharedAccessKey";
    final String sharedAccessKey = "1234567890abcdefghijklmnopqrstvwxyz=";
    final String connectionString = "HostName=" + hostName + ";SharedAccessKeyName=" + sharedAccessKeyName + ";" + policyName + "=" + sharedAccessKey;
    final IotHubConnectionString iotHubConnectionString = IotHubConnectionStringBuilder.createConnectionString(connectionString);
    // act
    iotHubConnectionString.getUrlModulesOnDevice(deviceId);
}
Also used : IotHubConnectionString(com.microsoft.azure.sdk.iot.service.IotHubConnectionString) IotHubConnectionString(com.microsoft.azure.sdk.iot.service.IotHubConnectionString) Test(org.junit.Test)

Example 64 with IotHubConnectionString

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

the class IotHubConnectionStringTest method getUrlTwinThrowsOnNullDeviceID.

@Test(expected = IllegalArgumentException.class)
public void getUrlTwinThrowsOnNullDeviceID() throws IOException, IllegalArgumentException {
    // arrange
    final String iotHubName = "b.c.d";
    final String hostName = "HOSTNAME." + iotHubName;
    final String sharedAccessKeyName = "ACCESSKEYNAME";
    final String policyName = "SharedAccessKey";
    final String sharedAccessKey = "1234567890abcdefghijklmnopqrstvwxyz=";
    final String connectionString = "HostName=" + hostName + ";SharedAccessKeyName=" + sharedAccessKeyName + ";" + policyName + "=" + sharedAccessKey;
    final String deviceId = null;
    final IotHubConnectionString iotHubConnectionString = IotHubConnectionStringBuilder.createConnectionString(connectionString);
    // act
    iotHubConnectionString.getUrlTwin(deviceId).toString();
}
Also used : IotHubConnectionString(com.microsoft.azure.sdk.iot.service.IotHubConnectionString) IotHubConnectionString(com.microsoft.azure.sdk.iot.service.IotHubConnectionString) Test(org.junit.Test)

Example 65 with IotHubConnectionString

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

the class IotHubConnectionStringTest method getUrlConfigurationListMaxCountZero.

// Tests_SRS_SERVICE_SDK_JAVA_IOTHUBCONNECTIONSTRING_28_006: [The constructor shall throw NullPointerException if the input integer is 0]
// assert
@Test(expected = IllegalArgumentException.class)
public void getUrlConfigurationListMaxCountZero() throws IOException, IllegalArgumentException {
    // arrange
    Integer maxCount = 0;
    final String iotHubName = "b.c.d";
    final String hostName = "HOSTNAME." + iotHubName;
    final String sharedAccessKeyName = "ACCESSKEYNAME";
    final String policyName = "SharedAccessKey";
    final String sharedAccessKey = "1234567890abcdefghijklmnopqrstvwxyz=";
    final String connectionString = "HostName=" + hostName + ";SharedAccessKeyName=" + sharedAccessKeyName + ";" + policyName + "=" + sharedAccessKey;
    final IotHubConnectionString iotHubConnectionString = IotHubConnectionStringBuilder.createConnectionString(connectionString);
    // act
    iotHubConnectionString.getUrlConfigurationsList(maxCount);
}
Also used : IotHubConnectionString(com.microsoft.azure.sdk.iot.service.IotHubConnectionString) IotHubConnectionString(com.microsoft.azure.sdk.iot.service.IotHubConnectionString) Test(org.junit.Test)

Aggregations

IotHubConnectionString (com.microsoft.azure.sdk.iot.service.IotHubConnectionString)196 Test (org.junit.Test)171 IotHubServiceSasToken (com.microsoft.azure.sdk.iot.service.auth.IotHubServiceSasToken)30 Expectations (mockit.Expectations)21 IntegrationTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.IntegrationTest)20 ServiceClient (com.microsoft.azure.sdk.iot.service.ServiceClient)17 AzureSasCredential (com.azure.core.credential.AzureSasCredential)16 JobClient (com.microsoft.azure.sdk.iot.service.jobs.JobClient)13 StandardTierHubOnlyTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.StandardTierHubOnlyTest)13 Device (com.microsoft.azure.sdk.iot.service.Device)12 IotHubServiceClientProtocol (com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol)12 IotHubTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.IotHubTest)12 HttpResponse (com.microsoft.azure.sdk.iot.service.transport.http.HttpResponse)11 URL (java.net.URL)11 ContinuousIntegrationTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest)11 NonStrictExpectations (mockit.NonStrictExpectations)10 DeviceTwin (com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwin)9 ArrayList (java.util.ArrayList)9 Verifications (mockit.Verifications)9 DeviceClient (com.microsoft.azure.sdk.iot.device.DeviceClient)8