hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1463728 [2/2] - in /httpcomponents/httpasyncclient/trunk: ./ httpasyncclient/src/main/java/org/apache/http/impl/nio/client/ httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/ httpasyncclient/src/test/java/org/apache/http/ httpasy...
Date Tue, 02 Apr 2013 20:10:36 GMT
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=1463728&r1=1463727&r2=1463728&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 Apr  2 20:10:35 2013
@@ -28,7 +28,7 @@ package org.apache.http.nio.client.integ
 
 import java.io.IOException;
 import java.net.InetSocketAddress;
-import java.util.Collections;
+import java.util.Arrays;
 import java.util.concurrent.Future;
 import java.util.concurrent.atomic.AtomicLong;
 
@@ -44,12 +44,16 @@ import org.apache.http.HttpResponseInter
 import org.apache.http.HttpStatus;
 import org.apache.http.auth.AUTH;
 import org.apache.http.auth.AuthScheme;
+import org.apache.http.auth.AuthSchemeProvider;
 import org.apache.http.auth.AuthScope;
 import org.apache.http.auth.Credentials;
 import org.apache.http.auth.UsernamePasswordCredentials;
 import org.apache.http.client.CredentialsProvider;
+import org.apache.http.client.config.RequestConfig;
 import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.params.AllClientPNames;
+import org.apache.http.config.ConnectionConfig;
+import org.apache.http.config.Registry;
+import org.apache.http.config.RegistryBuilder;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.DefaultHttpResponseFactory;
@@ -58,16 +62,16 @@ import org.apache.http.impl.auth.BasicSc
 import org.apache.http.impl.client.TargetAuthenticationStrategy;
 import org.apache.http.impl.nio.DefaultNHttpServerConnection;
 import org.apache.http.impl.nio.DefaultNHttpServerConnectionFactory;
+import org.apache.http.impl.nio.client.HttpAsyncClients;
 import org.apache.http.localserver.RequestBasicAuth;
 import org.apache.http.nio.NHttpConnectionFactory;
 import org.apache.http.nio.protocol.BasicAsyncRequestHandler;
 import org.apache.http.nio.protocol.HttpAsyncExpectationVerifier;
-import org.apache.http.nio.protocol.HttpAsyncRequestHandlerRegistry;
-import org.apache.http.nio.protocol.HttpAsyncRequestHandlerResolver;
+import org.apache.http.nio.protocol.HttpAsyncRequestHandlerMapper;
 import org.apache.http.nio.protocol.HttpAsyncService;
+import org.apache.http.nio.protocol.UriHttpAsyncRequestHandlerMapper;
 import org.apache.http.nio.reactor.IOReactorStatus;
 import org.apache.http.nio.reactor.ListenerEndpoint;
-import org.apache.http.params.HttpParams;
 import org.apache.http.protocol.BasicHttpContext;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpRequestHandler;
@@ -87,7 +91,7 @@ public class TestClientReauthentication 
     @Before
     public void setUp() throws Exception {
         initServer();
-        initClient();
+        initConnectionManager();
     }
 
     @After
@@ -115,8 +119,8 @@ public class TestClientReauthentication 
 
     @Override
     protected NHttpConnectionFactory<DefaultNHttpServerConnection> createServerConnectionFactory(
-            final HttpParams params) throws Exception {
-        return new DefaultNHttpServerConnectionFactory(params);
+            final ConnectionConfig config) throws Exception {
+        return new DefaultNHttpServerConnectionFactory(config);
     }
 
     @Override
@@ -125,15 +129,14 @@ public class TestClientReauthentication 
     }
 
     private HttpHost start(
-            final HttpAsyncRequestHandlerResolver requestHandlerResolver,
+            final HttpAsyncRequestHandlerMapper requestHandlerResolver,
             final HttpAsyncExpectationVerifier expectationVerifier) throws Exception {
         final HttpAsyncService serviceHandler = new HttpAsyncService(
                 this.serverHttpProc,
                 new DefaultConnectionReuseStrategy(),
                 new DefaultHttpResponseFactory(),
                 requestHandlerResolver,
-                expectationVerifier,
-                this.serverParams);
+                expectationVerifier);
         this.server.start(serviceHandler);
         this.httpclient.start();
 
@@ -212,17 +215,13 @@ public class TestClientReauthentication 
 
     @Test
     public void testBasicAuthenticationSuccess() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("*", new BasicAsyncRequestHandler(new AuthHandler()));
