use of com.microsoft.azure.sdk.iot.service.Device in project azure-iot-sdk-java by Azure.
the class SendMessagesIT method SendMessagesOverAmqps_multithreaded.
@Test
public void SendMessagesOverAmqps_multithreaded() throws URISyntaxException, IOException, InterruptedException {
List<Thread> threads = new ArrayList<>(deviceListAmqps.length);
CountDownLatch cdl = new CountDownLatch(deviceListAmqps.length);
Integer count = 0;
for (Device deviceAmqps : deviceListAmqps) {
Thread thread = new Thread(new TestDevice(deviceAmqps, IotHubClientProtocol.AMQPS, NUM_CONNECTIONS_PER_DEVICE, NUM_MESSAGES_PER_CONNECTION, NUM_KEYS_PER_MESSAGE, SEND_TIMEOUT_MILLISECONDS, cdl));
thread.start();
threads.add(thread);
count++;
}
cdl.await();
if (!succeed.get()) {
Assert.fail("Sending message over AMQP protocol in parallel failed");
}
}
use of com.microsoft.azure.sdk.iot.service.Device in project azure-iot-sdk-java by Azure.
the class DeviceTest method device_get_all_properties.
// Tests_SRS_SERVICE_SDK_JAVA_DEVICE_12_001: [The Device class has the following properties: Id, Etag, Authentication.SymmetricKey, State, StateReason, StateUpdatedTime, ConnectionState, ConnectionStateUpdatedTime, LastActivityTime]
// Assert
@Test(expected = IllegalArgumentException.class)
public void device_get_all_properties() throws NoSuchAlgorithmException {
// Arrange
String deviceId = "xxx-device";
// Act
Device device = Device.createFromId(deviceId, null, null);
device.getDeviceId();
device.getGenerationId();
device.getSymmetricKey();
device.getPrimaryKey();
device.getSecondaryKey();
device.geteTag();
device.getStatus();
device.getStatusReason();
device.getStatusUpdatedTime();
device.getConnectionState();
device.getConnectionStateUpdatedTime();
device.getLastActivityTime();
device.getCloudToDeviceMessageCount();
device.setForceUpdate(true);
device.setForceUpdate(null);
}
use of com.microsoft.azure.sdk.iot.service.Device in project azure-iot-sdk-java by Azure.
the class DeviceTest method constructor_string_empty.
// Tests_SRS_SERVICE_SDK_JAVA_DEVICE_12_004: [The constructor shall throw IllegalArgumentException if the input string is empty or null]
// Assert
@Test(expected = IllegalArgumentException.class)
public void constructor_string_empty() throws NoSuchAlgorithmException {
// Arrange
String deviceId = "";
// Act
Device device = Deencapsulation.newInstance(Device.class, deviceId, null, null);
}
use of com.microsoft.azure.sdk.iot.service.Device in project azure-iot-sdk-java by Azure.
the class DeviceTest method constructor_create_symmetrickey.
// Tests_SRS_SERVICE_SDK_JAVA_DEVICE_12_005: [If the input symmetric key is empty, the constructor shall create
// a new SymmetricKey instance using AES encryption and store it into a member variable]
@Test
public void constructor_create_symmetrickey() throws NoSuchAlgorithmException {
// Arrange
String encryptionMethod = "AES";
String deviceId = "xxx-device";
new NonStrictExpectations() {
{
SymmetricKey symmetricKey = new SymmetricKey();
KeyGenerator.getInstance(encryptionMethod);
}
};
// Act
Device device = Deencapsulation.newInstance(Device.class, deviceId, DeviceStatus.class, SymmetricKey.class);
// Assert
assertNotEquals(device.getSymmetricKey(), null);
}
use of com.microsoft.azure.sdk.iot.service.Device in project azure-iot-sdk-java by Azure.
the class DeviceTest method constructor_string_null.
// Tests_SRS_SERVICE_SDK_JAVA_DEVICE_12_004: [The constructor shall throw IllegalArgumentException if the input string is empty or null]
// Assert
@Test(expected = IllegalArgumentException.class)
public void constructor_string_null() throws NoSuchAlgorithmException {
// Arrange
String deviceId = null;
// Act
Device device = Deencapsulation.newInstance(Device.class, deviceId, null, null);
}
Aggregations