Search in sources :

Example 31 with HttpsTransportManager

use of com.microsoft.azure.sdk.iot.device.transport.https.HttpsTransportManager 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 32 with HttpsTransportManager

use of com.microsoft.azure.sdk.iot.device.transport.https.HttpsTransportManager 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

HttpsTransportManager (com.microsoft.azure.sdk.iot.device.transport.https.HttpsTransportManager)32 Test (org.junit.Test)31 HttpsIotHubConnection (com.microsoft.azure.sdk.iot.device.transport.https.HttpsIotHubConnection)12 FileUpload (com.microsoft.azure.sdk.iot.device.fileupload.FileUpload)5 IOException (java.io.IOException)5 MethodResult (com.microsoft.azure.sdk.iot.device.edge.MethodResult)4 IotHubTransportMessage (com.microsoft.azure.sdk.iot.device.transport.IotHubTransportMessage)3 LinkedBlockingDeque (java.util.concurrent.LinkedBlockingDeque)3 HashMap (java.util.HashMap)2 IotHubEventCallback (com.microsoft.azure.sdk.iot.device.IotHubEventCallback)1 ModuleClientException (com.microsoft.azure.sdk.iot.device.exceptions.ModuleClientException)1 TransportException (com.microsoft.azure.sdk.iot.device.exceptions.TransportException)1 FileUploadInProgress (com.microsoft.azure.sdk.iot.device.fileupload.FileUploadInProgress)1 FileUploadStatusCallBack (com.microsoft.azure.sdk.iot.device.fileupload.FileUploadStatusCallBack)1 URISyntaxException (java.net.URISyntaxException)1