-        final HttpHost target = start(registry, null);
-
-        final TestCredentialsProvider credsProvider = new TestCredentialsProvider(
-                new UsernamePasswordCredentials("test", "test"));
 
         final BasicSchemeFactory myBasicAuthSchemeFactory = new BasicSchemeFactory() {
 
             @Override
-            public AuthScheme newInstance(final HttpParams params) {
+            public AuthScheme create(final HttpContext context) {
                 return new BasicScheme() {
 
                     @Override
@@ -244,15 +243,27 @@ public class TestClientReauthentication 
 
         };
 
-        this.httpclient.setTargetAuthenticationStrategy(myAuthStrategy);
-        this.httpclient.getAuthSchemes().register("MyBasic", myBasicAuthSchemeFactory);
-        this.httpclient.setCredentialsProvider(credsProvider);
+        final TestCredentialsProvider credsProvider = new TestCredentialsProvider(
+                new UsernamePasswordCredentials("test", "test"));
+
+        final RequestConfig config = RequestConfig.custom()
+            .setTargetPreferredAuthSchemes(Arrays.asList("MyBasic"))
+            .build();
+        final Registry<AuthSchemeProvider> authSchemeRegistry = RegistryBuilder.<AuthSchemeProvider>create()
+            .register("MyBasic", myBasicAuthSchemeFactory)
+            .build();
+        this.httpclient = HttpAsyncClients.custom()
+            .setDefaultAuthSchemeRegistry(authSchemeRegistry)
+            .setTargetAuthenticationStrategy(myAuthStrategy)
+            .setDefaultCredentialsProvider(credsProvider)
+            .build();
+
+        final HttpHost target = start(registry, null);
 
         final HttpContext context = new BasicHttpContext();
         for (int i = 0; i < 10; i++) {
             final HttpGet httpget = new HttpGet("/");
-            httpget.getParams().setParameter(AllClientPNames.TARGET_AUTH_PREF,
-                    Collections.singletonList("MyBasic"));
+            httpget.setConfig(config);
             final Future<HttpResponse> future = this.httpclient.execute(target, httpget, context, null);
             final HttpResponse response = future.get();
             Assert.assertNotNull(response);

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=1463728&r1=1463727&r2=1463728&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 Apr  2 20:10:35 2013
@@ -40,10 +40,12 @@ import org.apache.http.HttpHost;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
+import org.apache.http.config.ConnectionConfig;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.DefaultHttpResponseFactory;
 import org.apache.http.impl.nio.DefaultNHttpServerConnection;
 import org.apache.http.impl.nio.DefaultNHttpServerConnectionFactory;
+import org.apache.http.impl.nio.client.HttpAsyncClients;
 import org.apache.http.localserver.EchoHandler;
 import org.apache.http.localserver.RandomHandler;
 import org.apache.http.nio.ContentDecoder;
@@ -54,13 +56,12 @@ import org.apache.http.nio.entity.NByteA
 import org.apache.http.nio.protocol.BasicAsyncRequestHandler;
 import org.apache.http.nio.protocol.BasicAsyncResponseConsumer;
 import org.apache.http.nio.protocol.HttpAsyncExpectationVerifier;
-import org.apache.http.nio.protocol.HttpAsyncRequestHandlerRegistry;
-import org.apache.http.nio.protocol.HttpAsyncRequestHandlerResolver;
+import org.apache.http.nio.protocol.HttpAsyncRequestHandlerMapper;
 import org.apache.http.nio.protocol.HttpAsyncRequestProducer;
 import org.apache.http.nio.protocol.HttpAsyncService;
+import org.apache.http.nio.protocol.UriHttpAsyncRequestHandlerMapper;
 import org.apache.http.nio.reactor.IOReactorStatus;
 import org.apache.http.nio.reactor.ListenerEndpoint;
-import org.apache.http.params.HttpParams;
 import org.apache.http.util.EntityUtils;
 import org.junit.After;
 import org.junit.Assert;
@@ -72,7 +73,10 @@ public class TestHttpAsync extends HttpA
     @Before
     public void setUp() throws Exception {
         initServer();
-        initClient();
+        initConnectionManager();
+        this.httpclient = HttpAsyncClients.custom()
+            .setConnectionManager(this.connMgr)
+            .build();
     }
 
     @After
@@ -83,8 +87,8 @@ public class TestHttpAsync extends HttpA
 
     @Override
     protected NHttpConnectionFactory<DefaultNHttpServerConnection> createServerConnectionFactory(
-            final HttpParams params) throws Exception {
-        return new DefaultNHttpServerConnectionFactory(params);
+            final ConnectionConfig config) throws Exception {
+        return new DefaultNHttpServerConnectionFactory(config);
     }
 
     @Override
@@ -93,15 +97,14 @@ public class TestHttpAsync extends HttpA
     }
 
     private HttpHost start(
-            final HttpAsyncRequestHandlerResolver requestHandlerResolver,
+            final HttpAsyncRequestHandlerMapper requestHandlerResolver,
             final HttpAsyncExpectationVerifier expectationVerifier) throws Exception {
         final HttpAsyncService serviceHandler = new HttpAsyncService(
                 this.serverHttpProc,
                 new DefaultConnectionReuseStrategy(),
                 new DefaultHttpResponseFactory(),
                 requestHandlerResolver,
-                expectationVerifier,
-                this.serverParams);
+                expectationVerifier);
         this.server.start(serviceHandler);
         this.httpclient.start();
 
@@ -115,7 +118,7 @@ public class TestHttpAsync extends HttpA
     }
 
     private HttpHost start() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("/echo/*", new BasicAsyncRequestHandler(new EchoHandler()));
         registry.register("/random/*", new BasicAsyncRequestHandler(new RandomHandler()));
         return start(registry, null);

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=1463728&r1=1463727&r2=1463728&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 Apr  2 20:10:35 2013
@@ -33,22 +33,23 @@ import org.apache.http.HttpAsyncTestBase
 import org.apache.http.HttpHost;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.methods.HttpGet;
+import org.apache.http.config.ConnectionConfig;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.DefaultHttpResponseFactory;
 import org.apache.http.impl.nio.DefaultNHttpServerConnection;
 import org.apache.http.impl.nio.DefaultNHttpServerConnectionFactory;
+import org.apache.http.impl.nio.client.HttpAsyncClients;
 import org.apache.http.localserver.EchoHandler;
 import org.apache.http.localserver.RandomHandler;
 import org.apache.http.nio.NHttpConnectionFactory;
 import org.apache.http.nio.client.util.HttpAsyncClientUtils;
 import org.apache.http.nio.protocol.BasicAsyncRequestHandler;
 import org.apache.http.nio.protocol.HttpAsyncExpectationVerifier;
-import org.apache.http.nio.protocol.HttpAsyncRequestHandlerRegistry;
-import org.apache.http.nio.protocol.HttpAsyncRequestHandlerResolver;
+import org.apache.http.nio.protocol.HttpAsyncRequestHandlerMapper;
 import org.apache.http.nio.protocol.HttpAsyncService;
+import org.apache.http.nio.protocol.UriHttpAsyncRequestHandlerMapper;
 import org.apache.http.nio.reactor.IOReactorStatus;
 import org.apache.http.nio.reactor.ListenerEndpoint;
-import org.apache.http.params.HttpParams;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -59,7 +60,7 @@ public class TestHttpAsyncClientUtils ex
     @Before
     public void setUp() throws Exception {
         initServer();
-        initClient();
+        initConnectionManager();
     }
 
     @After
@@ -70,8 +71,8 @@ public class TestHttpAsyncClientUtils ex
 
     @Override
     protected NHttpConnectionFactory<DefaultNHttpServerConnection> createServerConnectionFactory(
-            final HttpParams params) throws Exception {
-        return new DefaultNHttpServerConnectionFactory(params);
+            final ConnectionConfig config) throws Exception {
+        return new DefaultNHttpServerConnectionFactory(config);
     }
 
     @Override
@@ -94,20 +95,25 @@ public class TestHttpAsyncClientUtils ex
     }
 
     private HttpHost start() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("/echo/*", new BasicAsyncRequestHandler(new EchoHandler()));
         registry.register("/random/*", new BasicAsyncRequestHandler(new RandomHandler()));
         return start(registry, null);
     }
 
-    private HttpHost start(final HttpAsyncRequestHandlerResolver requestHandlerResolver,
+    private HttpHost start(final HttpAsyncRequestHandlerMapper requestHandlerResolver,
             final HttpAsyncExpectationVerifier expectationVerifier) throws Exception {
         final HttpAsyncService serviceHandler = new HttpAsyncService(
                 this.serverHttpProc,
                 new DefaultConnectionReuseStrategy(),
                 new DefaultHttpResponseFactory(),
-                requestHandlerResolver, expectationVerifier,
-                this.serverParams);
+                requestHandlerResolver,
+                expectationVerifier);
+
+        this.httpclient = HttpAsyncClients.custom()
+                .setConnectionManager(this.connMgr)
+                .build();
+
         this.server.start(serviceHandler);
         this.httpclient.start();
 

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=1463728&r1=1463727&r2=1463728&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 Apr  2 20:10:35 2013
@@ -39,11 +39,13 @@ import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.concurrent.FutureCallback;
+import org.apache.http.config.ConnectionConfig;
 import org.apache.http.entity.ContentType;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.DefaultHttpResponseFactory;
 import org.apache.http.impl.nio.DefaultNHttpServerConnection;
 import org.apache.http.impl.nio.DefaultNHttpServerConnectionFactory;
+import org.apache.http.impl.nio.client.HttpAsyncClients;
 import org.apache.http.nio.ContentEncoder;
 import org.apache.http.nio.IOControl;
 import org.apache.http.nio.NHttpConnectionFactory;
@@ -54,14 +56,13 @@ import org.apache.http.nio.protocol.Http
 import org.apache.http.nio.protocol.HttpAsyncExpectationVerifier;
 import org.apache.http.nio.protocol.HttpAsyncRequestConsumer;
 import org.apache.http.nio.protocol.HttpAsyncRequestHandler;
-import org.apache.http.nio.protocol.HttpAsyncRequestHandlerRegistry;
-import org.apache.http.nio.protocol.HttpAsyncRequestHandlerResolver;
+import org.apache.http.nio.protocol.HttpAsyncRequestHandlerMapper;
 import org.apache.http.nio.protocol.HttpAsyncService;
+import org.apache.http.nio.protocol.UriHttpAsyncRequestHandlerMapper;
 import org.apache.http.nio.reactor.IOReactorStatus;
 import org.apache.http.nio.reactor.ListenerEndpoint;
-import org.apache.http.params.HttpParams;
-import org.apache.http.protocol.ExecutionContext;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.HttpCoreContext;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -72,7 +73,7 @@ public class TestHttpAsyncPrematureTermi
     @Before
     public void setUp() throws Exception {
         initServer();
-        initClient();
+        initConnectionManager();
     }
 
     @After
@@ -83,8 +84,8 @@ public class TestHttpAsyncPrematureTermi
 
     @Override
     protected NHttpConnectionFactory<DefaultNHttpServerConnection> createServerConnectionFactory(
-            final HttpParams params) throws Exception {
-        return new DefaultNHttpServerConnectionFactory(params);
+            final ConnectionConfig config) throws Exception {
+        return new DefaultNHttpServerConnectionFactory(config);
     }
 
     @Override
@@ -93,15 +94,19 @@ public class TestHttpAsyncPrematureTermi
     }
 
     private HttpHost start(
-            final HttpAsyncRequestHandlerResolver requestHandlerResolver,
+            final HttpAsyncRequestHandlerMapper requestHandlerResolver,
             final HttpAsyncExpectationVerifier expectationVerifier) throws Exception {
         final HttpAsyncService serviceHandler = new HttpAsyncService(
                 this.serverHttpProc,
                 new DefaultConnectionReuseStrategy(),
                 new DefaultHttpResponseFactory(),
                 requestHandlerResolver,
-                expectationVerifier,
-                this.serverParams);
+                expectationVerifier);
+
+        this.httpclient = HttpAsyncClients.custom()
+                .setConnectionManager(this.connMgr)
+                .build();
+
         this.server.start(serviceHandler);
         this.httpclient.start();
 
