Search in sources :

Example 21 with FileUploadTask

use of com.microsoft.azure.sdk.iot.device.fileupload.FileUploadTask in project azure-iot-sdk-java by Azure.

the class FileUploadTaskTest method runCloseConnectionToIothubForRequestAndNotification.

/* Tests_SRS_FILEUPLOADTASK_21_012: [The run shall close the connection with the iothub, using the httpsTransportManager.] */
/* Tests_SRS_FILEUPLOADTASK_21_028: [The run shall close the connection with the iothub, using the httpsTransportManager.] */
@Test
public void runCloseConnectionToIothubForRequestAndNotification() throws IOException, IllegalArgumentException, URISyntaxException {
    // arrange
    expectSuccess(VALID_BLOB_NAME, VALID_CORRELATION_ID, VALID_HOST_NAME, VALID_CONTAINER_NAME, VALID_SAS_TOKEN, VALID_REQUEST_JSON, VALID_RESPONSE_JSON, VALID_NOTIFICATION_JSON);
    FileUploadTask fileUploadTask = Deencapsulation.newInstance(FileUploadTask.class, new Class[] { String.class, InputStream.class, long.class, HttpsTransportManager.class, IotHubEventCallback.class, Object.class }, VALID_BLOB_NAME, mockInputStream, VALID_STREAM_LENGTH, mockHttpsTransportManager, mockIotHubEventCallback, VALID_CALLBACK_CONTEXT);
    // act
    Deencapsulation.invoke(fileUploadTask, "run");
    // assert
    new Verifications() {

        {
            Deencapsulation.invoke(mockHttpsTransportManager, "close");
            times = 2;
        }
    };
}
Also used : FileUploadTask(com.microsoft.azure.sdk.iot.device.fileupload.FileUploadTask) Verifications(mockit.Verifications) Test(org.junit.Test)

Aggregations

FileUploadTask (com.microsoft.azure.sdk.iot.device.fileupload.FileUploadTask)21 Test (org.junit.Test)21 Verifications (mockit.Verifications)12 NonStrictExpectations (mockit.NonStrictExpectations)9 IOException (java.io.IOException)5 IotHubTransportMessage (com.microsoft.azure.sdk.iot.device.transport.IotHubTransportMessage)4 FileUploadCompletionNotification (com.microsoft.azure.sdk.iot.deps.serializer.FileUploadCompletionNotification)3 FileUploadSasUriRequest (com.microsoft.azure.sdk.iot.deps.serializer.FileUploadSasUriRequest)3 Expectations (mockit.Expectations)2 FileUploadSasUriResponse (com.microsoft.azure.sdk.iot.deps.serializer.FileUploadSasUriResponse)1 BadFormatException (com.microsoft.azure.sdk.iot.device.exceptions.BadFormatException)1 UnauthorizedException (com.microsoft.azure.sdk.iot.device.exceptions.UnauthorizedException)1