use of com.microsoft.azure.sdk.iot.device.DeviceClientConfig in project azure-iot-sdk-java by Azure.
the class DeviceClientConfigTest method constructorWithConnectionStringKeySucceed.
// Tests_SRS_DEVICECLIENTCONFIG_21_033: [The constructor shall save the IoT Hub hostname, hubname,
// device ID, device key, and device token, provided in the `iotHubConnectionString`.]
@Test
public void constructorWithConnectionStringKeySucceed() throws URISyntaxException {
// arrange
final String iotHubname = "iotHubName";
final String iotHubHostname = iotHubname + ".iothubhostname";
final String deviceId = "test-deviceid";
final String deviceKey = "test-devicekey";
final IotHubConnectionString iotHubConnectionString = Deencapsulation.newInstance(IotHubConnectionString.class, new Class[] { String.class }, "HostName=" + iotHubHostname + ";CredentialType=SharedAccessKey;CredentialScope=Device;" + "DeviceId=" + deviceId + ";SharedAccessKey=" + deviceKey + ";");
// act
DeviceClientConfig config = new DeviceClientConfig(iotHubConnectionString);
// assert
assertNotNull(config);
IotHubConnectionString actualConnectionString = Deencapsulation.getField(config, "iotHubConnectionString");
assertEquals(iotHubHostname, actualConnectionString.getHostName());
assertEquals(iotHubname, actualConnectionString.getHubName());
assertEquals(deviceId, actualConnectionString.getDeviceId());
assertEquals(deviceKey, actualConnectionString.getSharedAccessKey());
}
use of com.microsoft.azure.sdk.iot.device.DeviceClientConfig in project azure-iot-sdk-java by Azure.
the class DeviceClientConfigTest method getUserCertificateGets.
//Tests_SRS_DEVICECLIENTCONFIG_25_030: [**The function shall return the value of the user certificate string.**] **
@Test
public void getUserCertificateGets() throws URISyntaxException {
final String iotHubHostname = "test.iothubhostname";
final String deviceId = "test-deviceid";
final String deviceKey = "test-devicekey";
final String sharedAccessToken = null;
final String cert = "ValidCertString";
final IotHubConnectionString iotHubConnectionString = Deencapsulation.newInstance(IotHubConnectionString.class, new Class[] { String.class, String.class, String.class, String.class }, iotHubHostname, deviceId, deviceKey, sharedAccessToken);
DeviceClientConfig config = new DeviceClientConfig(iotHubConnectionString);
config.setUserCertificateString(cert);
String testCert = config.getUserCertificateString();
assertNotNull(cert);
assertEquals(testCert, cert);
}
use of com.microsoft.azure.sdk.iot.device.DeviceClientConfig in project azure-iot-sdk-java by Azure.
the class DeviceClientConfigTest method getMessageLockTimeoutSecsReturnsConstant.
// Tests_SRS_DEVICECLIENTCONFIG_11_013: [The function shall return 180s.]
@Test
public void getMessageLockTimeoutSecsReturnsConstant() throws URISyntaxException {
final String iotHubHostname = "test.iothubhostname";
final String deviceId = "test-deviceid";
final String deviceKey = "test-devicekey";
final String sharedAccessToken = null;
final IotHubConnectionString iotHubConnectionString = Deencapsulation.newInstance(IotHubConnectionString.class, new Class[] { String.class, String.class, String.class, String.class }, iotHubHostname, deviceId, deviceKey, sharedAccessToken);
DeviceClientConfig config = new DeviceClientConfig(iotHubConnectionString);
int testMessageLockTimeoutSecs = config.getMessageLockTimeoutSecs();
final int expectedMessageLockTimeoutSecs = 180;
assertThat(testMessageLockTimeoutSecs, is(expectedMessageLockTimeoutSecs));
}
use of com.microsoft.azure.sdk.iot.device.DeviceClientConfig in project azure-iot-sdk-java by Azure.
the class DeviceClientConfigTest method getIotHubHostnameReturnsIotHubHostname.
// Tests_SRS_DEVICECLIENTCONFIG_11_002: [The function shall return the IoT Hub hostname given in the constructor.]
@Test
public void getIotHubHostnameReturnsIotHubHostname() throws URISyntaxException {
final String iotHubHostname = "test.iothubhostname";
final String deviceId = "test-deviceid";
final String deviceKey = "test-devicekey";
final String sharedAccessToken = null;
final IotHubConnectionString iotHubConnectionString = Deencapsulation.newInstance(IotHubConnectionString.class, new Class[] { String.class, String.class, String.class, String.class }, iotHubHostname, deviceId, deviceKey, sharedAccessToken);
DeviceClientConfig config = new DeviceClientConfig(iotHubConnectionString);
String testIotHubHostname = config.getIotHubHostname();
final String expectedIotHubHostname = iotHubHostname;
assertThat(testIotHubHostname, is(expectedIotHubHostname));
}
use of com.microsoft.azure.sdk.iot.device.DeviceClientConfig in project azure-iot-sdk-java by Azure.
the class DeviceClientConfigTest method getReadTimeoutMillisReturnsConstant.
// Tests_SRS_DEVICECLIENTCONFIG_11_012: [The function shall return 240000ms.]
@Test
public void getReadTimeoutMillisReturnsConstant() throws URISyntaxException {
final String iotHubHostname = "test.iothubhostname";
final String deviceId = "test-deviceid";
final String deviceKey = "test-devicekey";
final String sharedAccessToken = null;
final IotHubConnectionString iotHubConnectionString = Deencapsulation.newInstance(IotHubConnectionString.class, new Class[] { String.class, String.class, String.class, String.class }, iotHubHostname, deviceId, deviceKey, sharedAccessToken);
DeviceClientConfig config = new DeviceClientConfig(iotHubConnectionString);
int testReadTimeoutMillis = config.getReadTimeoutMillis();
final int expectedReadTimeoutMillis = 240000;
assertThat(testReadTimeoutMillis, is(expectedReadTimeoutMillis));
}
Aggregations