@@ -116,14 +121,14 @@ public class TestHttpAsyncPrematureTermi
 
     @Test
     public void testConnectionTerminatedProcessingRequest() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("*", new HttpAsyncRequestHandler<HttpRequest>() {
 
             public HttpAsyncRequestConsumer<HttpRequest> processRequest(
                     final HttpRequest request,
                     final HttpContext context) throws HttpException, IOException {
                 final HttpConnection conn = (HttpConnection) context.getAttribute(
-                        ExecutionContext.HTTP_CONNECTION);
+                        HttpCoreContext.HTTP_CONNECTION);
                 conn.shutdown();
                 return new BasicAsyncRequestConsumer();
             }
@@ -138,6 +143,11 @@ public class TestHttpAsyncPrematureTermi
             }
 
         });
+
+        this.httpclient = HttpAsyncClients.custom()
+                .setConnectionManager(this.connMgr)
+                .build();
+
         final HttpHost target = start(registry, null);
         final HttpGet httpget = new HttpGet("/");
 
@@ -165,7 +175,7 @@ public class TestHttpAsyncPrematureTermi
 
     @Test
     public void testConnectionTerminatedHandlingRequest() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("*", new HttpAsyncRequestHandler<HttpRequest>() {
 
             public HttpAsyncRequestConsumer<HttpRequest> processRequest(
@@ -179,7 +189,7 @@ public class TestHttpAsyncPrematureTermi
                     final HttpAsyncExchange httpExchange,
                     final HttpContext context) throws HttpException, IOException {
                 final HttpConnection conn = (HttpConnection) context.getAttribute(
-                        ExecutionContext.HTTP_CONNECTION);
+                        HttpCoreContext.HTTP_CONNECTION);
                 conn.shutdown();
                 final HttpResponse response = httpExchange.getResponse();
                 response.setEntity(new NStringEntity("all is well", ContentType.TEXT_PLAIN));
@@ -187,6 +197,11 @@ public class TestHttpAsyncPrematureTermi
             }
 
         });
+
+        this.httpclient = HttpAsyncClients.custom()
+                .setConnectionManager(this.connMgr)
+                .build();
+
         final HttpHost target = start(registry, null);
         final HttpGet httpget = new HttpGet("/");
 
@@ -214,7 +229,7 @@ public class TestHttpAsyncPrematureTermi
 
     @Test
     public void testConnectionTerminatedSendingResponse() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("*", new HttpAsyncRequestHandler<HttpRequest>() {
 
             public HttpAsyncRequestConsumer<HttpRequest> processRequest(
@@ -242,6 +257,11 @@ public class TestHttpAsyncPrematureTermi
             }
 
         });
+
+        this.httpclient = HttpAsyncClients.custom()
+                .setConnectionManager(this.connMgr)
+                .build();
+
         final HttpHost target = start(registry, null);
         final HttpGet httpget = new HttpGet("/");
 

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=1463728&r1=1463727&r2=1463728&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 Apr  2 20:10:35 2013
@@ -27,19 +27,23 @@
 package org.apache.http.nio.client.integration;
 
 import org.apache.http.SSLTestContexts;
+import org.apache.http.config.ConnectionConfig;
+import org.apache.http.config.Registry;
+import org.apache.http.config.RegistryBuilder;
 import org.apache.http.impl.nio.DefaultNHttpServerConnection;
 import org.apache.http.impl.nio.SSLNHttpServerConnectionFactory;
+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.scheme.AsyncScheme;
 import org.apache.http.nio.conn.ssl.SSLLayeringStrategy;
-import org.apache.http.params.HttpParams;
+import org.apache.http.nio.conn.ssl.SchemeLayeringStrategy;
 
 public class TestHttpsAsync extends TestHttpAsync {
 
     @Override
     protected NHttpConnectionFactory<DefaultNHttpServerConnection> createServerConnectionFactory(
-            final HttpParams params) throws Exception {
-        return new SSLNHttpServerConnectionFactory(SSLTestContexts.createServerSSLContext(), null, params);
+            final ConnectionConfig config) throws Exception {
+        return new SSLNHttpServerConnectionFactory(SSLTestContexts.createServerSSLContext(), null, config);
     }
 
     @Override
@@ -48,10 +52,12 @@ public class TestHttpsAsync extends Test
     }
 
     @Override
