hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1479814 - in /httpcomponents/httpasyncclient/trunk/httpasyncclient/src: main/java/org/apache/http/impl/nio/client/ main/java/org/apache/http/impl/nio/conn/ main/java/org/apache/http/nio/conn/ main/java/org/apache/http/nio/conn/ssl/ test/ja...
Date Tue, 07 May 2013 08:49:55 GMT
Author: olegk
Date: Tue May  7 08:49:54 2013
New Revision: 1479814

URL: http://svn.apache.org/r1479814
Log:
Revised protocol scheme management and i/o session layering

Added:
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/PlainIOSessionFactory.java
      - copied, changed from r1479145, httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SchemeLayeringStrategy.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/SchemeIOSessionFactory.java   (contents, props changed)
      - copied, changed from r1479145, httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SchemeLayeringStrategy.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SSLIOSessionFactory.java   (with props)
Removed:
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SchemeLayeringStrategy.java
Modified:
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/PoolingNHttpClientConnectionManager.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/NHttpClientConnectionManager.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SSLLayeringStrategy.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/conn/TestPoolingHttpClientAsyncConnectionManager.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestClientAuthentication.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestClientAuthenticationFallBack.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestClientReauthentication.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpAsync.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpAsyncClientUtils.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpAsyncMinimal.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpAsyncPrematureTermination.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpsAsync.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpsRedirects.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestRedirects.java

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.java?rev=1479814&r1=1479813&r2=1479814&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.java Tue May  7 08:49:54 2013
@@ -91,8 +91,9 @@ import org.apache.http.impl.cookie.RFC29
 import org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager;
 import org.apache.http.impl.nio.reactor.IOReactorConfig;
 import org.apache.http.nio.conn.NHttpClientConnectionManager;
-import org.apache.http.nio.conn.ssl.SSLLayeringStrategy;
-import org.apache.http.nio.conn.ssl.SchemeLayeringStrategy;
+import org.apache.http.nio.conn.PlainIOSessionFactory;
+import org.apache.http.nio.conn.SchemeIOSessionFactory;
+import org.apache.http.nio.conn.ssl.SSLIOSessionFactory;
 import org.apache.http.nio.reactor.ConnectingIOReactor;
 import org.apache.http.protocol.HttpProcessor;
 import org.apache.http.protocol.HttpProcessorBuilder;
