Search in sources :

Example 1 with HttpProxySocketFactory

use of com.microsoft.azure.sdk.iot.device.transport.HttpProxySocketFactory in project azure-iot-sdk-java by Azure.

the class HttpsConnectionTest method setSSLContextSetsContextWithProxy.

@Test
public void setSSLContextSetsContextWithProxy(@Mocked final SSLContext mockedContext, @Mocked final SSLSocketFactory mockedSocketFactory, @Mocked final HttpProxySocketFactory mockedHttpProxySocketFactory) throws IOException, TransportException {
    final HttpsMethod httpsMethod = HttpsMethod.POST;
    new NonStrictExpectations() {

        {
            mockUrl.getProtocol();
            result = "https";
            mockUrl.openConnection();
            result = mockUrlConn;
            mockUrlConn.getRequestMethod();
            result = httpsMethod.name();
            mockedContext.getSocketFactory();
            result = mockedSocketFactory;
            new HttpProxySocketFactory(mockedSocketFactory, mockProxySettings);
            result = mockedHttpProxySocketFactory;
        }
    };
    final HttpsConnection conn = new HttpsConnection(mockUrl, httpsMethod, mockProxySettings);
    Deencapsulation.invoke(conn, "setSSLContext", mockedContext);
    new Verifications() {

        {
            mockUrlConn.setSSLSocketFactory(mockedHttpProxySocketFactory);
            times = 1;
        }
    };
}
Also used : HttpProxySocketFactory(com.microsoft.azure.sdk.iot.device.transport.HttpProxySocketFactory) HttpsConnection(com.microsoft.azure.sdk.iot.device.transport.https.HttpsConnection) HttpsMethod(com.microsoft.azure.sdk.iot.device.transport.https.HttpsMethod) Test(org.junit.Test)

Aggregations

HttpProxySocketFactory (com.microsoft.azure.sdk.iot.device.transport.HttpProxySocketFactory)1 HttpsConnection (com.microsoft.azure.sdk.iot.device.transport.https.HttpsConnection)1 HttpsMethod (com.microsoft.azure.sdk.iot.device.transport.https.HttpsMethod)1 Test (org.junit.Test)1