-    public void initClient() throws Exception {
-        super.initClient();
-        this.connMgr.getSchemeRegistry().register(new AsyncScheme("https", 443,
-                new SSLLayeringStrategy(SSLTestContexts.createClientSSLContext())));
+    public void initConnectionManager() throws Exception {
+        final Registry<SchemeLayeringStrategy> schemereg = RegistryBuilder.<SchemeLayeringStrategy>create()
+            .register("https", new SSLLayeringStrategy(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=1463728&r1=1463727&r2=1463728&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 Apr  2 20:10:35 2013
@@ -27,19 +27,23 @@
 package org.apache.http.nio.client.integration;
 
 import org.apache.http.SSLTestContexts;
+import org.apache.http.config.ConnectionConfig;
+import org.apache.http.config.Registry;
+import org.apache.http.config.RegistryBuilder;
 import org.apache.http.impl.nio.DefaultNHttpServerConnection;
 import org.apache.http.impl.nio.SSLNHttpServerConnectionFactory;
+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.scheme.AsyncScheme;
 import org.apache.http.nio.conn.ssl.SSLLayeringStrategy;
-import org.apache.http.params.HttpParams;
+import org.apache.http.nio.conn.ssl.SchemeLayeringStrategy;
 
 public class TestHttpsRedirects extends TestRedirects {
 
     @Override
     protected NHttpConnectionFactory<DefaultNHttpServerConnection> createServerConnectionFactory(
-            final HttpParams params) throws Exception {
-        return new SSLNHttpServerConnectionFactory(SSLTestContexts.createServerSSLContext(), null, params);
+            final ConnectionConfig config) throws Exception {
+        return new SSLNHttpServerConnectionFactory(SSLTestContexts.createServerSSLContext(), null, config);
     }
 
     @Override
@@ -48,10 +52,12 @@ public class TestHttpsRedirects extends 
     }
 
     @Override
-    public void initClient() throws Exception {
-        super.initClient();
-        this.connMgr.getSchemeRegistry().register(new AsyncScheme("https", 443,
-                new SSLLayeringStrategy(SSLTestContexts.createClientSSLContext())));
+    public void initConnectionManager() throws Exception {
+        final Registry<SchemeLayeringStrategy> schemereg = RegistryBuilder.<SchemeLayeringStrategy>create()
+            .register("https", new SSLLayeringStrategy(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=1463728&r1=1463727&r2=1463728&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 Apr  2 20:10:35 2013
@@ -29,6 +29,7 @@ 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;
@@ -49,10 +50,12 @@ import org.apache.http.ProtocolVersion;
 import org.apache.http.client.CircularRedirectException;
 import org.apache.http.client.CookieStore;
 import org.apache.http.client.RedirectException;
+import org.apache.http.client.config.RequestConfig;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.params.ClientPNames;
+import org.apache.http.client.protocol.HttpClientContext;
 import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.config.ConnectionConfig;
 import org.apache.http.cookie.SM;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
@@ -61,6 +64,7 @@ import org.apache.http.impl.client.Basic
 import org.apache.http.impl.cookie.BasicClientCookie;
 import org.apache.http.impl.nio.DefaultNHttpServerConnection;
 import org.apache.http.impl.nio.DefaultNHttpServerConnectionFactory;
+import org.apache.http.impl.nio.client.HttpAsyncClients;
 import org.apache.http.localserver.HttpServerNio;
 import org.apache.http.localserver.RandomHandler;
 import org.apache.http.message.BasicHeader;
@@ -68,16 +72,14 @@ import org.apache.http.nio.NHttpConnecti
 import org.apache.http.nio.entity.NStringEntity;
 import org.apache.http.nio.protocol.BasicAsyncRequestHandler;
 import org.apache.http.nio.protocol.HttpAsyncExpectationVerifier;
-import org.apache.http.nio.protocol.HttpAsyncRequestHandlerRegistry;
-import org.apache.http.nio.protocol.HttpAsyncRequestHandlerResolver;
+import org.apache.http.nio.protocol.HttpAsyncRequestHandlerMapper;
 import org.apache.http.nio.protocol.HttpAsyncService;
+import org.apache.http.nio.protocol.UriHttpAsyncRequestHandlerMapper;
 import org.apache.http.nio.reactor.IOReactorStatus;
 import org.apache.http.nio.reactor.ListenerEndpoint;
-import org.apache.http.params.HttpParams;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.ExecutionContext;
 import org.apache.http.protocol.HTTP;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.HttpCoreContext;
 import org.apache.http.protocol.HttpRequestHandler;
 import org.junit.After;
 import org.junit.Assert;
@@ -92,7 +94,10 @@ public class TestRedirects extends HttpA
     @Before
     public void setUp() throws Exception {
         initServer();
-        initClient();
+        initConnectionManager();
+        this.httpclient = HttpAsyncClients.custom()
+                .setConnectionManager(this.connMgr)
+                .build();
     }
 
     @After
@@ -103,8 +108,8 @@ public class TestRedirects extends HttpA
 
     @Override
     protected NHttpConnectionFactory<DefaultNHttpServerConnection> createServerConnectionFactory(
-            final HttpParams params) throws Exception {
-        return new DefaultNHttpServerConnectionFactory(params);
+            final ConnectionConfig config) throws Exception {
+        return new DefaultNHttpServerConnectionFactory(config);
     }
 
     @Override
@@ -113,15 +118,14 @@ public class TestRedirects extends HttpA
     }
 
     private HttpHost start(
-            final HttpAsyncRequestHandlerResolver requestHandlerResolver,
+            final HttpAsyncRequestHandlerMapper requestHandlerResolver,
             final HttpAsyncExpectationVerifier expectationVerifier) throws Exception {
         final HttpAsyncService serviceHandler = new HttpAsyncService(
                 this.serverHttpProc,
                 new DefaultConnectionReuseStrategy(),
                 new DefaultHttpResponseFactory(),
                 requestHandlerResolver,
-                expectationVerifier,
-                this.serverParams);
+                expectationVerifier);
         this.server.start(serviceHandler);
         this.httpclient.start();
 
@@ -150,7 +154,7 @@ public class TestRedirects extends HttpA
                 final HttpResponse response,
                 final HttpContext context) throws HttpException, IOException {
             final HttpInetConnection conn = (HttpInetConnection) context.getAttribute(
-                    ExecutionContext.HTTP_CONNECTION);
+                    HttpCoreContext.HTTP_CONNECTION);
             final ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
             final String uri = request.getRequestLine().getUri();
             if (uri.equals("/oldlocation/")) {
@@ -260,7 +264,7 @@ public class TestRedirects extends HttpA
                 final HttpResponse response,
                 final HttpContext context) throws HttpException, IOException {
             final HttpInetConnection conn = (HttpInetConnection) context.getAttribute(
-                    ExecutionContext.HTTP_CONNECTION);
+                    HttpCoreContext.HTTP_CONNECTION);
             String redirectUrl = this.url;
             if (!this.absolute) {
                 redirectUrl = this.schemeName + "://localhost:" + conn.getLocalPort() + redirectUrl;
@@ -283,12 +287,12 @@ public class TestRedirects extends HttpA
 
     @Test
     public void testBasicRedirect300() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("*", new BasicAsyncRequestHandler(
                 new BasicRedirectService(getSchemeName(), HttpStatus.SC_MULTIPLE_CHOICES)));
         final HttpHost target = start(registry, null);
 
-        final HttpContext context = new BasicHttpContext();
+        final HttpClientContext context = HttpClientContext.create();
 
         final HttpGet httpget = new HttpGet("/oldlocation/");
 
@@ -296,8 +300,7 @@ public class TestRedirects extends HttpA
         final HttpResponse response = future.get();
         Assert.assertNotNull(response);
 
-        final HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
-                ExecutionContext.HTTP_REQUEST);
+        final HttpRequest reqWrapper = context.getRequest();
 
         Assert.assertEquals(HttpStatus.SC_MULTIPLE_CHOICES, response.getStatusLine().getStatusCode());
         Assert.assertEquals("/oldlocation/", reqWrapper.getRequestLine().getUri());
@@ -305,12 +308,12 @@ public class TestRedirects extends HttpA
 
     @Test
     public void testBasicRedirect301() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("*", new BasicAsyncRequestHandler(
                 new BasicRedirectService(getSchemeName(), HttpStatus.SC_MOVED_PERMANENTLY)));
         final HttpHost target = start(registry, null);
 
-        final HttpContext context = new BasicHttpContext();
+        final HttpClientContext context = HttpClientContext.create();
 
         final HttpGet httpget = new HttpGet("/oldlocation/");
 
@@ -318,10 +321,8 @@ public class TestRedirects extends HttpA
         final HttpResponse response = future.get();
         Assert.assertNotNull(response);
 
-        final HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
-                ExecutionContext.HTTP_REQUEST);
-        final HttpHost host = (HttpHost) context.getAttribute(
-                ExecutionContext.HTTP_TARGET_HOST);
+        final HttpRequest reqWrapper = context.getRequest();
+        final HttpHost host = context.getTargetHost();
 
         Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
         Assert.assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());
@@ -330,12 +331,12 @@ public class TestRedirects extends HttpA
 
     @Test
     public void testBasicRedirect302() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("*", new BasicAsyncRequestHandler(
                 new BasicRedirectService(getSchemeName(), HttpStatus.SC_MOVED_TEMPORARILY)));
         final HttpHost target = start(registry, null);
 
-        final HttpContext context = new BasicHttpContext();
+        final HttpClientContext context = HttpClientContext.create();
 
         final HttpGet httpget = new HttpGet("/oldlocation/");
 
@@ -343,10 +344,8 @@ public class TestRedirects extends HttpA
         final HttpResponse response = future.get();
         Assert.assertNotNull(response);
 
-        final HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
-                ExecutionContext.HTTP_REQUEST);
-        final HttpHost host = (HttpHost) context.getAttribute(
-                ExecutionContext.HTTP_TARGET_HOST);
+        final HttpRequest reqWrapper = context.getRequest();
+        final HttpHost host = context.getTargetHost();
 
         Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
         Assert.assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());
@@ -355,7 +354,7 @@ public class TestRedirects extends HttpA
 
     @Test
     public void testBasicRedirect302NoLocation() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("*", new BasicAsyncRequestHandler(new HttpRequestHandler() {
 
             public void handle(
@@ -368,7 +367,7 @@ public class TestRedirects extends HttpA
         }));
         final HttpHost target = start(registry, null);
 
-        final HttpContext context = new BasicHttpContext();
+        final HttpClientContext context = HttpClientContext.create();
 
         final HttpGet httpget = new HttpGet("/oldlocation/");
 
@@ -376,10 +375,8 @@ public class TestRedirects extends HttpA
         final HttpResponse response = future.get();
         Assert.assertNotNull(response);
 
-        final HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
-                ExecutionContext.HTTP_REQUEST);
-        final HttpHost host = (HttpHost) context.getAttribute(
-                ExecutionContext.HTTP_TARGET_HOST);
+        final HttpRequest reqWrapper = context.getRequest();
+        final HttpHost host = context.getTargetHost();
 
         Assert.assertEquals(HttpStatus.SC_MOVED_TEMPORARILY, response.getStatusLine().getStatusCode());
         Assert.assertEquals("/oldlocation/", reqWrapper.getRequestLine().getUri());
@@ -388,12 +385,12 @@ public class TestRedirects extends HttpA
 
     @Test
     public void testBasicRedirect303() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("*", new BasicAsyncRequestHandler(
                 new BasicRedirectService(getSchemeName(), HttpStatus.SC_SEE_OTHER)));
         final HttpHost target = start(registry, null);
 
-        final HttpContext context = new BasicHttpContext();
+        final HttpClientContext context = HttpClientContext.create();
 
         final HttpGet httpget = new HttpGet("/oldlocation/");
 
@@ -401,10 +398,8 @@ public class TestRedirects extends HttpA
         final HttpResponse response = future.get();
         Assert.assertNotNull(response);
 
-        final HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
-                ExecutionContext.HTTP_REQUEST);
-        final HttpHost host = (HttpHost) context.getAttribute(
-                ExecutionContext.HTTP_TARGET_HOST);
+        final HttpRequest reqWrapper = context.getRequest();
+        final HttpHost host = context.getTargetHost();
 
         Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
         Assert.assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());
