use of com.microsoft.azure.sdk.iot.device.fileupload.FileUpload in project azure-iot-sdk-java by Azure.
the class FileUploadTest method uploadToBlobAsyncNullUserCallbackThrows.
/* Tests_SRS_FILEUPLOAD_21_008: [If the `userCallback` is null, the uploadToBlobAsync shall throw IllegalArgumentException.] */
@Test(expected = IllegalArgumentException.class)
public void uploadToBlobAsyncNullUserCallbackThrows() throws IOException {
// arrange
final String blobName = "validBlobName";
final long streamLength = 100;
final Map<String, Object> context = new HashMap<>();
constructorExpectations();
new NonStrictExpectations() {
{
mockInputStream.available();
result = streamLength;
}
};
FileUpload fileUpload = new FileUpload(mockConfig);
// act
fileUpload.uploadToBlobAsync(blobName, mockInputStream, streamLength, null, context);
}
use of com.microsoft.azure.sdk.iot.device.fileupload.FileUpload in project azure-iot-sdk-java by Azure.
the class FileUploadTest method closeNowSuccess.
/* Tests_SRS_FILEUPLOAD_21_017: [The closeNow shall shutdown the thread pool by calling `shutdownNow`.] */
@Test
public void closeNowSuccess() throws IOException {
// arrange
constructorExpectations();
FileUpload fileUpload = new FileUpload(mockConfig);
// act
fileUpload.closeNow();
// assert
new Verifications() {
{
mockScheduler.shutdownNow();
times = 1;
}
};
}
use of com.microsoft.azure.sdk.iot.device.fileupload.FileUpload in project azure-iot-sdk-java by Azure.
the class FileUploadTest method uploadToBlobAsyncNullBlobNameThrows.
/* Tests_SRS_FILEUPLOAD_21_005: [If the `blobName` is null or empty, the uploadToBlobAsync shall throw IllegalArgumentException.] */
@Test(expected = IllegalArgumentException.class)
public void uploadToBlobAsyncNullBlobNameThrows() throws IOException {
// arrange
final String blobName = null;
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 uploadToBlobAsyncNullInputStreamThrows.
/* Tests_SRS_FILEUPLOAD_21_006: [If the `inputStream` is null or not available, the uploadToBlobAsync shall throw IllegalArgumentException.] */
@Test(expected = IllegalArgumentException.class)
public void uploadToBlobAsyncNullInputStreamThrows() throws IOException {
// arrange
final String blobName = "validBlobName";
final long streamLength = 100;
final Map<String, Object> context = new HashMap<>();
constructorExpectations();
new NonStrictExpectations() {
{
mockInputStream.available();
result = streamLength;
}
};
FileUpload fileUpload = new FileUpload(mockConfig);
// act
fileUpload.uploadToBlobAsync(blobName, null, 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 constructorSuccess.
/* Tests_SRS_FILEUPLOAD_21_002: [The constructor shall create a new instance of `HttpsTransportManager` with the provided `config`.] */
/* Tests_SRS_FILEUPLOAD_21_012: [The constructor shall create an pool of 10 threads to execute the uploads in parallel.] */
/* Tests_SRS_FILEUPLOAD_21_013: [The constructor shall create a list `fileUploadInProgressesSet` to control the pending uploads.] */
@Test
public void constructorSuccess(@Mocked final LinkedBlockingDeque<?> mockFileUploadInProgressQueue) throws IOException {
// arrange
new Expectations() {
{
new HttpsTransportManager(mockConfig);
result = mockHttpsTransportManager;
Executors.newScheduledThreadPool(10);
result = mockScheduler;
}
};
// act
final FileUpload fileUpload = new FileUpload(mockConfig);
// assert
new Verifications() {
{
new LinkedBlockingDeque<>();
times = 1;
}
};
assertNotNull(fileUpload);
}
Aggregations