Return-Path: X-Original-To: apmail-hc-commits-archive@www.apache.org Delivered-To: apmail-hc-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 75C3411FEE for ; Tue, 17 Jun 2014 09:45:44 +0000 (UTC) Received: (qmail 62194 invoked by uid 500); 17 Jun 2014 09:45:44 -0000 Delivered-To: apmail-hc-commits-archive@hc.apache.org Received: (qmail 62151 invoked by uid 500); 17 Jun 2014 09:45:44 -0000 Mailing-List: contact commits-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list commits@hc.apache.org Received: (qmail 62142 invoked by uid 99); 17 Jun 2014 09:45:44 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Jun 2014 09:45:44 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Jun 2014 09:45:43 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 58F792388A4A for ; Tue, 17 Jun 2014 09:45:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1603109 [2/2] - in /httpcomponents/httpasyncclient/trunk: ./ httpasyncclient/src/test/java/org/apache/http/ httpasyncclient/src/test/java/org/apache/http/localserver/ httpasyncclient/src/test/java/org/apache/http/nio/client/integration/ ht... Date: Tue, 17 Jun 2014 09:45:17 -0000 To: commits@hc.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140617094518.58F792388A4A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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=1603109&r1=1603108&r2=1603109&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 Jun 17 09:45:17 2014 @@ -27,7 +27,6 @@ package org.apache.http.nio.client.integration; import java.io.IOException; -import java.net.InetSocketAddress; import java.nio.ByteBuffer; import java.util.concurrent.Future; @@ -40,84 +39,26 @@ 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.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.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.pool.PoolEntry; import org.apache.http.protocol.BasicHttpContext; import org.apache.http.protocol.HttpContext; import org.apache.http.protocol.HttpRequestHandler; -import org.junit.After; import org.junit.Assert; -import org.junit.Before; import org.junit.Test; public class TestStatefulConnManagement extends HttpAsyncTestBase { - @Before - public void setUp() throws Exception { - initServer(); - initConnectionManager(); - } - - @After - public void tearDown() throws Exception { - shutDownClient(); - shutDownServer(); - } - - @Override - protected NHttpConnectionFactory createServerConnectionFactory( - final ConnectionConfig config) throws Exception { - return new DefaultNHttpServerConnectionFactory(config); - } - - @Override - protected String getSchemeName() { - return "http"; - } - - 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.server.start(serviceHandler); - this.httpclient.start(); - - final ListenerEndpoint endpoint = this.server.getListenerEndpoint(); - endpoint.waitFor(); - - Assert.assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus()); - final InetSocketAddress address = (InetSocketAddress) endpoint.getAddress(); - return new HttpHost("localhost", address.getPort(), getSchemeName()); - } - static class SimpleService implements HttpRequestHandler { public SimpleService() { @@ -136,8 +77,7 @@ public class TestStatefulConnManagement @Test public void testStatefulConnections() throws Exception { - final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper(); - registry.register("*", new BasicAsyncRequestHandler(new SimpleService())); + this.serverBootstrap.registerHandler("*", new BasicAsyncRequestHandler(new SimpleService())); final UserTokenHandler userTokenHandler = new UserTokenHandler() { @@ -146,13 +86,8 @@ public class TestStatefulConnManagement } }; - - this.httpclient = HttpAsyncClients.custom() - .setConnectionManager(this.connMgr) - .setUserTokenHandler(userTokenHandler) - .build(); - - final HttpHost target = start(registry, null); + this.clientBuilder.setUserTokenHandler(userTokenHandler); + final HttpHost target = start(); final int workerCount = 2; final int requestCount = 5; @@ -280,6 +215,7 @@ public class TestStatefulConnManagement @Test public void testRouteSpecificPoolRecylcing() throws Exception { + this.serverBootstrap.registerHandler("*", new BasicAsyncRequestHandler(new SimpleService())); // 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. @@ -290,22 +226,14 @@ public class TestStatefulConnManagement } }; + this.clientBuilder.setUserTokenHandler(userTokenHandler); - this.httpclient = HttpAsyncClients.custom() - .setConnectionManager(this.connMgr) - .setUserTokenHandler(userTokenHandler) - .build(); - + final HttpHost target = start(); 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 UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper(); - registry.register("*", new BasicAsyncRequestHandler(new SimpleService())); - - final HttpHost target = start(registry, null); - // Bottom of the pool : a *keep alive* connection to Route 1. final HttpContext context1 = new BasicHttpContext(); context1.setAttribute("user", "stuff"); 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=1603109&r1=1603108&r2=1603109&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 Jun 17 09:45:17 2014 @@ -27,7 +27,6 @@ package org.apache.http.nio.client.methods; import java.io.IOException; -import java.net.InetSocketAddress; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.util.concurrent.ExecutionException; @@ -39,27 +38,13 @@ 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.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.protocol.HttpContext; -import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -67,57 +52,11 @@ import org.mockito.Mockito; public class TestAsyncConsumers extends HttpAsyncTestBase { - @Before + @Before @Override public void setUp() throws Exception { - initServer(); - initConnectionManager(); - this.httpclient = HttpAsyncClients.custom() - .setConnectionManager(this.connMgr) - .build(); - } - - @After - public void tearDown() throws Exception { - shutDownClient(); - shutDownServer(); - } - - @Override - protected NHttpConnectionFactory createServerConnectionFactory( - final ConnectionConfig config) throws Exception { - return new DefaultNHttpServerConnectionFactory(config); - } - - @Override - protected String getSchemeName() { - return "http"; - } - - 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.server.start(serviceHandler); - this.httpclient.start(); - - final ListenerEndpoint endpoint = this.server.getListenerEndpoint(); - endpoint.waitFor(); - - Assert.assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus()); - final InetSocketAddress address = (InetSocketAddress) endpoint.getAddress(); - return new HttpHost("localhost", address.getPort(), getSchemeName()); - } - - private HttpHost start() throws Exception { - final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper(); - registry.register("/echo/*", new BasicAsyncRequestHandler(new EchoHandler())); - registry.register("/random/*", new BasicAsyncRequestHandler(new RandomHandler())); - return start(registry, null); + super.setUp(); + this.serverBootstrap.registerHandler("/echo/*", new BasicAsyncRequestHandler(new EchoHandler())); + this.serverBootstrap.registerHandler("/random/*", new BasicAsyncRequestHandler(new RandomHandler())); } static class ByteCountingConsumer extends AsyncByteConsumer { 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=1603109&r1=1603108&r2=1603109&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 Jun 17 09:45:17 2014 @@ -31,7 +31,6 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import java.net.InetSocketAddress; import java.net.URI; import java.nio.charset.Charset; import java.util.concurrent.Future; @@ -50,81 +49,21 @@ 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.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.protocol.HttpContext; import org.apache.http.protocol.HttpRequestHandler; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; -import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; public class TestZeroCopy extends HttpAsyncTestBase { - @Before - public void setUp() throws Exception { - initServer(); - initConnectionManager(); - this.httpclient = HttpAsyncClients.custom() - .setConnectionManager(this.connMgr) - .build(); - } - - @After - public void tearDown() throws Exception { - shutDownClient(); - shutDownServer(); - } - - @Override - protected NHttpConnectionFactory createServerConnectionFactory( - final ConnectionConfig config) throws Exception { - return new DefaultNHttpServerConnectionFactory(config); - } - - @Override - protected String getSchemeName() { - return "http"; - } - - 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.server.start(serviceHandler); - this.httpclient.start(); - - final ListenerEndpoint endpoint = this.server.getListenerEndpoint(); - endpoint.waitFor(); - - Assert.assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus()); - final InetSocketAddress address = (InetSocketAddress) endpoint.getAddress(); - return new HttpHost("localhost", address.getPort(), getSchemeName()); - } - private static final String[] TEXT = { "blah blah blah blah blah blah blah blah blah blah blah blah blah blah", "yada yada yada yada yada yada yada yada yada yada yada yada yada yada", @@ -271,9 +210,8 @@ public class TestZeroCopy extends HttpAs @Test public void testTwoWayZeroCopy() throws Exception { - final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper(); - registry.register("*", new BasicAsyncRequestHandler(new TestHandler(false))); - final HttpHost target = start(registry, null); + this.serverBootstrap.registerHandler("*", new BasicAsyncRequestHandler(new TestHandler(false))); + final HttpHost target = start(); final File tmpdir = FileUtils.getTempDirectory(); this.tmpfile = new File(tmpdir, "dst.test"); @@ -301,9 +239,8 @@ public class TestZeroCopy extends HttpAs @Test public void testZeroCopyFallback() throws Exception { - final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper(); - registry.register("*", new BasicAsyncRequestHandler(new TestHandler(true))); - final HttpHost target = start(registry, null); + this.serverBootstrap.registerHandler("*", new BasicAsyncRequestHandler(new TestHandler(true))); + final HttpHost target = start(); final File tmpdir = FileUtils.getTempDirectory(); this.tmpfile = new File(tmpdir, "dst.test"); final TestZeroCopyPost httppost = new TestZeroCopyPost(target.toURI() + "/bounce", true); Modified: httpcomponents/httpasyncclient/trunk/pom.xml URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/pom.xml?rev=1603109&r1=1603108&r2=1603109&view=diff ============================================================================== --- httpcomponents/httpasyncclient/trunk/pom.xml (original) +++ httpcomponents/httpasyncclient/trunk/pom.xml Tue Jun 17 09:45:17 2014 @@ -66,7 +66,7 @@ 1.6 1.6 - 4.3.2 + 4.4-alpha1 4.3.3 1.1.3 2.4