@@ -413,12 +408,12 @@ public class TestRedirects extends HttpA
 
     @Test
     public void testBasicRedirect304() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("*", new BasicAsyncRequestHandler(
                 new BasicRedirectService(getSchemeName(), HttpStatus.SC_NOT_MODIFIED)));
         final HttpHost target = start(registry, null);
 
-        final HttpContext context = new BasicHttpContext();
+        final HttpClientContext context = HttpClientContext.create();
 
         final HttpGet httpget = new HttpGet("/oldlocation/");
 
@@ -426,8 +421,7 @@ public class TestRedirects extends HttpA
         final HttpResponse response = future.get();
         Assert.assertNotNull(response);
 
-        final HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
-                ExecutionContext.HTTP_REQUEST);
+        final HttpRequest reqWrapper = context.getRequest();
 
         Assert.assertEquals(HttpStatus.SC_NOT_MODIFIED, response.getStatusLine().getStatusCode());
         Assert.assertEquals("/oldlocation/", reqWrapper.getRequestLine().getUri());
@@ -435,12 +429,12 @@ public class TestRedirects extends HttpA
 
     @Test
     public void testBasicRedirect305() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("*", new BasicAsyncRequestHandler(
                 new BasicRedirectService(getSchemeName(), HttpStatus.SC_USE_PROXY)));
         final HttpHost target = start(registry, null);
 
-        final HttpContext context = new BasicHttpContext();
+        final HttpClientContext context = HttpClientContext.create();
 
         final HttpGet httpget = new HttpGet("/oldlocation/");
 
@@ -448,8 +442,7 @@ public class TestRedirects extends HttpA
         final HttpResponse response = future.get();
         Assert.assertNotNull(response);
 
-        final HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
-                ExecutionContext.HTTP_REQUEST);
+        final HttpRequest reqWrapper = context.getRequest();
 
         Assert.assertEquals(HttpStatus.SC_USE_PROXY, response.getStatusLine().getStatusCode());
         Assert.assertEquals("/oldlocation/", reqWrapper.getRequestLine().getUri());
@@ -457,12 +450,12 @@ public class TestRedirects extends HttpA
 
     @Test
     public void testBasicRedirect307() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("*", new BasicAsyncRequestHandler(
                 new BasicRedirectService(getSchemeName(), HttpStatus.SC_TEMPORARY_REDIRECT)));
         final HttpHost target = start(registry, null);
 
-        final HttpContext context = new BasicHttpContext();
+        final HttpClientContext context = HttpClientContext.create();
 
         final HttpGet httpget = new HttpGet("/oldlocation/");
 
@@ -470,10 +463,8 @@ public class TestRedirects extends HttpA
         final HttpResponse response = future.get();
         Assert.assertNotNull(response);
 
-        final HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
-                ExecutionContext.HTTP_REQUEST);
-        final HttpHost host = (HttpHost) context.getAttribute(
-                ExecutionContext.HTTP_TARGET_HOST);
+        final HttpRequest reqWrapper = context.getRequest();
+        final HttpHost host = context.getTargetHost();
 
         Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
         Assert.assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());
@@ -482,14 +473,16 @@ public class TestRedirects extends HttpA
 
     @Test(expected=ExecutionException.class)
     public void testMaxRedirectCheck() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("*", new BasicAsyncRequestHandler(new CircularRedirectService()));
         final HttpHost target = start(registry, null);
 
-        this.httpclient.getParams().setBooleanParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, true);
-        this.httpclient.getParams().setIntParameter(ClientPNames.MAX_REDIRECTS, 5);
+        final RequestConfig config = RequestConfig.custom()
+                .setCircularRedirectsAllowed(true)
+                .setMaxRedirects(5).build();
 
         final HttpGet httpget = new HttpGet("/circular-oldlocation/");
+        httpget.setConfig(config);
         try {
             final Future<HttpResponse> future = this.httpclient.execute(target, httpget, null);
             future.get();
@@ -501,15 +494,17 @@ public class TestRedirects extends HttpA
 
     @Test(expected=ExecutionException.class)
     public void testCircularRedirect() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("*", new BasicAsyncRequestHandler(new CircularRedirectService()));
         final HttpHost target = start(registry, null);
 
-        this.httpclient.getParams().setBooleanParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, false);
-        this.httpclient.getParams().setBooleanParameter(ClientPNames.REJECT_RELATIVE_REDIRECT, false);
+        final RequestConfig config = RequestConfig.custom()
+                .setCircularRedirectsAllowed(false)
+                .setRelativeRedirectsAllowed(true)
+                .build();
 
         final HttpGet httpget = new HttpGet("/circular-oldlocation/");
-
+        httpget.setConfig(config);
         try {
             final Future<HttpResponse> future = this.httpclient.execute(target, httpget, null);
             future.get();
@@ -521,12 +516,12 @@ public class TestRedirects extends HttpA
 
     @Test
     public void testPostNoRedirect() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("*", new BasicAsyncRequestHandler(
                 new BasicRedirectService(getSchemeName(), HttpStatus.SC_MOVED_TEMPORARILY)));
         final HttpHost target = start(registry, null);
 
-        final HttpContext context = new BasicHttpContext();
+        final HttpClientContext context = HttpClientContext.create();
 
         final HttpPost httppost = new HttpPost("/oldlocation/");
         httppost.setEntity(new NStringEntity("stuff"));
@@ -535,8 +530,7 @@ public class TestRedirects extends HttpA
         final HttpResponse response = future.get();
         Assert.assertNotNull(response);
 
-        final HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
-                ExecutionContext.HTTP_REQUEST);
+        final HttpRequest reqWrapper = context.getRequest();
 
         Assert.assertEquals(HttpStatus.SC_MOVED_TEMPORARILY, response.getStatusLine().getStatusCode());
         Assert.assertEquals("/oldlocation/", reqWrapper.getRequestLine().getUri());
@@ -545,12 +539,12 @@ public class TestRedirects extends HttpA
 
     @Test
     public void testPostRedirectSeeOther() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("*", new BasicAsyncRequestHandler(
                 new BasicRedirectService(getSchemeName(), HttpStatus.SC_SEE_OTHER)));
         final HttpHost target = start(registry, null);
 
-        final HttpContext context = new BasicHttpContext();
+        final HttpClientContext context = HttpClientContext.create();
 
         final HttpPost httppost = new HttpPost("/oldlocation/");
         httppost.setEntity(new NStringEntity("stuff"));
@@ -559,8 +553,7 @@ public class TestRedirects extends HttpA
         final HttpResponse response = future.get();
         Assert.assertNotNull(response);
 
-        final HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
-                ExecutionContext.HTTP_REQUEST);
+        final HttpRequest reqWrapper = context.getRequest();
 
         Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
         Assert.assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());
@@ -569,24 +562,25 @@ public class TestRedirects extends HttpA
 
     @Test
     public void testRelativeRedirect() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("*", new BasicAsyncRequestHandler(new RelativeRedirectService()));
         final HttpHost target = start(registry, null);
 
