use of com.microsoft.azure.sdk.iot.service.digitaltwin.DigitalTwinClient in project azure-iot-sdk-java by Azure.
the class DigitalTwinClientTests method digitalTwinConstructorThrowsForNegativeReadTimeout.
@Test(expected = IllegalArgumentException.class)
@StandardTierHubOnlyTest
public void digitalTwinConstructorThrowsForNegativeReadTimeout() {
// arrange
DigitalTwinClientOptions clientOptions = DigitalTwinClientOptions.builder().httpReadTimeout(-1).build();
digitalTwinClient = new DigitalTwinClient(IOTHUB_CONNECTION_STRING, clientOptions);
}
use of com.microsoft.azure.sdk.iot.service.digitaltwin.DigitalTwinClient in project azure-iot-sdk-java by Azure.
the class DigitalTwinClientTests method getDigitalTwinWithProxy.
@Test
@StandardTierHubOnlyTest
public void getDigitalTwinWithProxy() {
// arrange
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(testProxyHostname, testProxyPort));
ProxyOptions proxyOptions = new ProxyOptions(proxy);
DigitalTwinClientOptions clientOptions = DigitalTwinClientOptions.builder().proxyOptions(proxyOptions).httpReadTimeout(0).build();
digitalTwinClient = new DigitalTwinClient(IOTHUB_CONNECTION_STRING, clientOptions);
// act
BasicDigitalTwin response = digitalTwinClient.getDigitalTwin(deviceId, BasicDigitalTwin.class);
ServiceResponseWithHeaders<BasicDigitalTwin, DigitalTwinGetHeaders> responseWithHeaders = digitalTwinClient.getDigitalTwinWithResponse(deviceId, BasicDigitalTwin.class);
// assert
assertEquals(response.getMetadata().getModelId(), E2ETestConstants.THERMOSTAT_MODEL_ID);
assertEquals(responseWithHeaders.body().getMetadata().getModelId(), E2ETestConstants.THERMOSTAT_MODEL_ID);
}
use of com.microsoft.azure.sdk.iot.service.digitaltwin.DigitalTwinClient in project azure-iot-sdk-java by Azure.
the class DigitalTwinClientTests method buildDigitalTwinClientWithAzureSasCredential.
private static DigitalTwinClient buildDigitalTwinClientWithAzureSasCredential() {
IotHubConnectionString iotHubConnectionStringObj = IotHubConnectionStringBuilder.createIotHubConnectionString(IOTHUB_CONNECTION_STRING);
IotHubServiceSasToken serviceSasToken = new IotHubServiceSasToken(iotHubConnectionStringObj);
AzureSasCredential azureSasCredential = new AzureSasCredential(serviceSasToken.toString());
DigitalTwinClientOptions options = DigitalTwinClientOptions.builder().httpReadTimeout(HTTP_READ_TIMEOUT).build();
return new DigitalTwinClient(iotHubConnectionStringObj.getHostName(), azureSasCredential, options);
}
Aggregations