use of com.microsoft.azure.sdk.iot.device.fileupload.FileUpload in project azure-iot-sdk-java by Azure.
the class FileUploadTest method constructorExecutorThrows.
/* Tests_SRS_FILEUPLOAD_21_015: [If create the executor failed, the constructor shall throws IOException.] */
@Test(expected = IOException.class)
public void constructorExecutorThrows() throws IOException {
// arrange
new NonStrictExpectations() {
{
new HttpsTransportManager(mockConfig);
result = mockHttpsTransportManager;
Executors.newScheduledThreadPool(10);
result = new IllegalArgumentException();
times = 1;
}
};
// act
FileUpload fileUpload = new FileUpload(mockConfig);
}
use of com.microsoft.azure.sdk.iot.device.fileupload.FileUpload in project azure-iot-sdk-java by Azure.
the class FileUploadTest method constructorHttpsTransportManagerThrows.
/* Tests_SRS_FILEUPLOAD_21_003: [If the constructor fail to create the new instance of the `HttpsTransportManager`, it shall throw IllegalArgumentException, threw by the HttpsTransportManager constructor.] */
@Test(expected = IllegalArgumentException.class)
public void constructorHttpsTransportManagerThrows() throws IOException {
// arrange
new NonStrictExpectations() {
{
new HttpsTransportManager(mockConfig);
result = new IllegalArgumentException();
times = 1;
}
};
// act
FileUpload fileUpload = new FileUpload(mockConfig);
}
use of com.microsoft.azure.sdk.iot.device.fileupload.FileUpload in project azure-iot-sdk-java by Azure.
the class FileUploadTest method uploadToBlobAsyncEmptyBlobNameThrows.
/* Tests_SRS_FILEUPLOAD_21_005: [If the `blobName` is null or empty, the uploadToBlobAsync shall throw IllegalArgumentException.] */
@Test(expected = IllegalArgumentException.class)
public void uploadToBlobAsyncEmptyBlobNameThrows() throws IOException {
// arrange
final String blobName = "";
final long streamLength = 100;
final Map<String, Object> context = new HashMap<>();
constructorExpectations();
FileUpload fileUpload = new FileUpload(mockConfig);
// act
fileUpload.uploadToBlobAsync(blobName, mockInputStream, streamLength, mockIotHubEventCallback, context);
}
use of com.microsoft.azure.sdk.iot.device.fileupload.FileUpload in project azure-iot-sdk-java by Azure.
the class FileUploadTest method callbackDeleteFileUploadInProgress.
/* Tests_SRS_FILEUPLOAD_21_021: [The FileUploadStatusCallBack shall delete the `FileUploadInProgress` that store this file upload context.] */
@Test
public void callbackDeleteFileUploadInProgress(@Mocked final LinkedBlockingDeque<?> mockFileUploadInProgressQueue) throws IOException {
// arrange
final Map<String, Object> context = new HashMap<>();
new NonStrictExpectations() {
{
new HttpsTransportManager(mockConfig);
result = mockHttpsTransportManager;
Executors.newScheduledThreadPool(10);
result = mockScheduler;
new LinkedBlockingDeque<>();
result = mockFileUploadInProgressQueue;
}
};
FileUpload fileUpload = new FileUpload(mockConfig);
IotHubEventCallback testFileUploadStatusCallBack = new FileUploadStatusCallBack();
// act
testFileUploadStatusCallBack.execute(IotHubStatusCode.OK_EMPTY, mockFileUploadInProgress);
// assert
new Verifications() {
{
mockFileUploadInProgressQueue.remove(mockFileUploadInProgress);
times = 1;
}
};
}
Aggregations