-        final HttpContext context = new BasicHttpContext();
+        final HttpClientContext context = HttpClientContext.create();
+
+        final RequestConfig config = RequestConfig.custom()
+                .setRelativeRedirectsAllowed(true)
+                .build();
 
-        this.httpclient.getParams().setBooleanParameter(
-                ClientPNames.REJECT_RELATIVE_REDIRECT, false);
         final HttpGet httpget = new HttpGet("/oldlocation/");
+        httpget.setConfig(config);
 
         final Future<HttpResponse> future = this.httpclient.execute(target, httpget, context, null);
         final HttpResponse response = future.get();
         Assert.assertNotNull(response);
 
-        final HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
-                ExecutionContext.HTTP_REQUEST);
-        final HttpHost host = (HttpHost) context.getAttribute(
-                ExecutionContext.HTTP_TARGET_HOST);
+        final HttpRequest reqWrapper = context.getRequest();
+        final HttpHost host = context.getTargetHost();
 
         Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
         Assert.assertEquals("/relativelocation/", reqWrapper.getRequestLine().getUri());
@@ -595,24 +589,25 @@ public class TestRedirects extends HttpA
 
     @Test
     public void testRelativeRedirect2() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("*", new BasicAsyncRequestHandler(new RelativeRedirectService2()));
         final HttpHost target = start(registry, null);
 
-        final HttpContext context = new BasicHttpContext();
+        final HttpClientContext context = HttpClientContext.create();
+
+        final RequestConfig config = RequestConfig.custom()
+                .setRelativeRedirectsAllowed(true)
+                .build();
 
-        this.httpclient.getParams().setBooleanParameter(
-                ClientPNames.REJECT_RELATIVE_REDIRECT, false);
         final HttpGet httpget = new HttpGet("/test/oldlocation");
+        httpget.setConfig(config);
 
         final Future<HttpResponse> future = this.httpclient.execute(target, httpget, context, null);
         final HttpResponse response = future.get();
         Assert.assertNotNull(response);
 
-        final HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
-                ExecutionContext.HTTP_REQUEST);
-        final HttpHost host = (HttpHost) context.getAttribute(
-                ExecutionContext.HTTP_TARGET_HOST);
+        final HttpRequest reqWrapper = context.getRequest();
+        final HttpHost host = context.getTargetHost();
 
         Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
         Assert.assertEquals("/test/relativelocation", reqWrapper.getRequestLine().getUri());
@@ -621,14 +616,16 @@ public class TestRedirects extends HttpA
 
     @Test(expected=ExecutionException.class)
     public void testRejectRelativeRedirect() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("*", new BasicAsyncRequestHandler(new RelativeRedirectService()));
         final HttpHost target = start(registry, null);
 
-        this.httpclient.getParams().setBooleanParameter(
-                ClientPNames.REJECT_RELATIVE_REDIRECT, true);
-        final HttpGet httpget = new HttpGet("/oldlocation/");
+        final RequestConfig config = RequestConfig.custom()
+                .setRelativeRedirectsAllowed(false)
+                .build();
 
+        final HttpGet httpget = new HttpGet("/oldlocation/");
+        httpget.setConfig(config);
         try {
             final Future<HttpResponse> future = this.httpclient.execute(target, httpget, null);
             future.get();
@@ -640,7 +637,7 @@ public class TestRedirects extends HttpA
 
     @Test(expected=ExecutionException.class)
     public void testRejectBogusRedirectLocation() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("*", new BasicAsyncRequestHandler(
                 new BogusRedirectService(getSchemeName(), "xxx://bogus", true)));
         final HttpHost target = start(registry, null);
@@ -651,14 +648,14 @@ 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 HttpException);
+            Assert.assertTrue(e.getCause() instanceof UnknownHostException);
             throw e;
         }
     }
 
     @Test(expected=ExecutionException.class)
     public void testRejectInvalidRedirectLocation() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("*", new BasicAsyncRequestHandler(
                 new BogusRedirectService(getSchemeName(), "/newlocation/?p=I have spaces", false)));
         final HttpHost target = start(registry, null);
@@ -675,13 +672,14 @@ public class TestRedirects extends HttpA
 
     @Test
     public void testRedirectWithCookie() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("*", new BasicAsyncRequestHandler(
                 new BasicRedirectService(getSchemeName(), HttpStatus.SC_MOVED_TEMPORARILY)));
         final HttpHost target = start(registry, null);
 
         final CookieStore cookieStore = new BasicCookieStore();
-        this.httpclient.setCookieStore(cookieStore);
+        final HttpClientContext context = HttpClientContext.create();
+        context.setCookieStore(cookieStore);
 
         final BasicClientCookie cookie = new BasicClientCookie("name", "value");
         cookie.setDomain(target.getHostName());
@@ -689,15 +687,13 @@ public class TestRedirects extends HttpA
 
         cookieStore.addCookie(cookie);
 
-        final HttpContext context = new BasicHttpContext();
         final HttpGet httpget = new HttpGet("/oldlocation/");
 
         final Future<HttpResponse> future = this.httpclient.execute(target, httpget, context, null);
         final HttpResponse response = future.get();
         Assert.assertNotNull(response);
 
-        final HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
-                ExecutionContext.HTTP_REQUEST);
+        final HttpRequest reqWrapper = context.getRequest();
 
         Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
         Assert.assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());
@@ -708,17 +704,21 @@ public class TestRedirects extends HttpA
 
     @Test
     public void testDefaultHeadersRedirect() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("*", new BasicAsyncRequestHandler(
                 new BasicRedirectService(getSchemeName(), HttpStatus.SC_MOVED_TEMPORARILY)));
-        final HttpHost target = start(registry, null);
-
-        final HttpContext context = new BasicHttpContext();
 
         final List<Header> defaultHeaders = new ArrayList<Header>(1);
         defaultHeaders.add(new BasicHeader(HTTP.USER_AGENT, "my-test-client"));
 
-        this.httpclient.getParams().setParameter(ClientPNames.DEFAULT_HEADERS, defaultHeaders);
+        this.httpclient = HttpAsyncClients.custom()
+                .setConnectionManager(this.connMgr)
+                .setDefaultHeaders(defaultHeaders)
+                .build();
+
+        final HttpHost target = start(registry, null);
+
+        final HttpClientContext context = HttpClientContext.create();
 
         final HttpGet httpget = new HttpGet("/oldlocation/");
 
@@ -726,9 +726,7 @@ public class TestRedirects extends HttpA
         final HttpResponse response = future.get();
         Assert.assertNotNull(response);
 
-
-        final HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
-                ExecutionContext.HTTP_REQUEST);
+        final HttpRequest reqWrapper = context.getRequest();
 
         Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
         Assert.assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());
@@ -769,23 +767,23 @@ public class TestRedirects extends HttpA
 
     @Test
     public void testCrossSiteRedirect() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("/random/*", new BasicAsyncRequestHandler(
                 new RandomHandler()));
         final HttpHost redirectTarget = start(registry, null);
 
-        final HttpAsyncRequestHandlerRegistry registry2 = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry2 = new UriHttpAsyncRequestHandlerMapper();
         registry2.register("/redirect/*", new BasicAsyncRequestHandler(
                 new CrossSiteRedirectService(redirectTarget)));
-        final HttpServerNio secondServer = new HttpServerNio(createServerConnectionFactory(this.serverParams));
+        final HttpServerNio secondServer = new HttpServerNio(this.serverReactorConfig,
+                createServerConnectionFactory(this.serverConnectionConfig));
         secondServer.setExceptionHandler(new SimpleIOReactorExceptionHandler());
         final HttpAsyncService serviceHandler = new HttpAsyncService(
                 this.serverHttpProc,
                 new DefaultConnectionReuseStrategy(),
                 new DefaultHttpResponseFactory(),
                 registry2,
-                null,
-                this.serverParams);
+                null);
         secondServer.start(serviceHandler);
         try {
             final ListenerEndpoint endpoint2 = secondServer.getListenerEndpoint();
@@ -797,7 +795,7 @@ public class TestRedirects extends HttpA
 
             final Queue<Future<HttpResponse>> queue = new ConcurrentLinkedQueue<Future<HttpResponse>>();
             for (int i = 0; i < 4; i++) {
-                final HttpContext context = new BasicHttpContext();
+                final HttpClientContext context = HttpClientContext.create();
                 final HttpGet httpget = new HttpGet("/redirect/anywhere");
                 queue.add(this.httpclient.execute(initialTarget, httpget, context, null));
             }
@@ -812,4 +810,4 @@ public class TestRedirects extends HttpA
         }
     }
 
