Tools.getTestModule(String iotHubConnectionString, IotHubClientProtocol protocol, AuthenticationType authenticationType, boolean needCleanTwin) 方法

定义

Return a module identity and client that can be used for a test. If a recycled identity is available to use, this method will prioritize using that instead of creating a new identity. When creating a new identity, this method will not create a batch of identities since there is no bulk add service API for just modules. This method will also prioritize returning cached identities with twin changes over cached identities with no twin changes, but needCleanTwin can be used to never return a cached identity with twin changes.

For instance, a test method that just wants to send telemetry from a module identity should set needCleanTwin to false so that it can use any available module. Conversely, a test method that involves setting reported or desired properties should set needCleanTwin to true to avoid previous twin state interfering with the upcoming test.

public static TestModuleIdentity getTestModule(String iotHubConnectionString, IotHubClientProtocol protocol, AuthenticationType authenticationType, boolean needCleanTwin)

参数

iotHubConnectionString
String

The connection string for the IoT Hub where the identity will be registered to.

protocol
IotHubClientProtocol

The device side protocol for the client to use.

authenticationType
AuthenticationType

The device side authentication type for the client to use.

needCleanTwin
boolean

True if the returned module identity needs to not have any pre-existing desired or reported properties, false otherwise.

返回

A TestDeviceIdentity that was either recycled from a previous test when possible, or was just created for this test.

例外

URISyntaxException

If the connection string cannot be parsed.

IOException

If the registry addition of a module fails.

IotHubException

If the registry addition of a module fails.

GeneralSecurityException

If creating the x509 certificates for an x509 module fails.

适用于