@@ -106,7 +107,7 @@ public class HttpAsyncClientBuilder {
 
     private NHttpClientConnectionManager connManager;
     private SchemePortResolver schemePortResolver;
-    private SchemeLayeringStrategy sslLayeringStrategy;
+    private SchemeIOSessionFactory iosessionFactory;
     private SSLContext sslcontext;
     private ConnectionReuseStrategy reuseStrategy;
     private ConnectionKeepAliveStrategy keepAliveStrategy;
@@ -293,9 +294,9 @@ public class HttpAsyncClientBuilder {
         return this;
     }
 
-    public final HttpAsyncClientBuilder setSSLLayeringStrategy(
-            final SchemeLayeringStrategy layeringStrategy) {
-        this.sslLayeringStrategy = layeringStrategy;
+    public final HttpAsyncClientBuilder setSSLIOSessionFactory(
+            final SchemeIOSessionFactory iosessionFactory) {
+        this.iosessionFactory = iosessionFactory;
         return this;
     }
 
@@ -337,8 +338,8 @@ public class HttpAsyncClientBuilder {
     public CloseableHttpAsyncClient build() {
         NHttpClientConnectionManager connManager = this.connManager;
         if (connManager == null) {
-            SchemeLayeringStrategy sslLayeringStrategy = this.sslLayeringStrategy;
-            if (sslLayeringStrategy == null) {
+            SchemeIOSessionFactory iosessionFactory = this.iosessionFactory;
+            if (iosessionFactory == null) {
                 SSLContext sslcontext = this.sslcontext;
                 if (sslcontext == null) {
                     if (systemProperties) {
@@ -347,14 +348,15 @@ public class HttpAsyncClientBuilder {
                         sslcontext = SSLContexts.createSystemDefault();
                     }
                 }
-                sslLayeringStrategy = new SSLLayeringStrategy(sslcontext);
+                iosessionFactory = new SSLIOSessionFactory(sslcontext);
             }
             final ConnectingIOReactor ioreactor = IOReactorUtils.create(
                 defaultIOReactorConfig != null ? defaultIOReactorConfig : IOReactorConfig.DEFAULT);
             final PoolingNHttpClientConnectionManager poolingmgr = new PoolingNHttpClientConnectionManager(
                     ioreactor,
-                    RegistryBuilder.<SchemeLayeringStrategy>create()
-                        .register("https", sslLayeringStrategy)
+                    RegistryBuilder.<SchemeIOSessionFactory>create()
+                        .register("http", PlainIOSessionFactory.INSTANCE)
+                        .register("https", iosessionFactory)
                         .build());
             if (defaultSocketConfig != null) {
                 poolingmgr.setDefaultSocketConfig(defaultSocketConfig);

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/PoolingNHttpClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/PoolingNHttpClientConnectionManager.java?rev=1479814&r1=1479813&r2=1479814&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/PoolingNHttpClientConnectionManager.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/PoolingNHttpClientConnectionManager.java Tue May  7 08:49:54 2013
@@ -30,7 +30,6 @@ import java.io.IOException;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.SocketAddress;
-import java.net.UnknownHostException;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.Future;
@@ -45,7 +44,6 @@ import org.apache.http.config.Connection
 import org.apache.http.config.Registry;
 import org.apache.http.config.RegistryBuilder;
 import org.apache.http.config.SocketConfig;
-import org.apache.http.conn.ConnectTimeoutException;
 import org.apache.http.conn.DnsResolver;
 import org.apache.http.conn.SchemePortResolver;
 import org.apache.http.conn.routing.HttpRoute;
@@ -55,15 +53,14 @@ import org.apache.http.nio.NHttpClientCo
 import org.apache.http.nio.conn.ManagedNHttpClientConnection;
 import org.apache.http.nio.conn.NHttpClientConnectionManager;
 import org.apache.http.nio.conn.NHttpConnectionFactory;
-import org.apache.http.nio.conn.ssl.SSLLayeringStrategy;
-import org.apache.http.nio.conn.ssl.SchemeLayeringStrategy;
+import org.apache.http.nio.conn.PlainIOSessionFactory;
+import org.apache.http.nio.conn.SchemeIOSessionFactory;
+import org.apache.http.nio.conn.ssl.SSLIOSessionFactory;
 import org.apache.http.nio.pool.NIOConnFactory;
 import org.apache.http.nio.pool.SocketAddressResolver;
 import org.apache.http.nio.reactor.ConnectingIOReactor;
 import org.apache.http.nio.reactor.IOEventDispatch;
 import org.apache.http.nio.reactor.IOSession;
-import org.apache.http.nio.reactor.SessionRequest;
-import org.apache.http.nio.reactor.SessionRequestCallback;
 import org.apache.http.pool.ConnPoolControl;
 import org.apache.http.pool.PoolStats;
 import org.apache.http.protocol.HttpContext;
@@ -78,13 +75,12 @@ public class PoolingNHttpClientConnectio
     private final ConnectingIOReactor ioreactor;
     private final ConfigData configData;
     private final CPool pool;
-    private final Registry<SchemeLayeringStrategy> layeringStrategyRegistry;
-    private final SchemePortResolver schemePortResolver;
-    private final DnsResolver dnsResolver;
-
-    private static Registry<SchemeLayeringStrategy> getDefaultRegistry() {
-        return RegistryBuilder.<SchemeLayeringStrategy>create()
-                .register("https", SSLLayeringStrategy.getDefaultStrategy())
+    private final Registry<SchemeIOSessionFactory> iosessionFactoryRegistry;
+
+    private static Registry<SchemeIOSessionFactory> getDefaultRegistry() {
+        return RegistryBuilder.<SchemeIOSessionFactory>create()
+                .register("http", PlainIOSessionFactory.INSTANCE)
+                .register("https", SSLIOSessionFactory.getDefaultStrategy())
                 .build();
     }
 
@@ -94,8 +90,8 @@ public class PoolingNHttpClientConnectio
 
     public PoolingNHttpClientConnectionManager(
             final ConnectingIOReactor ioreactor,
-            final Registry<SchemeLayeringStrategy> layeringStrategyRegistry) {
-        this(ioreactor, null, layeringStrategyRegistry, null);
+            final Registry<SchemeIOSessionFactory> iosessionFactoryRegistry) {
+        this(ioreactor, null, iosessionFactoryRegistry, null);
     }
 
     public PoolingNHttpClientConnectionManager(
@@ -114,46 +110,42 @@ public class PoolingNHttpClientConnectio
     public PoolingNHttpClientConnectionManager(
             final ConnectingIOReactor ioreactor,
             final NHttpConnectionFactory<ManagedNHttpClientConnection> connFactory,
-            final Registry<SchemeLayeringStrategy> layeringStrategyRegistry) {
-        this(ioreactor, connFactory, layeringStrategyRegistry, null);
+            final Registry<SchemeIOSessionFactory> iosessionFactoryRegistry) {
+        this(ioreactor, connFactory, iosessionFactoryRegistry, null);
     }
 
     public PoolingNHttpClientConnectionManager(
             final ConnectingIOReactor ioreactor,
             final NHttpConnectionFactory<ManagedNHttpClientConnection> connFactory,
-            final Registry<SchemeLayeringStrategy> layeringStrategyRegistry,
+            final Registry<SchemeIOSessionFactory> iosessionFactoryRegistry,
             final DnsResolver dnsResolver) {
-        this(ioreactor, connFactory, layeringStrategyRegistry, null, dnsResolver,
+        this(ioreactor, connFactory, iosessionFactoryRegistry, null, dnsResolver,
             -1, TimeUnit.MILLISECONDS);
     }
 
     public PoolingNHttpClientConnectionManager(
             final ConnectingIOReactor ioreactor,
             final NHttpConnectionFactory<ManagedNHttpClientConnection> connFactory,
-            final Registry<SchemeLayeringStrategy> layeringStrategyRegistry,
+            final Registry<SchemeIOSessionFactory> iosessionFactoryRegistry,
             final SchemePortResolver schemePortResolver,
             final DnsResolver dnsResolver,
             final long timeToLive, final TimeUnit tunit) {
         super();
         Args.notNull(ioreactor, "I/O reactor");
-        Args.notNull(layeringStrategyRegistry, "Layering strategy registry");
+        Args.notNull(iosessionFactoryRegistry, "Layering strategy registry");
         this.ioreactor = ioreactor;
         this.configData = new ConfigData();
         this.pool = new CPool(ioreactor,
             new InternalConnectionFactory(this.configData, connFactory),
             new InternalAddressResolver(schemePortResolver, dnsResolver),
             2, 20, timeToLive, tunit != null ? tunit : TimeUnit.MILLISECONDS);
-        this.layeringStrategyRegistry = layeringStrategyRegistry;
-        this.schemePortResolver = schemePortResolver != null ? schemePortResolver :
-            DefaultSchemePortResolver.INSTANCE;
-        this.dnsResolver = dnsResolver != null ? dnsResolver :
-            SystemDefaultDnsResolver.INSTANCE;
+        this.iosessionFactoryRegistry = iosessionFactoryRegistry;
     }
 
     PoolingNHttpClientConnectionManager(
             final ConnectingIOReactor ioreactor,
             final CPool pool,
-            final Registry<SchemeLayeringStrategy> layeringStrategyRegistry,
+            final Registry<SchemeIOSessionFactory> iosessionFactoryRegistry,
             final SchemePortResolver schemePortResolver,
             final DnsResolver dnsResolver,
             final long timeToLive, final TimeUnit tunit) {
@@ -161,11 +153,7 @@ public class PoolingNHttpClientConnectio
         this.ioreactor = ioreactor;
         this.configData = new ConfigData();
         this.pool = pool;
-        this.layeringStrategyRegistry = layeringStrategyRegistry;
-        this.schemePortResolver = schemePortResolver != null ? schemePortResolver :
-            DefaultSchemePortResolver.INSTANCE;
-        this.dnsResolver = dnsResolver != null ? dnsResolver :
-            SystemDefaultDnsResolver.INSTANCE;
+        this.iosessionFactoryRegistry = iosessionFactoryRegistry;
     }
 
     @Override
@@ -236,6 +224,18 @@ public class PoolingNHttpClientConnectio
             this.log.debug("Connection request: " + format(route, state) + formatStats(route));
         }
         final BasicFuture<NHttpClientConnection> future = new BasicFuture<NHttpClientConnection>(callback);
+        final HttpHost host;
+        if (route.getProxyHost() != null) {
+            host = route.getProxyHost();
+        } else {
+            host = route.getTargetHost();
+        }
+        final SchemeIOSessionFactory sf = this.iosessionFactoryRegistry.lookup(
+                host.getSchemeName());
+        if (sf == null) {
+            future.failed(new IOException("Unsupported scheme: " + host.getSchemeName()));
+            return future;
+        }
         this.pool.lease(route, state, connectTimeout,
                 tunit != null ? tunit : TimeUnit.MILLISECONDS,
                 new InternalPoolEntryCallback(future));
@@ -277,63 +277,6 @@ public class PoolingNHttpClientConnectio
         }
     }
 
-    public Future<NHttpClientConnection> connect(
-            final NHttpClientConnection managedConn,
-            final HttpRoute route,
-            final int connectTimeout,
-            final FutureCallback<NHttpClientConnection> callback) {
-        Args.notNull(managedConn, "Managed connection");
-        final BasicFuture<NHttpClientConnection> future = new BasicFuture<NHttpClientConnection>(callback);
-        if (managedConn.isOpen()) {
-            future.completed(managedConn);
-            return future;
-        }
-        final HttpHost host;
-        if (route.getProxyHost() != null) {
-            host = route.getProxyHost();
-        } else {
-            host = route.getTargetHost();
-        }
-        final InetSocketAddress localAddress = route.getLocalAddress() != null ?
-            new InetSocketAddress(route.getLocalAddress(), 0) : null;
-        final InetAddress[] addresses;
-        try {
-            addresses = this.dnsResolver.resolve(host.getHostName());
-        } catch (final UnknownHostException ex) {
-            future.failed(ex);
-            return future;
-        }
-        final int port = this.schemePortResolver.resolve(host);
-        final InetSocketAddress remoteAddress = new InetSocketAddress(addresses[0], port);
-        this.ioreactor.connect(remoteAddress, localAddress, null, new SessionRequestCallback() {
-
-            public void completed(final SessionRequest request) {
-                synchronized (managedConn) {
-                    final CPoolEntry entry = CPoolProxy.getPoolEntry(managedConn);
-                    final ManagedNHttpClientConnection conn = entry.getConnection();
-                    final IOSession iosession = request.getSession();
-                    iosession.setAttribute(IOEventDispatch.CONNECTION_KEY, conn);
-                    conn.bind(iosession);
-                }
-                future.completed(managedConn);
-            }
-
-            public void timeout(final SessionRequest request) {
-                future.failed(new ConnectTimeoutException(host, remoteAddress));
-            }
-
-            public void failed(final SessionRequest request) {
-                future.failed(request.getException());
-            }
-
-            public void cancelled(final SessionRequest request) {
-                future.cancel();
-            }
-
-        });
-        return future;
-    }
-
     public void initialize(
             final NHttpClientConnection managedConn,
             final HttpRoute route,
@@ -346,15 +289,16 @@ public class PoolingNHttpClientConnectio
         } else {
             host = route.getTargetHost();
         }
-        final SchemeLayeringStrategy layeringStrategy = layeringStrategyRegistry.lookup(
+        final SchemeIOSessionFactory sf = this.iosessionFactoryRegistry.lookup(
                 host.getSchemeName());
-        if (layeringStrategy != null) {
-            synchronized (managedConn) {
-                final CPoolEntry entry = CPoolProxy.getPoolEntry(managedConn);
-                final ManagedNHttpClientConnection conn = entry.getConnection();
-                final IOSession currentSession = layeringStrategy.layer(host, conn.getIOSession());
-                conn.bind(currentSession);
-            }
+        if (sf == null) {
+            throw new IOException("Unsupported scheme: " + host.getSchemeName());
+        }
+        synchronized (managedConn) {
+            final CPoolEntry entry = CPoolProxy.getPoolEntry(managedConn);
+            final ManagedNHttpClientConnection conn = entry.getConnection();
+            final IOSession currentSession = sf.create(host, conn.getIOSession());
+            conn.bind(currentSession);
         }
     }
 
@@ -365,13 +309,16 @@ public class PoolingNHttpClientConnectio
         Args.notNull(managedConn, "Managed connection");
         Args.notNull(route, "HTTP route");
         final HttpHost host  = route.getTargetHost();
-        final SchemeLayeringStrategy layeringStrategy = layeringStrategyRegistry.lookup(
+        final SchemeIOSessionFactory sf = this.iosessionFactoryRegistry.lookup(
             host.getSchemeName());
+        if (sf == null) {
+            throw new IOException("Unsupported scheme: " + host.getSchemeName());
+        }
         synchronized (managedConn) {
             final CPoolEntry entry = CPoolProxy.getPoolEntry(managedConn);
             final ManagedNHttpClientConnection conn = entry.getConnection();
-            Asserts.check(layeringStrategy != null, "Layering is not supported for this scheme");
-            final IOSession currentSession = layeringStrategy.layer(host, conn.getIOSession());
+            Asserts.check(sf.isLayering(), "Layering is not supported for this scheme");
+            final IOSession currentSession = sf.create(host, conn.getIOSession());
             conn.bind(currentSession);
         }
     }
@@ -398,8 +345,8 @@ public class PoolingNHttpClientConnectio
     }
 
     public void closeIdleConnections(final long idleTimeout, final TimeUnit tunit) {
-        if (log.isDebugEnabled()) {
-            log.debug("Closing connections idle longer than " + idleTimeout + " " + tunit);
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("Closing connections idle longer than " + idleTimeout + " " + tunit);
         }
         this.pool.closeIdle(idleTimeout, tunit);
     }
@@ -618,12 +565,8 @@ public class PoolingNHttpClientConnectio
                 host = route.getTargetHost();
             }
             final int port = this.schemePortResolver.resolve(host);
-            try {
-                final InetAddress[] addresses = this.dnsResolver.resolve(host.getHostName());
-                return new InetSocketAddress(addresses[0], port);
-            } catch (final UnknownHostException ex) {
-                return new InetSocketAddress(host.getHostName(), port);
-            }
+            final InetAddress[] addresses = this.dnsResolver.resolve(host.getHostName());
+            return new InetSocketAddress(addresses[0], port);
         }
 
     }

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/NHttpClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/NHttpClientConnectionManager.java?rev=1479814&r1=1479813&r2=1479814&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/NHttpClientConnectionManager.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/NHttpClientConnectionManager.java Tue May  7 08:49:54 2013
@@ -77,12 +77,6 @@ public interface NHttpClientConnectionMa
     void releaseConnection(
             NHttpClientConnection conn, Object newState, long validDuration, TimeUnit timeUnit);
 
-    Future<NHttpClientConnection> connect(
-            NHttpClientConnection conn,
-            HttpRoute route,
-            int connectTimeout,
-            FutureCallback<NHttpClientConnection> callback);
-
     void initialize(
             NHttpClientConnection conn,
             HttpRoute route,

Copied: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/PlainIOSessionFactory.java (from r1479145, httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SchemeLayeringStrategy.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/PlainIOSessionFactory.java?p2=httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/PlainIOSessionFactory.java&p1=httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SchemeLayeringStrategy.java&r1=1479145&r2=1479814&rev=1479814&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SchemeLayeringStrategy.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/PlainIOSessionFactory.java Tue May  7 08:49:54 2013
@@ -24,13 +24,21 @@
  * <http://www.apache.org/>.
  *
  */
-package org.apache.http.nio.conn.ssl;
+package org.apache.http.nio.conn;
 
 import org.apache.http.HttpHost;
 import org.apache.http.nio.reactor.IOSession;
 
-public interface SchemeLayeringStrategy {
+public class PlainIOSessionFactory implements SchemeIOSessionFactory {
 
-    IOSession layer(HttpHost host, IOSession iosession);
+    public static final PlainIOSessionFactory INSTANCE = new PlainIOSessionFactory();
+
+    public IOSession create(final HttpHost host, final IOSession iosession) {
+        return iosession;
+    }
+
+    public boolean isLayering() {
+        return false;
+    }
 
 }

Copied: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/SchemeIOSessionFactory.java (from r1479145, httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SchemeLayeringStrategy.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/SchemeIOSessionFactory.java?p2=httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/SchemeIOSessionFactory.java&p1=httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SchemeLayeringStrategy.java&r1=1479145&r2=1479814&rev=1479814&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SchemeLayeringStrategy.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/SchemeIOSessionFactory.java Tue May  7 08:49:54 2013
@@ -24,13 +24,15 @@
  * <http://www.apache.org/>.
  *
  */
-package org.apache.http.nio.conn.ssl;
+package org.apache.http.nio.conn;
 
 import org.apache.http.HttpHost;
 import org.apache.http.nio.reactor.IOSession;
 
-public interface SchemeLayeringStrategy {
+public interface SchemeIOSessionFactory {
 
-    IOSession layer(HttpHost host, IOSession iosession);
+    IOSession create(HttpHost host, IOSession iosession);
+
+    boolean isLayering();
 
 }

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/SchemeIOSessionFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/SchemeIOSessionFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/SchemeIOSessionFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SSLIOSessionFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SSLIOSessionFactory.java?rev=1479814&view=auto
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SSLIOSessionFactory.java (added)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SSLIOSessionFactory.java Tue May  7 08:49:54 2013
@@ -0,0 +1,111 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.nio.conn.ssl;
+
+import java.security.cert.Certificate;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLEngine;
+import javax.net.ssl.SSLException;
+import javax.net.ssl.SSLSession;
+
+import org.apache.http.HttpHost;
+import org.apache.http.conn.ssl.BrowserCompatHostnameVerifier;
+import org.apache.http.conn.ssl.SSLContexts;
+import org.apache.http.conn.ssl.X509HostnameVerifier;
+import org.apache.http.nio.conn.SchemeIOSessionFactory;
+import org.apache.http.nio.reactor.IOSession;
+import org.apache.http.nio.reactor.ssl.SSLIOSession;
+import org.apache.http.nio.reactor.ssl.SSLMode;
+import org.apache.http.nio.reactor.ssl.SSLSetupHandler;
+
+public class SSLIOSessionFactory implements SchemeIOSessionFactory {
+
+    public static SSLIOSessionFactory getDefaultStrategy() {
+        return new SSLIOSessionFactory(SSLContexts.createDefault());
+    }
+
+    public static SSLIOSessionFactory getSystemDefaultStrategy() {
+        return new SSLIOSessionFactory(SSLContexts.createSystemDefault());
+    }
+
+    private final SSLContext sslContext;
+    private final X509HostnameVerifier hostnameVerifier;
+
+    public SSLIOSessionFactory(
+            final SSLContext sslContext, final X509HostnameVerifier hostnameVerifier) {
+        super();
+        this.sslContext = sslContext;
+        this.hostnameVerifier = hostnameVerifier;
+    }
+
+    public SSLIOSessionFactory(final SSLContext sslcontext) {
+        this(sslcontext, new BrowserCompatHostnameVerifier());
+    }
+
+    public SSLIOSession create(final HttpHost host, final IOSession iosession) {
+        final SSLIOSession ssliosession = new SSLIOSession(
+            iosession,
+            SSLMode.CLIENT,
+            this.sslContext,
+            new SSLSetupHandler() {
+
+                public void initalize(
+                        final SSLEngine sslengine) throws SSLException {
+                    initializeEngine(sslengine);
+                }
+
+                public void verify(
+                        final IOSession iosession,
+                        final SSLSession sslsession) throws SSLException {
+                    verifySession(host, iosession, sslsession);
+                }
+
+        });
+        iosession.setAttribute(SSLIOSession.SESSION_KEY, ssliosession);
+        return ssliosession;
+    }
+
+    protected void initializeEngine(final SSLEngine engine) {
+    }
+
+    protected void verifySession(
+            final HttpHost host,
+            final IOSession iosession,
+            final SSLSession sslsession) throws SSLException {
+        final Certificate[] certs = sslsession.getPeerCertificates();
+        final X509Certificate x509 = (X509Certificate) certs[0];
+        this.hostnameVerifier.verify(host.getHostName(), x509);
+    }
+
+    public boolean isLayering() {
+        return false;
+    }
+
+}

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SSLIOSessionFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SSLIOSessionFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SSLIOSessionFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SSLLayeringStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SSLLayeringStrategy.java?rev=1479814&r1=1479813&r2=1479814&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SSLLayeringStrategy.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SSLLayeringStrategy.java Tue May  7 08:49:54 2013
@@ -47,7 +47,6 @@ import javax.net.ssl.TrustManager;
 import javax.net.ssl.TrustManagerFactory;
 import javax.net.ssl.X509TrustManager;
 
-import org.apache.http.HttpHost;
 import org.apache.http.conn.ssl.BrowserCompatHostnameVerifier;
 import org.apache.http.conn.ssl.SSLContexts;
 import org.apache.http.conn.ssl.TrustStrategy;
@@ -58,8 +57,8 @@ import org.apache.http.nio.reactor.ssl.S
 import org.apache.http.nio.reactor.ssl.SSLMode;
 import org.apache.http.nio.reactor.ssl.SSLSetupHandler;
 
-@SuppressWarnings("deprecation")
-public class SSLLayeringStrategy implements LayeringStrategy, SchemeLayeringStrategy {
+@Deprecated
+public class SSLLayeringStrategy implements LayeringStrategy {
 
     public static final String TLS   = "TLS";
     public static final String SSL   = "SSL";
@@ -183,7 +182,6 @@ public class SSLLayeringStrategy impleme
         return true;
     }
 
-    @Deprecated
     public SSLIOSession layer(final IOSession iosession) {
         final SSLIOSession ssliosession = new SSLIOSession(
             iosession,
@@ -207,33 +205,9 @@ public class SSLLayeringStrategy impleme
         return ssliosession;
     }
 
-    public SSLIOSession layer(final HttpHost host, final IOSession iosession) {
-        final SSLIOSession ssliosession = new SSLIOSession(
-            iosession,
-            SSLMode.CLIENT,
-            this.sslContext,
-            new SSLSetupHandler() {
-
-                public void initalize(
-                        final SSLEngine sslengine) throws SSLException {
-                    initializeEngine(sslengine);
-                }
-
-                public void verify(
-                        final IOSession iosession,
-                        final SSLSession sslsession) throws SSLException {
-                    verifySession(host, iosession, sslsession);
-                }
-
-        });
-        iosession.setAttribute(SSLIOSession.SESSION_KEY, ssliosession);
-        return ssliosession;
-    }
-
     protected void initializeEngine(final SSLEngine engine) {
     }
 
-    @Deprecated
     protected void verifySession(
             final IOSession iosession,
             final SSLSession sslsession) throws SSLException {
@@ -241,16 +215,7 @@ public class SSLLayeringStrategy impleme
 
         final Certificate[] certs = sslsession.getPeerCertificates();
         final X509Certificate x509 = (X509Certificate) certs[0];
-        hostnameVerifier.verify(address.getHostName(), x509);
-    }
-
-    protected void verifySession(
-            final HttpHost host,
-            final IOSession iosession,
-            final SSLSession sslsession) throws SSLException {
-        final Certificate[] certs = sslsession.getPeerCertificates();
-        final X509Certificate x509 = (X509Certificate) certs[0];
-        hostnameVerifier.verify(host.getHostName(), x509);
+        this.hostnameVerifier.verify(address.getHostName(), x509);
     }
 
 }

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/conn/TestPoolingHttpClientAsyncConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/conn/TestPoolingHttpClientAsyncConnectionManager.java?rev=1479814&r1=1479813&r2=1479814&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/conn/TestPoolingHttpClientAsyncConnectionManager.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/conn/TestPoolingHttpClientAsyncConnectionManager.java Tue May  7 08:49:54 2013
@@ -26,12 +26,9 @@
  */
 package org.apache.http.impl.nio.conn;
 
-import java.io.IOException;
 import java.lang.reflect.Proxy;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.net.UnknownHostException;
 import java.util.Calendar;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
@@ -45,7 +42,6 @@ import org.apache.http.concurrent.Future
 import org.apache.http.config.ConnectionConfig;
 import org.apache.http.config.Registry;
 import org.apache.http.config.RegistryBuilder;
-import org.apache.http.conn.ConnectTimeoutException;
 import org.apache.http.conn.DnsResolver;
 import org.apache.http.conn.SchemePortResolver;
 import org.apache.http.conn.routing.HttpRoute;
@@ -55,9 +51,8 @@ import org.apache.http.impl.nio.conn.Poo
 import org.apache.http.nio.NHttpClientConnection;
 import org.apache.http.nio.conn.ManagedNHttpClientConnection;
 import org.apache.http.nio.conn.NHttpConnectionFactory;
-import org.apache.http.nio.conn.ssl.SchemeLayeringStrategy;
+import org.apache.http.nio.conn.SchemeIOSessionFactory;
 import org.apache.http.nio.reactor.ConnectingIOReactor;
-import org.apache.http.nio.reactor.IOEventDispatch;
 import org.apache.http.nio.reactor.IOSession;
 import org.apache.http.nio.reactor.SessionRequest;
 import org.apache.http.nio.reactor.SessionRequestCallback;
@@ -78,7 +73,9 @@ public class TestPoolingHttpClientAsyncC
     @Mock
     private CPool pool;
     @Mock
-    private SchemeLayeringStrategy layeringStrategy;
+    private SchemeIOSessionFactory plainFactory;
+    @Mock
+    private SchemeIOSessionFactory sslFactory;
     @Mock
     private SchemePortResolver schemePortResolver;
     @Mock
@@ -98,14 +95,18 @@ public class TestPoolingHttpClientAsyncC
     @Mock
     private IOSession iosession;
 
-    private Registry<SchemeLayeringStrategy> layeringStrategyRegistry;
+    private Registry<SchemeIOSessionFactory> layeringStrategyRegistry;
     private PoolingNHttpClientConnectionManager connman;
 
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
-        layeringStrategyRegistry = RegistryBuilder.<SchemeLayeringStrategy>create()
-            .register("https", layeringStrategy).build();
+        Mockito.when(sslFactory.isLayering()).thenReturn(Boolean.TRUE);
+
+        layeringStrategyRegistry = RegistryBuilder.<SchemeIOSessionFactory>create()
+            .register("http", plainFactory)
+            .register("https", sslFactory)
+            .build();
         connman = new PoolingNHttpClientConnectionManager(
             ioreactor, pool, layeringStrategyRegistry,
             schemePortResolver, dnsResolver, 10, TimeUnit.SECONDS);
@@ -259,181 +260,6 @@ public class TestPoolingHttpClientAsyncC
     }
 
     @Test
-    public void testConnect() throws Exception {
-        final InetAddress la1 = InetAddress.getByAddress(new byte[] {127,0,0,1});
-        final InetAddress ra1 = InetAddress.getByAddress(new byte[] {10,0,0,1});
-        final InetAddress ra2 = InetAddress.getByAddress(new byte[] {10,0,0,2});
-        final HttpHost target = new HttpHost("somehost", -1, "https");
-        final HttpRoute route = new HttpRoute(target, la1, true);
-
-        Mockito.when(dnsResolver.resolve("somehost")).thenReturn(new InetAddress[] {ra1, ra2});
-        Mockito.when(schemePortResolver.resolve(target)).thenReturn(8443);
-
-        final Log log = Mockito.mock(Log.class);
-        final CPoolEntry poolentry = new CPoolEntry(log, "some-id", route, conn, -1, TimeUnit.MILLISECONDS);
-        poolentry.markRouteComplete();
-        final NHttpClientConnection managedConn = CPoolProxy.newProxy(poolentry);
-        final Future<NHttpClientConnection> future = connman.connect(
-            managedConn, route, 1000, connCallback);
-        Assert.assertNotNull(future);
-
-        Mockito.verify(ioreactor).connect(
-            Mockito.eq(new InetSocketAddress(ra1, 8443)),
-            Mockito.eq(new InetSocketAddress(la1, 0)),
-            Mockito.isNull(),
-            sessionRequestCallbackCaptor.capture());
-
-        Mockito.when(sessionRequest.getSession()).thenReturn(iosession);
-        Mockito.when(layeringStrategy.layer(target, iosession)).thenReturn(iosession);
-
-        final SessionRequestCallback callback = sessionRequestCallbackCaptor.getValue();
-        callback.completed(sessionRequest);
-        Mockito.verify(connCallback).completed(Mockito.<NHttpClientConnection>any());
-        Mockito.verify(iosession).setAttribute(IOEventDispatch.CONNECTION_KEY, conn);
-        Mockito.verify(conn).bind(iosession);
-    }
-
-    @Test
-    public void testConnectAlreadyConnected() throws Exception {
-        final HttpHost target = new HttpHost("somehost", -1, "https");
-        final HttpRoute route = new HttpRoute(target);
-
-        final Log log = Mockito.mock(Log.class);
-        final CPoolEntry poolentry = new CPoolEntry(log, "some-id", route, conn, -1, TimeUnit.MILLISECONDS);
-        poolentry.markRouteComplete();
-        final NHttpClientConnection managedConn = CPoolProxy.newProxy(poolentry);
-
-        Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE);
-
-        final Future<NHttpClientConnection> future = connman.connect(
-            managedConn, route, 1000, connCallback);
-        Assert.assertNotNull(future);
-        Assert.assertTrue(future.isDone());
-
-        Mockito.verify(ioreactor, Mockito.never()).connect(
-            Mockito.<InetSocketAddress>any(),
-            Mockito.<InetSocketAddress>any(),
-            Mockito.any(),
-            Mockito.<SessionRequestCallback>any());
-    }
-
-    @Test
-    public void testConnectUnknownHost() throws Exception {
-        final HttpHost target = new HttpHost("pampa", -1, "https");
-        final HttpRoute route = new HttpRoute(target);
-
-        final Log log = Mockito.mock(Log.class);
-        final CPoolEntry poolentry = new CPoolEntry(log, "some-id", route, conn, -1, TimeUnit.MILLISECONDS);
-        poolentry.markRouteComplete();
-        final NHttpClientConnection managedConn = CPoolProxy.newProxy(poolentry);
-
-        Mockito.when(dnsResolver.resolve("pampa")).thenThrow(new UnknownHostException());
-
-        final Future<NHttpClientConnection> future = connman.connect(
-            managedConn, route, 1000, connCallback);
-        Assert.assertNotNull(future);
-        Assert.assertTrue(future.isDone());
-
-        Mockito.verify(ioreactor, Mockito.never()).connect(
-            Mockito.<InetSocketAddress>any(),
-            Mockito.<InetSocketAddress>any(),
-            Mockito.any(),
-            Mockito.<SessionRequestCallback>any());
-
-        try {
-            future.get();
-        } catch (final ExecutionException ex) {
-            Assert.assertTrue(ex.getCause() instanceof UnknownHostException);
-        }
-    }
-
-    @Test
-    public void testConnectFailure() throws Exception {
-        final InetAddress ra1 = InetAddress.getByAddress(new byte[] {10,0,0,1});
-        final HttpHost target = new HttpHost("somehost", -1, "https");
-        final HttpRoute route = new HttpRoute(target);
-
-        Mockito.when(dnsResolver.resolve("somehost")).thenReturn(new InetAddress[] {ra1});
-        Mockito.when(schemePortResolver.resolve(target)).thenReturn(8443);
-
-        final Log log = Mockito.mock(Log.class);
-        final CPoolEntry poolentry = new CPoolEntry(log, "some-id", route, conn, -1, TimeUnit.MILLISECONDS);
-        poolentry.markRouteComplete();
-        final NHttpClientConnection managedConn = CPoolProxy.newProxy(poolentry);
-        final Future<NHttpClientConnection> future = connman.connect(
-            managedConn, route, 1000, connCallback);
-        Assert.assertNotNull(future);
-
-        Mockito.verify(ioreactor).connect(
-            Mockito.eq(new InetSocketAddress(ra1, 8443)),
-            (SocketAddress) Mockito.isNull(),
-            Mockito.isNull(),
-            sessionRequestCallbackCaptor.capture());
-
-        Mockito.when(sessionRequest.getException()).thenReturn(new IOException());
-
-        final SessionRequestCallback callback = sessionRequestCallbackCaptor.getValue();
-        callback.failed(sessionRequest);
-        Mockito.verify(connCallback).failed(Mockito.<IOException>any());
-    }
-
-    @Test
-    public void testConnectTimeout() throws Exception {
-        final InetAddress ra1 = InetAddress.getByAddress(new byte[] {10,0,0,1});
-        final HttpHost target = new HttpHost("somehost", -1, "https");
-        final HttpRoute route = new HttpRoute(target);
-
-        Mockito.when(dnsResolver.resolve("somehost")).thenReturn(new InetAddress[] {ra1});
-        Mockito.when(schemePortResolver.resolve(target)).thenReturn(8443);
-
-        final Log log = Mockito.mock(Log.class);
-        final CPoolEntry poolentry = new CPoolEntry(log, "some-id", route, conn, -1, TimeUnit.MILLISECONDS);
-        poolentry.markRouteComplete();
-        final NHttpClientConnection managedConn = CPoolProxy.newProxy(poolentry);
-        final Future<NHttpClientConnection> future = connman.connect(
-            managedConn, route, 1000, connCallback);
-        Assert.assertNotNull(future);
-
-        Mockito.verify(ioreactor).connect(
-            Mockito.eq(new InetSocketAddress(ra1, 8443)),
-            (SocketAddress) Mockito.isNull(),
-            Mockito.isNull(),
-            sessionRequestCallbackCaptor.capture());
-
-        final SessionRequestCallback callback = sessionRequestCallbackCaptor.getValue();
-        callback.timeout(sessionRequest);
-        Mockito.verify(connCallback).failed(Mockito.<ConnectTimeoutException>any());
-    }
-
-    @Test
-    public void testConnectCancelled() throws Exception {
-        final InetAddress ra1 = InetAddress.getByAddress(new byte[] {10,0,0,1});
-        final HttpHost target = new HttpHost("somehost", -1, "https");
-        final HttpRoute route = new HttpRoute(target);
-
-        Mockito.when(dnsResolver.resolve("somehost")).thenReturn(new InetAddress[] {ra1});
-        Mockito.when(schemePortResolver.resolve(target)).thenReturn(8443);
-
-        final Log log = Mockito.mock(Log.class);
-        final CPoolEntry poolentry = new CPoolEntry(log, "some-id", route, conn, -1, TimeUnit.MILLISECONDS);
-        poolentry.markRouteComplete();
-        final NHttpClientConnection managedConn = CPoolProxy.newProxy(poolentry);
-        final Future<NHttpClientConnection> future = connman.connect(
-            managedConn, route, 1000, connCallback);
-        Assert.assertNotNull(future);
-
-        Mockito.verify(ioreactor).connect(
-            Mockito.eq(new InetSocketAddress(ra1, 8443)),
-            (SocketAddress) Mockito.isNull(),
-            Mockito.isNull(),
-            sessionRequestCallbackCaptor.capture());
-
-        final SessionRequestCallback callback = sessionRequestCallbackCaptor.getValue();
-        callback.cancelled(sessionRequest);
-        Mockito.verify(connCallback).cancelled();
-    }
-
-    @Test
     public void testConnectionInitialize() throws Exception {
         final HttpHost target = new HttpHost("somehost", -1, "http");
         final HttpRoute route = new HttpRoute(target);
@@ -444,11 +270,11 @@ public class TestPoolingHttpClientAsyncC
         final NHttpClientConnection managedConn = CPoolProxy.newProxy(poolentry);
 
         Mockito.when(conn.getIOSession()).thenReturn(iosession);
-        Mockito.when(layeringStrategy.layer(target, iosession)).thenReturn(iosession);
+        Mockito.when(sslFactory.create(target, iosession)).thenReturn(iosession);
 
         connman.initialize(managedConn, route, context);
 
-        Mockito.verify(layeringStrategy, Mockito.never()).layer(target, iosession);
+        Mockito.verify(plainFactory).create(target, iosession);
         Mockito.verify(conn, Mockito.never()).bind(iosession);
 
         Assert.assertFalse(connman.isRouteComplete(managedConn));
@@ -466,11 +292,11 @@ public class TestPoolingHttpClientAsyncC
         final NHttpClientConnection managedConn = CPoolProxy.newProxy(poolentry);
 
         Mockito.when(conn.getIOSession()).thenReturn(iosession);
-        Mockito.when(layeringStrategy.layer(target, iosession)).thenReturn(iosession);
+        Mockito.when(sslFactory.create(target, iosession)).thenReturn(iosession);
 
         connman.initialize(managedConn, route, context);
 
-        Mockito.verify(layeringStrategy).layer(target, iosession);
+        Mockito.verify(sslFactory).create(target, iosession);
         Mockito.verify(conn).bind(iosession);
     }
 
@@ -486,11 +312,11 @@ public class TestPoolingHttpClientAsyncC
         final NHttpClientConnection managedConn = CPoolProxy.newProxy(poolentry);
 
         Mockito.when(conn.getIOSession()).thenReturn(iosession);
-        Mockito.when(layeringStrategy.layer(target, iosession)).thenReturn(iosession);
+        Mockito.when(sslFactory.create(target, iosession)).thenReturn(iosession);
 
         connman.upgrade(managedConn, route, context);
 
-        Mockito.verify(layeringStrategy).layer(target, iosession);
+        Mockito.verify(sslFactory).create(target, iosession);
         Mockito.verify(conn).bind(iosession);
     }
 
@@ -506,7 +332,7 @@ public class TestPoolingHttpClientAsyncC
         final NHttpClientConnection managedConn = CPoolProxy.newProxy(poolentry);
 
         Mockito.when(conn.getIOSession()).thenReturn(iosession);
-        Mockito.when(layeringStrategy.layer(target, iosession)).thenReturn(iosession);
+        Mockito.when(sslFactory.create(target, iosession)).thenReturn(iosession);
 
         connman.upgrade(managedConn, route, context);
     }
@@ -523,7 +349,7 @@ public class TestPoolingHttpClientAsyncC
         final NHttpClientConnection managedConn = CPoolProxy.newProxy(poolentry);
 
         Mockito.when(conn.getIOSession()).thenReturn(iosession);
-        Mockito.when(layeringStrategy.layer(target, iosession)).thenReturn(iosession);
+        Mockito.when(sslFactory.create(target, iosession)).thenReturn(iosession);
 
         connman.initialize(managedConn, route, context);
         connman.routeComplete(managedConn, route, context);
@@ -574,7 +400,7 @@ public class TestPoolingHttpClientAsyncC
         final HttpRoute route = new HttpRoute(new HttpHost("somehost"));
         internalConnFactory.create(route, iosession);
 
-        Mockito.verify(layeringStrategy, Mockito.never()).layer(
+        Mockito.verify(sslFactory, Mockito.never()).create(
             Mockito.eq(new HttpHost("somehost")), Mockito.<IOSession>any());
         Mockito.verify(connFactory).create(Mockito.same(iosession), Mockito.<ConnectionConfig>any());
     }

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestClientAuthentication.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestClientAuthentication.java?rev=1479814&r1=1479813&r2=1479814&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestClientAuthentication.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestClientAuthentication.java Tue May  7 08:49:54 2013
@@ -137,8 +137,8 @@ public class TestClientAuthentication ex
             final HttpAsyncExpectationVerifier expectationVerifier) throws Exception {
         final HttpAsyncService serviceHandler = new HttpAsyncService(
                 this.serverHttpProc,
-                new DefaultConnectionReuseStrategy(),
-                new DefaultHttpResponseFactory(),
+                DefaultConnectionReuseStrategy.INSTANCE,
+                DefaultHttpResponseFactory.INSTANCE,
                 requestHandlerResolver,
                 expectationVerifier);
         this.server.start(serviceHandler);

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestClientAuthenticationFallBack.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestClientAuthenticationFallBack.java?rev=1479814&r1=1479813&r2=1479814&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestClientAuthenticationFallBack.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestClientAuthenticationFallBack.java Tue May  7 08:49:54 2013
@@ -122,8 +122,8 @@ public class TestClientAuthenticationFal
             final HttpAsyncExpectationVerifier expectationVerifier) throws Exception {
         final HttpAsyncService serviceHandler = new HttpAsyncService(
                 this.serverHttpProc,
-                new DefaultConnectionReuseStrategy(),
-                new DefaultHttpResponseFactory(),
+                DefaultConnectionReuseStrategy.INSTANCE,
+                DefaultHttpResponseFactory.INSTANCE,
                 requestHandlerResolver,
                 expectationVerifier);
         this.server.start(serviceHandler);

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestClientReauthentication.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestClientReauthentication.java?rev=1479814&r1=1479813&r2=1479814&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestClientReauthentication.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestClientReauthentication.java Tue May  7 08:49:54 2013
@@ -133,8 +133,8 @@ public class TestClientReauthentication 
             final HttpAsyncExpectationVerifier expectationVerifier) throws Exception {
         final HttpAsyncService serviceHandler = new HttpAsyncService(
                 this.serverHttpProc,
-                new DefaultConnectionReuseStrategy(),
-                new DefaultHttpResponseFactory(),
+                DefaultConnectionReuseStrategy.INSTANCE,
+                DefaultHttpResponseFactory.INSTANCE,
                 requestHandlerResolver,
                 expectationVerifier);
         this.server.start(serviceHandler);

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpAsync.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpAsync.java?rev=1479814&r1=1479813&r2=1479814&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpAsync.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpAsync.java Tue May  7 08:49:54 2013
@@ -101,8 +101,8 @@ public class TestHttpAsync extends HttpA
             final HttpAsyncExpectationVerifier expectationVerifier) throws Exception {
         final HttpAsyncService serviceHandler = new HttpAsyncService(
                 this.serverHttpProc,
-                new DefaultConnectionReuseStrategy(),
-                new DefaultHttpResponseFactory(),
+                DefaultConnectionReuseStrategy.INSTANCE,
+                DefaultHttpResponseFactory.INSTANCE,
                 requestHandlerResolver,
                 expectationVerifier);
         this.server.start(serviceHandler);

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpAsyncClientUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpAsyncClientUtils.java?rev=1479814&r1=1479813&r2=1479814&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpAsyncClientUtils.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpAsyncClientUtils.java Tue May  7 08:49:54 2013
@@ -105,8 +105,8 @@ public class TestHttpAsyncClientUtils ex
             final HttpAsyncExpectationVerifier expectationVerifier) throws Exception {
         final HttpAsyncService serviceHandler = new HttpAsyncService(
                 this.serverHttpProc,
-                new DefaultConnectionReuseStrategy(),
-                new DefaultHttpResponseFactory(),
+                DefaultConnectionReuseStrategy.INSTANCE,
+                DefaultHttpResponseFactory.INSTANCE,
                 requestHandlerResolver,
                 expectationVerifier);
 

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpAsyncMinimal.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpAsyncMinimal.java?rev=1479814&r1=1479813&r2=1479814&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpAsyncMinimal.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpAsyncMinimal.java Tue May  7 08:49:54 2013
@@ -92,8 +92,8 @@ public class TestHttpAsyncMinimal extend
             final HttpAsyncExpectationVerifier expectationVerifier) throws Exception {
         final HttpAsyncService serviceHandler = new HttpAsyncService(
                 this.serverHttpProc,
-                new DefaultConnectionReuseStrategy(),
-                new DefaultHttpResponseFactory(),
+                DefaultConnectionReuseStrategy.INSTANCE,
+                DefaultHttpResponseFactory.INSTANCE,
                 requestHandlerResolver,
                 expectationVerifier);
         this.server.start(serviceHandler);

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpAsyncPrematureTermination.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpAsyncPrematureTermination.java?rev=1479814&r1=1479813&r2=1479814&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpAsyncPrematureTermination.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpAsyncPrematureTermination.java Tue May  7 08:49:54 2013
@@ -98,8 +98,8 @@ public class TestHttpAsyncPrematureTermi
             final HttpAsyncExpectationVerifier expectationVerifier) throws Exception {
         final HttpAsyncService serviceHandler = new HttpAsyncService(
                 this.serverHttpProc,
-                new DefaultConnectionReuseStrategy(),
-                new DefaultHttpResponseFactory(),
+                DefaultConnectionReuseStrategy.INSTANCE,
+                DefaultHttpResponseFactory.INSTANCE,
                 requestHandlerResolver,
                 expectationVerifier);
 

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpsAsync.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpsAsync.java?rev=1479814&r1=1479813&r2=1479814&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpsAsync.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpsAsync.java Tue May  7 08:49:54 2013
@@ -35,8 +35,9 @@ import org.apache.http.impl.nio.SSLNHttp
 import org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager;
 import org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor;
 import org.apache.http.nio.NHttpConnectionFactory;
-import org.apache.http.nio.conn.ssl.SSLLayeringStrategy;
-import org.apache.http.nio.conn.ssl.SchemeLayeringStrategy;
+import org.apache.http.nio.conn.PlainIOSessionFactory;
+import org.apache.http.nio.conn.SchemeIOSessionFactory;
+import org.apache.http.nio.conn.ssl.SSLIOSessionFactory;
 
 public class TestHttpsAsync extends TestHttpAsync {
 
@@ -53,9 +54,10 @@ public class TestHttpsAsync extends Test
 
     @Override
     public void initConnectionManager() throws Exception {
-        final Registry<SchemeLayeringStrategy> schemereg = RegistryBuilder.<SchemeLayeringStrategy>create()
-            .register("https", new SSLLayeringStrategy(SSLTestContexts.createClientSSLContext()))
-            .build();
+        final Registry<SchemeIOSessionFactory> schemereg = RegistryBuilder.<SchemeIOSessionFactory>create()
+                .register("http", PlainIOSessionFactory.INSTANCE)
+                .register("https", new SSLIOSessionFactory(SSLTestContexts.createClientSSLContext()))
+                .build();
         this.clientIOReactor = new DefaultConnectingIOReactor(this.clientReactorConfig);
         this.connMgr = new PoolingNHttpClientConnectionManager(this.clientIOReactor, schemereg);
     }

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpsRedirects.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpsRedirects.java?rev=1479814&r1=1479813&r2=1479814&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpsRedirects.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestHttpsRedirects.java Tue May  7 08:49:54 2013
@@ -35,8 +35,9 @@ import org.apache.http.impl.nio.SSLNHttp
 import org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager;
 import org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor;
 import org.apache.http.nio.NHttpConnectionFactory;
-import org.apache.http.nio.conn.ssl.SSLLayeringStrategy;
-import org.apache.http.nio.conn.ssl.SchemeLayeringStrategy;
+import org.apache.http.nio.conn.PlainIOSessionFactory;
+import org.apache.http.nio.conn.SchemeIOSessionFactory;
+import org.apache.http.nio.conn.ssl.SSLIOSessionFactory;
 
 public class TestHttpsRedirects extends TestRedirects {
 
@@ -53,9 +54,10 @@ public class TestHttpsRedirects extends 
 
     @Override
     public void initConnectionManager() throws Exception {
-        final Registry<SchemeLayeringStrategy> schemereg = RegistryBuilder.<SchemeLayeringStrategy>create()
-            .register("https", new SSLLayeringStrategy(SSLTestContexts.createClientSSLContext()))
-            .build();
+        final Registry<SchemeIOSessionFactory> schemereg = RegistryBuilder.<SchemeIOSessionFactory>create()
+                .register("http", PlainIOSessionFactory.INSTANCE)
+                .register("https", new SSLIOSessionFactory(SSLTestContexts.createClientSSLContext()))
+                .build();
         this.clientIOReactor = new DefaultConnectingIOReactor(this.clientReactorConfig);
         this.connMgr = new PoolingNHttpClientConnectionManager(this.clientIOReactor, schemereg);
     }

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestRedirects.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestRedirects.java?rev=1479814&r1=1479813&r2=1479814&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestRedirects.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestRedirects.java Tue May  7 08:49:54 2013
@@ -29,7 +29,6 @@ package org.apache.http.nio.client.integ
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.net.URISyntaxException;
-import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Queue;
@@ -122,8 +121,8 @@ public class TestRedirects extends HttpA
             final HttpAsyncExpectationVerifier expectationVerifier) throws Exception {
         final HttpAsyncService serviceHandler = new HttpAsyncService(
                 this.serverHttpProc,
-                new DefaultConnectionReuseStrategy(),
-                new DefaultHttpResponseFactory(),
+                DefaultConnectionReuseStrategy.INSTANCE,
+                DefaultHttpResponseFactory.INSTANCE,
                 requestHandlerResolver,
                 expectationVerifier);
         this.server.start(serviceHandler);
@@ -648,7 +647,7 @@ public class TestRedirects extends HttpA
             final Future<HttpResponse> future = this.httpclient.execute(target, httpget, null);
             future.get();
         } catch (final ExecutionException e) {
-            Assert.assertTrue(e.getCause() instanceof UnknownHostException);
+            Assert.assertTrue(e.getCause() instanceof IOException);
             throw e;
         }
     }



Mime
View raw message