-}
+}
\ No newline at end of file

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestStatefulConnManagement.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestStatefulConnManagement.java?rev=1463728&r1=1463727&r2=1463728&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestStatefulConnManagement.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/integration/TestStatefulConnManagement.java Tue Apr  2 20:10:35 2013
@@ -40,30 +40,31 @@ import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
 import org.apache.http.client.UserTokenHandler;
 import org.apache.http.client.methods.HttpGet;
+import org.apache.http.config.ConnectionConfig;
 import org.apache.http.entity.ContentType;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.DefaultHttpResponseFactory;
 import org.apache.http.impl.nio.DefaultNHttpServerConnection;
 import org.apache.http.impl.nio.DefaultNHttpServerConnectionFactory;
+import org.apache.http.impl.nio.client.HttpAsyncClients;
+import org.apache.http.impl.nio.conn.CPoolUtils;
 import org.apache.http.nio.ContentDecoder;
 import org.apache.http.nio.IOControl;
+import org.apache.http.nio.NHttpClientConnection;
 import org.apache.http.nio.NHttpConnectionFactory;
 import org.apache.http.nio.client.HttpAsyncClient;
-import org.apache.http.nio.conn.ManagedClientAsyncConnection;
 import org.apache.http.nio.entity.NStringEntity;
 import org.apache.http.nio.protocol.AbstractAsyncResponseConsumer;
 import org.apache.http.nio.protocol.BasicAsyncRequestHandler;
 import org.apache.http.nio.protocol.BasicAsyncRequestProducer;
 import org.apache.http.nio.protocol.HttpAsyncExpectationVerifier;
-import org.apache.http.nio.protocol.HttpAsyncRequestHandlerRegistry;
-import org.apache.http.nio.protocol.HttpAsyncRequestHandlerResolver;
+import org.apache.http.nio.protocol.HttpAsyncRequestHandlerMapper;
 import org.apache.http.nio.protocol.HttpAsyncService;
+import org.apache.http.nio.protocol.UriHttpAsyncRequestHandlerMapper;
 import org.apache.http.nio.reactor.IOEventDispatch;
 import org.apache.http.nio.reactor.IOReactorStatus;
 import org.apache.http.nio.reactor.ListenerEndpoint;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpConnectionParams;
-import org.apache.http.params.HttpParams;
+import org.apache.http.pool.PoolEntry;
 import org.apache.http.protocol.BasicHttpContext;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpRequestHandler;
@@ -77,7 +78,7 @@ public class TestStatefulConnManagement 
     @Before
     public void setUp() throws Exception {
         initServer();
-        initClient();
+        initConnectionManager();
     }
 
     @After
@@ -88,8 +89,8 @@ public class TestStatefulConnManagement 
 
     @Override
     protected NHttpConnectionFactory<DefaultNHttpServerConnection> createServerConnectionFactory(
-            final HttpParams params) throws Exception {
-        return new DefaultNHttpServerConnectionFactory(params);
+            final ConnectionConfig config) throws Exception {
+        return new DefaultNHttpServerConnectionFactory(config);
     }
 
     @Override
@@ -98,15 +99,14 @@ public class TestStatefulConnManagement 
     }
 
     private HttpHost start(
-            final HttpAsyncRequestHandlerResolver requestHandlerResolver,
+            final HttpAsyncRequestHandlerMapper requestHandlerResolver,
             final HttpAsyncExpectationVerifier expectationVerifier) throws Exception {
         final HttpAsyncService serviceHandler = new HttpAsyncService(
                 this.serverHttpProc,
                 new DefaultConnectionReuseStrategy(),
                 new DefaultHttpResponseFactory(),
                 requestHandlerResolver,
-                expectationVerifier,
-                this.serverParams);
+                expectationVerifier);
         this.server.start(serviceHandler);
         this.httpclient.start();
 
