hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
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 GMT
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<DefaultNHttpServerConnection> 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<DefaultNHttpServerConnection> 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<Long> {

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<DefaultNHttpServerConnection> 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 @@
   <properties>
     <maven.compiler.source>1.6</maven.compiler.source>
     <maven.compiler.target>1.6</maven.compiler.target>
-    <httpcore.version>4.3.2</httpcore.version>
+    <httpcore.version>4.4-alpha1</httpcore.version>
     <httpclient.version>4.3.3</httpclient.version>
     <commons-logging.version>1.1.3</commons-logging.version>
     <commons-io.version>2.4</commons-io.version>



Mime
View raw message