use of com.microsoft.azure.sdk.iot.device.DeviceClient in project azure-iot-sdk-java by Azure.
the class JobClientTests method setUp.
@BeforeClass
public static void setUp() throws IOException, IotHubException, InterruptedException, URISyntaxException {
iotHubConnectionString = Tools.retrieveEnvironmentVariableValue(TestConstants.IOT_HUB_CONNECTION_STRING_ENV_VAR_NAME);
isBasicTierHub = Boolean.parseBoolean(Tools.retrieveEnvironmentVariableValue(TestConstants.IS_BASIC_TIER_HUB_ENV_VAR_NAME));
isPullRequest = Boolean.parseBoolean(Tools.retrieveEnvironmentVariableValue(TestConstants.IS_PULL_REQUEST));
jobClient = new JobClient(iotHubConnectionString);
registryManager = new RegistryManager(iotHubConnectionString, RegistryManagerOptions.builder().httpReadTimeout(HTTP_READ_TIMEOUT).build());
String uuid = UUID.randomUUID().toString();
for (int i = 0; i < MAX_DEVICES; i++) {
testDevice = Tools.addDeviceWithRetry(registryManager, Device.createFromId(DEVICE_ID_NAME.concat("-" + i + "-" + uuid), DeviceStatus.Enabled, null));
DeviceTestManager testManager = new DeviceTestManager(new DeviceClient(registryManager.getDeviceConnectionString(testDevice), IotHubClientProtocol.AMQPS));
testManager.client.open();
testManager.subscribe(true, true);
devices.add(testManager);
}
}
use of com.microsoft.azure.sdk.iot.device.DeviceClient in project azure-iot-sdk-java by Azure.
the class DeviceTwinWithVersionTests method createDevice.
private void createDevice(IotHubClientProtocol protocol) throws IOException, URISyntaxException {
testInstance.deviceTwinWithVersionTestDevice.deviceClient = new DeviceClient(DeviceConnectionString.get(iotHubConnectionString, testInstance.deviceForRegistryManager), protocol);
testInstance.deviceTwinWithVersionTestDevice.deviceClient.open();
testInstance.deviceTwinWithVersionTestDevice.deviceClient.startDeviceTwin(new DeviceTwinStatusCallBack(), testInstance.deviceTwinWithVersionTestDevice, new DeviceTwinPropertyCallback(), testInstance.deviceTwinWithVersionTestDevice);
}
use of com.microsoft.azure.sdk.iot.device.DeviceClient in project azure-iot-sdk-java by Azure.
the class ProvisioningTests method sendReportedPropertyUpdate.
private void sendReportedPropertyUpdate(String expectedReportedPropertyName, String expectedReportedPropertyValue, String iothubUri, String deviceId) throws InterruptedException, IOException, URISyntaxException {
// hardcoded AMQP here only because we aren't testing this connection. We just need to open a connection to send a twin update so that
// we can test if the twin updates carry over after reprovisioning
DeviceClient deviceClient = DeviceClient.createFromSecurityProvider(iothubUri, deviceId, testInstance.securityProvider, IotHubClientProtocol.AMQPS);
deviceClient.open();
CountDownLatch twinLock = new CountDownLatch(2);
deviceClient.startDeviceTwin(new StubTwinCallback(twinLock), null, new StubTwinCallback(twinLock), null);
Set<Property> reportedProperties = new HashSet<>();
reportedProperties.add(new Property(expectedReportedPropertyName, expectedReportedPropertyValue));
deviceClient.sendReportedProperties(reportedProperties);
twinLock.await(MAX_TWIN_PROPAGATION_WAIT_SECONDS, TimeUnit.SECONDS);
deviceClient.closeNow();
}
Aggregations