@@ -137,26 +137,28 @@ public class TestStatefulConnManagement 
 
     @Test
     public void testStatefulConnections() throws Exception {
-        this.httpclient.setUserTokenHandler(new UserTokenHandler() {
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
+        registry.register("*", new BasicAsyncRequestHandler(new SimpleService()));
+
+        final UserTokenHandler userTokenHandler = new UserTokenHandler() {
 
             public Object getUserToken(final HttpContext context) {
                 final Integer id = (Integer) context.getAttribute("user");
                 return id;
             }
 
-        });
+        };
 
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
-        registry.register("*", new BasicAsyncRequestHandler(new SimpleService()));
+        this.httpclient = HttpAsyncClients.custom()
+                .setConnectionManager(this.connMgr)
+                .setUserTokenHandler(userTokenHandler)
+                .build();
 
         final HttpHost target = start(registry, null);
 
         final int workerCount = 2;
         final int requestCount = 5;
 
-        final HttpParams params = new BasicHttpParams();
-        HttpConnectionParams.setConnectionTimeout(params, 10);
-
         final HttpContext[] contexts = new HttpContext[workerCount];
         final HttpWorker[] workers = new HttpWorker[workerCount];
         for (int i = 0; i < contexts.length; i++) {
@@ -184,7 +186,7 @@ public class TestStatefulConnManagement 
         for (final HttpContext context : contexts) {
             final Integer id = (Integer) context.getAttribute("user");
 
-            for (int r = 0; r < requestCount; r++) {
+            for (int r = 1; r < requestCount; r++) {
                 final Integer state = (Integer) context.getAttribute("r" + r);
                 Assert.assertEquals(id, state);
             }
@@ -252,9 +254,11 @@ public class TestStatefulConnManagement 
 
                                 @Override
                                 protected Object buildResult(final HttpContext context) throws Exception {
-                                    final ManagedClientAsyncConnection conn = (ManagedClientAsyncConnection) context.getAttribute(
+                                    final NHttpClientConnection conn = (NHttpClientConnection) context.getAttribute(
                                             IOEventDispatch.CONNECTION_KEY);
-                                    return conn.getState();
+
+                                    final PoolEntry<?, ?> entry = CPoolUtils.getPoolEntry(conn);
+                                    return entry.getState();
                                 }
 
                                 @Override
@@ -281,20 +285,25 @@ public class TestStatefulConnManagement 
         // This tests what happens when a maxed connection pool needs
         // to kill the last idle connection to a route to build a new
         // one to the same route.
-        this.httpclient.setUserTokenHandler(new UserTokenHandler() {
+        final UserTokenHandler userTokenHandler = new UserTokenHandler() {
 
             public Object getUserToken(final HttpContext context) {
                 return context.getAttribute("user");
             }
 
-        });
+        };
+
+        this.httpclient = HttpAsyncClients.custom()
+                .setConnectionManager(this.connMgr)
+                .setUserTokenHandler(userTokenHandler)
+                .build();
 
         final int maxConn = 2;
         // We build a client with 2 max active // connections, and 2 max per route.
         this.connMgr.setMaxTotal(maxConn);
         this.connMgr.setDefaultMaxPerRoute(maxConn);
 
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("*", new BasicAsyncRequestHandler(new SimpleService()));
 
         final HttpHost target = start(registry, null);
@@ -345,4 +354,4 @@ public class TestStatefulConnManagement 
         Assert.assertEquals(200, response3.getStatusLine().getStatusCode());
     }
 
-}
+}
\ No newline at end of file

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestAsyncConsumers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestAsyncConsumers.java?rev=1463728&r1=1463727&r2=1463728&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestAsyncConsumers.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestAsyncConsumers.java Tue Apr  2 20:10:35 2013
@@ -39,24 +39,25 @@ import org.apache.http.HttpAsyncTestBase
 import org.apache.http.HttpException;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpResponse;
+import org.apache.http.config.ConnectionConfig;
 import org.apache.http.entity.ContentType;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.DefaultHttpResponseFactory;
 import org.apache.http.impl.nio.DefaultNHttpServerConnection;
 import org.apache.http.impl.nio.DefaultNHttpServerConnectionFactory;
+import org.apache.http.impl.nio.client.HttpAsyncClients;
 import org.apache.http.localserver.EchoHandler;
 import org.apache.http.localserver.RandomHandler;
 import org.apache.http.nio.IOControl;
 import org.apache.http.nio.NHttpConnectionFactory;
 import org.apache.http.nio.protocol.BasicAsyncRequestHandler;
 import org.apache.http.nio.protocol.HttpAsyncExpectationVerifier;
-import org.apache.http.nio.protocol.HttpAsyncRequestHandlerRegistry;
-import org.apache.http.nio.protocol.HttpAsyncRequestHandlerResolver;
+import org.apache.http.nio.protocol.HttpAsyncRequestHandlerMapper;
 import org.apache.http.nio.protocol.HttpAsyncRequestProducer;
 import org.apache.http.nio.protocol.HttpAsyncService;
+import org.apache.http.nio.protocol.UriHttpAsyncRequestHandlerMapper;
 import org.apache.http.nio.reactor.IOReactorStatus;
 import org.apache.http.nio.reactor.ListenerEndpoint;
-import org.apache.http.params.HttpParams;
 import org.apache.http.protocol.HttpContext;
 import org.junit.After;
 import org.junit.Assert;
@@ -69,7 +70,10 @@ public class TestAsyncConsumers extends 
     @Before
     public void setUp() throws Exception {
         initServer();
-        initClient();
+        initConnectionManager();
+        this.httpclient = HttpAsyncClients.custom()
+                .setConnectionManager(this.connMgr)
+                .build();
     }
 
     @After
@@ -80,8 +84,8 @@ public class TestAsyncConsumers extends 
 
     @Override
     protected NHttpConnectionFactory<DefaultNHttpServerConnection> createServerConnectionFactory(
-            final HttpParams params) throws Exception {
-        return new DefaultNHttpServerConnectionFactory(params);
+            final ConnectionConfig config) throws Exception {
+        return new DefaultNHttpServerConnectionFactory(config);
     }
 
     @Override
@@ -90,15 +94,14 @@ public class TestAsyncConsumers extends 
     }
 
     private HttpHost start(
-            final HttpAsyncRequestHandlerResolver requestHandlerResolver,
+            final HttpAsyncRequestHandlerMapper requestHandlerResolver,
             final HttpAsyncExpectationVerifier expectationVerifier) throws Exception {
         final HttpAsyncService serviceHandler = new HttpAsyncService(
                 this.serverHttpProc,
                 new DefaultConnectionReuseStrategy(),
                 new DefaultHttpResponseFactory(),
                 requestHandlerResolver,
-                expectationVerifier,
-                this.serverParams);
+                expectationVerifier);
         this.server.start(serviceHandler);
         this.httpclient.start();
 
@@ -112,7 +115,7 @@ public class TestAsyncConsumers extends 
     }
 
     private HttpHost start() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("/echo/*", new BasicAsyncRequestHandler(new EchoHandler()));
         registry.register("/random/*", new BasicAsyncRequestHandler(new RandomHandler()));
         return start(registry, null);

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestZeroCopy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestZeroCopy.java?rev=1463728&r1=1463727&r2=1463728&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestZeroCopy.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/nio/client/methods/TestZeroCopy.java Tue Apr  2 20:10:35 2013
@@ -49,23 +49,24 @@ import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
 import org.apache.http.client.methods.HttpPost;
+import org.apache.http.config.ConnectionConfig;
 import org.apache.http.entity.BasicHttpEntity;
 import org.apache.http.entity.ContentType;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.DefaultHttpResponseFactory;
 import org.apache.http.impl.nio.DefaultNHttpServerConnection;
 import org.apache.http.impl.nio.DefaultNHttpServerConnectionFactory;
+import org.apache.http.impl.nio.client.HttpAsyncClients;
 import org.apache.http.nio.NHttpConnectionFactory;
 import org.apache.http.nio.entity.NFileEntity;
 import org.apache.http.nio.entity.NStringEntity;
 import org.apache.http.nio.protocol.BasicAsyncRequestHandler;
 import org.apache.http.nio.protocol.HttpAsyncExpectationVerifier;
-import org.apache.http.nio.protocol.HttpAsyncRequestHandlerRegistry;
-import org.apache.http.nio.protocol.HttpAsyncRequestHandlerResolver;
+import org.apache.http.nio.protocol.HttpAsyncRequestHandlerMapper;
 import org.apache.http.nio.protocol.HttpAsyncService;
+import org.apache.http.nio.protocol.UriHttpAsyncRequestHandlerMapper;
 import org.apache.http.nio.reactor.IOReactorStatus;
 import org.apache.http.nio.reactor.ListenerEndpoint;
-import org.apache.http.params.HttpParams;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpRequestHandler;
 import org.junit.After;
@@ -80,7 +81,10 @@ public class TestZeroCopy extends HttpAs
     @Before
     public void setUp() throws Exception {
         initServer();
-        initClient();
+        initConnectionManager();
+        this.httpclient = HttpAsyncClients.custom()
+                .setConnectionManager(this.connMgr)
+                .build();
     }
 
     @After
@@ -91,8 +95,8 @@ public class TestZeroCopy extends HttpAs
 
     @Override
     protected NHttpConnectionFactory<DefaultNHttpServerConnection> createServerConnectionFactory(
-            final HttpParams params) throws Exception {
-        return new DefaultNHttpServerConnectionFactory(params);
+            final ConnectionConfig config) throws Exception {
+        return new DefaultNHttpServerConnectionFactory(config);
     }
 
     @Override
@@ -101,15 +105,14 @@ public class TestZeroCopy extends HttpAs
     }
 
     private HttpHost start(
-            final HttpAsyncRequestHandlerResolver requestHandlerResolver,
+            final HttpAsyncRequestHandlerMapper requestHandlerResolver,
             final HttpAsyncExpectationVerifier expectationVerifier) throws Exception {
         final HttpAsyncService serviceHandler = new HttpAsyncService(
                 this.serverHttpProc,
                 new DefaultConnectionReuseStrategy(),
                 new DefaultHttpResponseFactory(),
                 requestHandlerResolver,
-                expectationVerifier,
-                this.serverParams);
+                expectationVerifier);
         this.server.start(serviceHandler);
         this.httpclient.start();
 
@@ -266,7 +269,7 @@ public class TestZeroCopy extends HttpAs
 
     @Test
     public void testTwoWayZeroCopy() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("*", new BasicAsyncRequestHandler(new TestHandler(false)));
         final HttpHost target = start(registry, null);
 
@@ -296,7 +299,7 @@ public class TestZeroCopy extends HttpAs
 
     @Test
     public void testZeroCopyFallback() throws Exception {
-        final HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
+        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
         registry.register("*", new BasicAsyncRequestHandler(new TestHandler(true)));
         final HttpHost target = start(registry, null);
         final File tmpdir = FileUtils.getTempDirectory();

Modified: httpcomponents/httpasyncclient/trunk/pom.xml
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/pom.xml?rev=1463728&r1=1463727&r2=1463728&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/pom.xml (original)
+++ httpcomponents/httpasyncclient/trunk/pom.xml Tue Apr  2 20:10:35 2013
@@ -65,7 +65,7 @@
   </scm>
 
   <properties>
-    <httpcore.version>4.3-alpha1</httpcore.version>
+    <httpcore.version>4.3-beta1</httpcore.version>
     <httpclient.version>4.3-alpha1</httpclient.version>
     <commons-logging.version>1.1.1</commons-logging.version>
     <!-- Note IO 2.3+ requires Java 6 -->



Mime
View raw message