use of tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest in project azure-iot-sdk-java by Azure.
the class FileUploadTests method uploadToBlobAsyncMultipleFilesParallel.
@Test(timeout = MAX_MILLISECS_TIMEOUT_KILL_TEST)
@ContinuousIntegrationTest
public void uploadToBlobAsyncMultipleFilesParallel() throws URISyntaxException, IOException, InterruptedException, IotHubException, GeneralSecurityException {
if (testInstance.withProxy) {
// No need to do performance test both with and without proxy
return;
}
// arrange
DeviceClient deviceClient = setUpDeviceClient(testInstance.protocol);
ExecutorService executor = Executors.newFixedThreadPool(2);
// act
for (int i = 1; i < MAX_FILES_TO_UPLOAD; i++) {
final int index = i;
executor.submit(() -> {
try {
deviceClient.uploadToBlobAsync(testInstance.fileUploadState[index].blobName, testInstance.fileUploadState[index].fileInputStream, testInstance.fileUploadState[index].fileLength, new FileUploadCallback(), testInstance.fileUploadState[index]);
} catch (IOException e) {
fail(buildExceptionMessage("IOException occurred during upload: " + Tools.getStackTraceFromThrowable(e), deviceClient));
}
});
// assert
waitForFileUploadStatusCallbackTriggered(i, deviceClient);
assertEquals(buildExceptionMessage("Expected SUCCESS but file upload status " + i + " was " + testInstance.fileUploadState[i].fileUploadStatus, deviceClient), SUCCESS, testInstance.fileUploadState[i].fileUploadStatus);
assertEquals(buildExceptionMessage("Expected SUCCESS but message status " + i + " was " + testInstance.messageStates[i].messageStatus, deviceClient), SUCCESS, testInstance.messageStates[i].messageStatus);
}
executor.shutdown();
if (!executor.awaitTermination(10000, TimeUnit.MILLISECONDS)) {
executor.shutdownNow();
}
tearDownDeviceClient(deviceClient);
}
use of tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest in project azure-iot-sdk-java by Azure.
the class SendMessagesTests method sendMessagesWithUnusualApplicationProperties.
@Test
@ContinuousIntegrationTest
public void sendMessagesWithUnusualApplicationProperties() throws Exception {
this.testInstance.setup();
this.testInstance.identity.getClient().open();
Message msg = new Message("asdf");
// All of these characters should be allowed within application properties
msg.setProperty("TestKey1234!#$%&'*+-^_`|~", "TestValue1234!#$%&'*+-^_`|~()<>@,;:\\\"[]?={} \t");
// ()<>@,;:\"[]?={}
IotHubServicesCommon.sendMessageAndWaitForResponse(this.testInstance.identity.getClient(), new MessageAndResult(msg, IotHubStatusCode.OK_EMPTY), RETRY_MILLISECONDS, SEND_TIMEOUT_MILLISECONDS, testInstance.protocol);
this.testInstance.identity.getClient().closeNow();
}
use of tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest in project azure-iot-sdk-java by Azure.
the class DeviceTwinWithVersionTests method testUpdateReportedPropertiesWithHigherVersionFailed.
@Test
@StandardTierHubOnlyTest
@ContinuousIntegrationTest
public void testUpdateReportedPropertiesWithHigherVersionFailed() throws IOException, InterruptedException, URISyntaxException, IotHubException {
// arrange
createDevice(testInstance.protocol);
testInstance.deviceTwinWithVersionTestDevice.expectedProperties = new HashSet<>(PROPERTIES);
// Create the first version of the reported properties.
testInstance.deviceTwinWithVersionTestDevice.deviceTwinStatus = STATUS.UNKNOWN;
testInstance.deviceTwinWithVersionTestDevice.deviceClient.sendReportedProperties(PROPERTIES);
Thread.sleep(MAXIMUM_TIME_TO_WAIT_FOR_IOTHUB);
testInstance.deviceTwinWithVersionTestDevice.deviceClient.getDeviceTwin();
long startTime = System.currentTimeMillis();
while (!testInstance.deviceTwinWithVersionTestDevice.expectedProperties.isEmpty()) {
if (System.currentTimeMillis() - startTime > EXPECTED_PROPERTIES_MAX_WAIT_MILLISECONDS) {
fail(buildExceptionMessage("Timed out waiting for expected property change", testInstance.deviceTwinWithVersionTestDevice.deviceClient));
}
Thread.sleep(BREATHE_TIME);
if (testInstance.deviceTwinWithVersionTestDevice.deviceTwinStatus == STATUS.IOTHUB_FAILURE) {
throw new IOException("IoTHub send Http error code");
}
if (testInstance.deviceTwinWithVersionTestDevice.deviceTwinStatus == STATUS.BAD_ANSWER) {
throw new IOException(testInstance.deviceTwinWithVersionTestDevice.exception);
}
}
assertEquals(buildExceptionMessage("Expected 2, but reported properties version was " + testInstance.deviceTwinWithVersionTestDevice.reportedPropertyVersion, testInstance.deviceTwinWithVersionTestDevice.deviceClient), 2, (int) testInstance.deviceTwinWithVersionTestDevice.reportedPropertyVersion);
// New values for the reported properties
final Set<Property> newValues = new HashSet<Property>() {
{
add(new Property(PROPERTY_KEY_1, "newValue1"));
add(new Property(PROPERTY_KEY_2, "newValue2"));
}
};
testInstance.deviceTwinWithVersionTestDevice.expectedProperties = new HashSet<>(newValues);
testInstance.deviceTwinWithVersionTestDevice.deviceTwinStatus = STATUS.UNKNOWN;
testInstance.deviceTwinWithVersionTestDevice.reportedPropertyVersion = null;
testInstance.deviceTwinWithVersionTestDevice.receivedProperties = new HashSet<>();
// act
testInstance.deviceTwinWithVersionTestDevice.deviceClient.sendReportedProperties(newValues, 3);
// assert
// test device client
Thread.sleep(MAXIMUM_TIME_TO_WAIT_FOR_IOTHUB);
while ((testInstance.deviceTwinWithVersionTestDevice.deviceTwinStatus != STATUS.BAD_ANSWER) && (testInstance.deviceTwinWithVersionTestDevice.deviceTwinStatus != STATUS.IOTHUB_FAILURE)) {
Thread.sleep(BREATHE_TIME);
}
testInstance.deviceTwinWithVersionTestDevice.expectedProperties = new HashSet<>(PROPERTIES);
testInstance.deviceTwinWithVersionTestDevice.deviceTwinStatus = STATUS.UNKNOWN;
testInstance.deviceTwinWithVersionTestDevice.reportedPropertyVersion = null;
testInstance.deviceTwinWithVersionTestDevice.receivedProperties = new HashSet<>();
testInstance.deviceTwinWithVersionTestDevice.deviceClient.getDeviceTwin();
startTime = System.currentTimeMillis();
while (!testInstance.deviceTwinWithVersionTestDevice.expectedProperties.isEmpty()) {
if (System.currentTimeMillis() - startTime > EXPECTED_PROPERTIES_MAX_WAIT_MILLISECONDS) {
fail(buildExceptionMessage("Timed out waiting for expected property change", testInstance.deviceTwinWithVersionTestDevice.deviceClient));
}
Thread.sleep(BREATHE_TIME);
if (testInstance.deviceTwinWithVersionTestDevice.deviceTwinStatus == STATUS.BAD_ANSWER) {
throw new IOException(testInstance.deviceTwinWithVersionTestDevice.exception);
}
}
assertEquals(buildExceptionMessage("Expected 2, but reported properties version was " + testInstance.deviceTwinWithVersionTestDevice.reportedPropertyVersion, testInstance.deviceTwinWithVersionTestDevice.deviceClient), 2, (int) testInstance.deviceTwinWithVersionTestDevice.reportedPropertyVersion);
// test service client
DeviceTwinDevice deviceOnServiceClient = new DeviceTwinDevice(testInstance.deviceTwinWithVersionTestDevice.deviceId);
testInstance.twinServiceClient.getTwin(deviceOnServiceClient);
assertEquals(buildExceptionMessage("Expected reported properties version 2 but was " + deviceOnServiceClient.getReportedPropertiesVersion(), testInstance.deviceTwinWithVersionTestDevice.deviceClient), 2, (int) deviceOnServiceClient.getReportedPropertiesVersion());
Set<Pair> reported = deviceOnServiceClient.getReportedProperties();
assertSetEquals(PROPERTIES, reported);
}
use of tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest in project azure-iot-sdk-java by Azure.
the class ServiceClientTests method serviceClientValidatesRemoteCertificateWhenGettingFileUploadFeedbackReceiver.
// The IoT Hub instance we use for this test is currently offline, so this test cannot be run
@Ignore
@Test
@ContinuousIntegrationTest
public void serviceClientValidatesRemoteCertificateWhenGettingFileUploadFeedbackReceiver() throws IOException {
boolean expectedExceptionWasCaught = false;
ServiceClient serviceClient = ServiceClient.createFromConnectionString(invalidCertificateServerConnectionString, testInstance.protocol);
try {
serviceClient.open();
FileUploadNotificationReceiver receiver = serviceClient.getFileUploadNotificationReceiver();
receiver.open();
receiver.receive(1000);
} catch (IOException e) {
expectedExceptionWasCaught = true;
} catch (Exception e) {
fail(buildExceptionMessage("Expected IOException, but received: " + Tools.getStackTraceFromThrowable(e), hostName));
}
assertTrue(buildExceptionMessage("Expected an exception due to service presenting invalid certificate", hostName), expectedExceptionWasCaught);
}
use of tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest in project azure-iot-sdk-java by Azure.
the class ServiceClientTests method serviceClientValidatesRemoteCertificateWhenGettingFeedbackReceiver.
// The IoT Hub instance we use for this test is currently offline, so this test cannot be run
@Ignore
@Test
@ContinuousIntegrationTest
public void serviceClientValidatesRemoteCertificateWhenGettingFeedbackReceiver() throws IOException {
boolean expectedExceptionWasCaught = false;
ServiceClient serviceClient = ServiceClient.createFromConnectionString(invalidCertificateServerConnectionString, testInstance.protocol);
try {
serviceClient.open();
FeedbackReceiver receiver = serviceClient.getFeedbackReceiver();
receiver.open();
receiver.receive(1000);
} catch (IOException e) {
expectedExceptionWasCaught = true;
} catch (Exception e) {
fail(buildExceptionMessage("Expected IOException, but received: " + Tools.getStackTraceFromThrowable(e), hostName));
}
assertTrue(buildExceptionMessage("Expected an exception due to service presenting invalid certificate", hostName), expectedExceptionWasCaught);
}
Aggregations