Search in sources :

Example 6 with HttpClientConnectionManager

use of software.amazon.awssdk.crt.http.HttpClientConnectionManager in project aws-crt-java by awslabs.

the class ProxyTest method testConnectionManager_TunnelingHttpProxy_BasicAuth.

@Test
public void testConnectionManager_TunnelingHttpProxy_BasicAuth() {
    skipIfNetworkUnavailable();
    Assume.assumeTrue(isEnvironmentSetUpForProxyTests());
    try (HttpClientConnectionManager manager = buildProxiedConnectionManager(ProxyTestType.TUNNELING_HTTP, ProxyAuthType.Basic)) {
        doHttpConnectionManagerProxyTest(manager);
    }
}
Also used : HttpClientConnectionManager(software.amazon.awssdk.crt.http.HttpClientConnectionManager) Test(org.junit.Test)

Example 7 with HttpClientConnectionManager

use of software.amazon.awssdk.crt.http.HttpClientConnectionManager in project aws-crt-java by awslabs.

the class ProxyTest method testConnectionManager_LegacyHttpProxy_NoAuth.

@Test
public void testConnectionManager_LegacyHttpProxy_NoAuth() {
    skipIfNetworkUnavailable();
    Assume.assumeTrue(isEnvironmentSetUpForProxyTests());
    try (HttpClientConnectionManager manager = buildProxiedConnectionManager(ProxyTestType.LEGACY_HTTP, ProxyAuthType.None)) {
        doHttpConnectionManagerProxyTest(manager);
    }
}
Also used : HttpClientConnectionManager(software.amazon.awssdk.crt.http.HttpClientConnectionManager) Test(org.junit.Test)

Example 8 with HttpClientConnectionManager

use of software.amazon.awssdk.crt.http.HttpClientConnectionManager in project aws-crt-java by awslabs.

the class ProxyTest method testConnectionManager_ForwardingProxy_NoAuth.

@Test
public void testConnectionManager_ForwardingProxy_NoAuth() {
    skipIfNetworkUnavailable();
    Assume.assumeTrue(isEnvironmentSetUpForProxyTests());
    try (HttpClientConnectionManager manager = buildProxiedConnectionManager(ProxyTestType.FORWARDING, ProxyAuthType.None)) {
        doHttpConnectionManagerProxyTest(manager);
    }
}
Also used : HttpClientConnectionManager(software.amazon.awssdk.crt.http.HttpClientConnectionManager) Test(org.junit.Test)

Example 9 with HttpClientConnectionManager

use of software.amazon.awssdk.crt.http.HttpClientConnectionManager in project aws-crt-java by awslabs.

the class HttpClientConnectionManagerTest method testPendingAcquisitionsDuringShutdown.

@Test
public void testPendingAcquisitionsDuringShutdown() throws Exception {
    skipIfNetworkUnavailable();
    HttpClientConnection firstConnection = null;
    CompletableFuture<HttpClientConnection> firstAcquisition;
    CompletableFuture<HttpClientConnection> secondAcquisition;
    try (HttpClientConnectionManager connectionPool = createConnectionManager(new URI(endpoint), 1, 1)) {
        firstAcquisition = connectionPool.acquireConnection();
        secondAcquisition = connectionPool.acquireConnection();
        firstConnection = firstAcquisition.get();
    }
    firstConnection.close();
}
Also used : HttpClientConnection(software.amazon.awssdk.crt.http.HttpClientConnection) HttpClientConnectionManager(software.amazon.awssdk.crt.http.HttpClientConnectionManager) URI(java.net.URI) Test(org.junit.Test)

Example 10 with HttpClientConnectionManager

use of software.amazon.awssdk.crt.http.HttpClientConnectionManager in project aws-crt-java by awslabs.

the class HttpClientConnectionManagerTest method testCancelAcquire.

@Test
public void testCancelAcquire() throws Exception {
    // related: https://github.com/awslabs/aws-sdk-kotlin/issues/511
    skipIfNetworkUnavailable();
    try (HttpClientConnectionManager connectionPool = createConnectionManager(new URI(endpoint), 1, 1)) {
        CompletableFuture<HttpClientConnection> firstAcquisition = connectionPool.acquireConnection();
        CompletableFuture<HttpClientConnection> secondAcquisition = connectionPool.acquireConnection();
        CompletableFuture<HttpClientConnection> thirdAcquisition = connectionPool.acquireConnection();
        HttpClientConnection firstConnection = firstAcquisition.get();
        // cancel acquisition and abandon it
        secondAcquisition.cancel(false);
        // return the first conn to the pool, future acquisitions should succeed
        firstConnection.close();
        // should succeed, will timeout if the second acquisition doesn't return the unused/abandoned conn to the pool
        HttpClientConnection conn = thirdAcquisition.get(500, TimeUnit.MILLISECONDS);
        conn.close();
    }
}
Also used : HttpClientConnection(software.amazon.awssdk.crt.http.HttpClientConnection) HttpClientConnectionManager(software.amazon.awssdk.crt.http.HttpClientConnectionManager) URI(java.net.URI) Test(org.junit.Test)

Aggregations

HttpClientConnectionManager (software.amazon.awssdk.crt.http.HttpClientConnectionManager)20 Test (org.junit.Test)15 HttpClientConnection (software.amazon.awssdk.crt.http.HttpClientConnection)6 URI (java.net.URI)5 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 HttpClientConnectionManagerOptions (software.amazon.awssdk.crt.http.HttpClientConnectionManagerOptions)2 HttpRequest (software.amazon.awssdk.crt.http.HttpRequest)2 HttpStream (software.amazon.awssdk.crt.http.HttpStream)2 HttpStreamResponseHandler (software.amazon.awssdk.crt.http.HttpStreamResponseHandler)2 CompletableFuture (java.util.concurrent.CompletableFuture)1 HttpHeader (software.amazon.awssdk.crt.http.HttpHeader)1 ClientBootstrap (software.amazon.awssdk.crt.io.ClientBootstrap)1 SocketOptions (software.amazon.awssdk.crt.io.SocketOptions)1 TlsContext (software.amazon.awssdk.crt.io.TlsContext)1 TlsContextOptions (software.amazon.awssdk.crt.io.TlsContextOptions)1 CrtRequestContext (software.amazon.awssdk.http.crt.internal.CrtRequestContext)1 CrtRequestExecutor (software.amazon.awssdk.http.crt.internal.CrtRequestExecutor)1