use of com.microsoft.azure.sdk.iot.service.IotHubConnectionString in project azure-iot-sdk-java by Azure.
the class IotHubConnectionStringTest method getUrlConfigurationListGoodCase.
// Tests_SRS_SERVICE_SDK_JAVA_IOTHUBCONNECTIONSTRING_28_007: [The function shall create a URL object from the given
// integer using the following format: https:hostname/configurations/?maxCount=XX&api-version=201X-XX-XX]
@Test
public void getUrlConfigurationListGoodCase() throws IOException, IllegalArgumentException {
// arrange
Integer maxCount = 10;
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);
final String expected = "https://HOSTNAME.b.c.d/configurations?top=10&" + URL_API_VERSION;
// act
String actual = iotHubConnectionString.getUrlConfigurationsList(maxCount).toString();
// assert
assertEquals("ConfigurationList URL mismatch!", expected, actual);
}
use of com.microsoft.azure.sdk.iot.service.IotHubConnectionString in project azure-iot-sdk-java by Azure.
the class IotHubConnectionStringTest method getUrlDeviceDeviceNameEmpty.
// 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 getUrlDeviceDeviceNameEmpty() 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.getUrlDevice(deviceId);
}
use of com.microsoft.azure.sdk.iot.service.IotHubConnectionString in project azure-iot-sdk-java by Azure.
the class IotHubConnectionStringTest method getUserStringGoodCase.
// Tests_SRS_SERVICE_SDK_JAVA_IOTHUBCONNECTIONSTRING_12_001: [The function shall serialize the object properties to a string using the following format: SharedAccessKeyName@SAS.root.IotHubName]
@Test
public void getUserStringGoodCase() throws IOException {
// 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 IotHubConnectionString iotHubConnectionString = IotHubConnectionStringBuilder.createConnectionString(connectionString);
final String expected = sharedAccessKeyName + "@SAS.root.HOSTNAME";
// act
String actual = iotHubConnectionString.getUserString();
// assert
assertEquals("UserString mismatch!", expected, actual);
}
use of com.microsoft.azure.sdk.iot.service.IotHubConnectionString in project azure-iot-sdk-java by Azure.
the class IotHubConnectionStringTest method getUrlModuleTwinDeviceNameNull.
// Tests_SRS_SERVICE_SDK_JAVA_IOTHUBCONNECTIONSTRING_28_010: [The function shall throw IllegalArgumentException if the deviceId string is empty or null]
// assert
@Test(expected = IllegalArgumentException.class)
public void getUrlModuleTwinDeviceNameNull() 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.getUrlModuleTwin(deviceId, moduleId);
}
use of com.microsoft.azure.sdk.iot.service.IotHubConnectionString in project azure-iot-sdk-java by Azure.
the class IotHubConnectionStringTest method getUrlModuleOnDeviceDeviceNameNull.
// 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 getUrlModuleOnDeviceDeviceNameNull() 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.getUrlModulesOnDevice(deviceId);
}
Aggregations