Search in sources :

Example 11 with FileUpload

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);
}
Also used : HttpsTransportManager(com.microsoft.azure.sdk.iot.device.transport.https.HttpsTransportManager) FileUpload(com.microsoft.azure.sdk.iot.device.fileupload.FileUpload) Test(org.junit.Test)

Example 12 with FileUpload

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);
}
Also used : HttpsTransportManager(com.microsoft.azure.sdk.iot.device.transport.https.HttpsTransportManager) FileUpload(com.microsoft.azure.sdk.iot.device.fileupload.FileUpload) Test(org.junit.Test)

Example 13 with FileUpload

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);
}
Also used : HashMap(java.util.HashMap) FileUpload(com.microsoft.azure.sdk.iot.device.fileupload.FileUpload) Test(org.junit.Test)

Example 14 with FileUpload

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;
        }
    };
}
Also used : HttpsTransportManager(com.microsoft.azure.sdk.iot.device.transport.https.HttpsTransportManager) IotHubEventCallback(com.microsoft.azure.sdk.iot.device.IotHubEventCallback) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) HashMap(java.util.HashMap) FileUpload(com.microsoft.azure.sdk.iot.device.fileupload.FileUpload) FileUploadStatusCallBack(com.microsoft.azure.sdk.iot.device.fileupload.FileUploadStatusCallBack) Test(org.junit.Test)

Aggregations

FileUpload (com.microsoft.azure.sdk.iot.device.fileupload.FileUpload)14 Test (org.junit.Test)14 HashMap (java.util.HashMap)10 HttpsTransportManager (com.microsoft.azure.sdk.iot.device.transport.https.HttpsTransportManager)5 LinkedBlockingDeque (java.util.concurrent.LinkedBlockingDeque)4 IotHubEventCallback (com.microsoft.azure.sdk.iot.device.IotHubEventCallback)3 FileUploadStatusCallBack (com.microsoft.azure.sdk.iot.device.fileupload.FileUploadStatusCallBack)3 FileUploadInProgress (com.microsoft.azure.sdk.iot.device.fileupload.FileUploadInProgress)1