hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1164868 - in /httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http: ./ impl/nio/reactor/ nio/protocol/ testserver/
Date Sat, 03 Sep 2011 14:31:00 GMT
Author: olegk
Date: Sat Sep  3 14:30:59 2011
New Revision: 1164868

URL: http://svn.apache.org/viewvc?rev=1164868&view=rev
Log:
Eliminated SSL specific test server / client classes

Added:
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/SSLTestContexts.java
      - copied, changed from r1164865, httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/HttpSSLServer.java
Modified:
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOSSLTestBase.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOTestBase.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestBaseIOReactorSSL.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactors.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactorsSSL.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestAsyncNHttpHandlers.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBufferingNHttpHandlers.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncHandlers.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestNIOSSLHttp.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestThrottlingNHttpHandlers.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestTruncatedChunks.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/HttpClientNio.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/HttpSSLClient.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/HttpSSLServer.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/HttpServerNio.java

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOSSLTestBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOSSLTestBase.java?rev=1164868&r1=1164867&r2=1164868&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOSSLTestBase.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOSSLTestBase.java Sat Sep  3 14:30:59 2011
@@ -27,12 +27,15 @@
 
 package org.apache.http;
 
+import org.apache.http.impl.nio.SSLNHttpClientConnectionFactory;
+import org.apache.http.impl.nio.SSLNHttpServerConnectionFactory;
 import org.apache.http.params.CoreConnectionPNames;
 import org.apache.http.params.CoreProtocolPNames;
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.SyncBasicHttpParams;
-import org.apache.http.testserver.HttpSSLClient;
-import org.apache.http.testserver.HttpSSLServer;
+import org.apache.http.testserver.HttpClientNio;
+import org.apache.http.testserver.HttpServerNio;
+import org.apache.http.testserver.SSLTestContexts;
 import org.junit.After;
 import org.junit.Before;
 
@@ -41,35 +44,37 @@ import org.junit.Before;
  */
 public class HttpCoreNIOSSLTestBase {
 
-    protected HttpSSLServer server;
-    protected HttpSSLClient client;
+    protected HttpParams serverParams;
+    protected HttpParams clientParams;
+    protected HttpServerNio server;
+    protected HttpClientNio client;
 
     @Before
     public void initServer() throws Exception {
-        HttpParams serverParams = new SyncBasicHttpParams();
-        serverParams
+        this.serverParams = new SyncBasicHttpParams();
+        this.serverParams
             .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 120000)
             .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024)
             .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false)
             .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true)
             .setParameter(CoreProtocolPNames.ORIGIN_SERVER, "TEST-SERVER/1.1");
-
-        this.server = new HttpSSLServer(serverParams);
+        this.server = new HttpServerNio(new SSLNHttpServerConnectionFactory(
+                SSLTestContexts.createServerSSLContext(), null, this.serverParams));
         this.server.setExceptionHandler(new SimpleIOReactorExceptionHandler());
     }
 
     @Before
     public void initClient() throws Exception {
-        HttpParams clientParams = new SyncBasicHttpParams();
-        clientParams
+        this.clientParams = new SyncBasicHttpParams();
+        this.clientParams
             .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 120000)
             .setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 120000)
             .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024)
             .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false)
             .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true)
             .setParameter(CoreProtocolPNames.USER_AGENT, "TEST-CLIENT/1.1");
-
-        this.client = new HttpSSLClient(clientParams);
+        this.client = new HttpClientNio(new SSLNHttpClientConnectionFactory(
+                SSLTestContexts.createClientSSLContext(), null, this.clientParams));
         this.client.setExceptionHandler(new SimpleIOReactorExceptionHandler());
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOTestBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOTestBase.java?rev=1164868&r1=1164867&r2=1164868&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOTestBase.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOTestBase.java Sat Sep  3 14:30:59 2011
@@ -27,6 +27,8 @@
 
 package org.apache.http;
 
+import org.apache.http.impl.nio.DefaultNHttpClientConnectionFactory;
+import org.apache.http.impl.nio.DefaultNHttpServerConnectionFactory;
 import org.apache.http.params.CoreConnectionPNames;
 import org.apache.http.params.CoreProtocolPNames;
 import org.apache.http.params.HttpParams;
@@ -42,27 +44,28 @@ import org.junit.Before;
  */
 public class HttpCoreNIOTestBase {
 
+    protected HttpParams serverParams;
+    protected HttpParams clientParams;
     protected HttpServerNio server;
     protected HttpClientNio client;
 
     @Before
     public void initServer() throws Exception {
-        HttpParams serverParams = new SyncBasicHttpParams();
-        serverParams
+        this.serverParams = new SyncBasicHttpParams();
+        this.serverParams
             .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 60000)
             .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024)
             .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false)
             .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true)
             .setParameter(CoreProtocolPNames.ORIGIN_SERVER, "TEST-SERVER/1.1");
-
-        this.server = new HttpServerNio(serverParams);
+        this.server = new HttpServerNio(new DefaultNHttpServerConnectionFactory(this.serverParams));
         this.server.setExceptionHandler(new SimpleIOReactorExceptionHandler());
     }
 
     @Before
     public void initClient() throws Exception {
-        HttpParams clientParams = new SyncBasicHttpParams();
-        clientParams
+        this.clientParams = new SyncBasicHttpParams();
+        this.clientParams
             .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 60000)
             .setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 60000)
             .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024)
@@ -70,7 +73,7 @@ public class HttpCoreNIOTestBase {
             .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true)
             .setParameter(CoreProtocolPNames.USER_AGENT, "TEST-CLIENT/1.1");
 
-        this.client = new HttpClientNio(clientParams);
+        this.client = new HttpClientNio(new DefaultNHttpClientConnectionFactory(this.clientParams));
         this.client.setExceptionHandler(new SimpleIOReactorExceptionHandler());
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestBaseIOReactorSSL.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestBaseIOReactorSSL.java?rev=1164868&r1=1164867&r2=1164868&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestBaseIOReactorSSL.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestBaseIOReactorSSL.java Sat Sep  3 14:30:59 2011
@@ -45,6 +45,7 @@ import org.apache.http.HttpResponse;
 import org.apache.http.HttpResponseInterceptor;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.DefaultHttpResponseFactory;
+import org.apache.http.impl.nio.SSLNHttpServerConnectionFactory;
 import org.apache.http.nio.NHttpServiceHandler;
 import org.apache.http.nio.protocol.BufferingHttpServiceHandler;
 import org.apache.http.nio.protocol.EventListener;
@@ -62,7 +63,8 @@ import org.apache.http.protocol.Response
 import org.apache.http.protocol.ResponseContent;
 import org.apache.http.protocol.ResponseDate;
 import org.apache.http.protocol.ResponseServer;
-import org.apache.http.testserver.HttpSSLServer;
+import org.apache.http.testserver.HttpServerNio;
+import org.apache.http.testserver.SSLTestContexts;
 import org.apache.http.testserver.SimpleHttpRequestHandlerResolver;
 import org.junit.After;
 import org.junit.Assert;
@@ -71,19 +73,20 @@ import org.junit.Test;
 
 public class TestBaseIOReactorSSL {
 
-    private HttpSSLServer server;
+    private HttpParams serverParams;
+    private HttpServerNio server;
 
     @Before
     public void initServer() throws Exception {
-        HttpParams serverParams = new SyncBasicHttpParams();
-        serverParams
+        this.serverParams = new SyncBasicHttpParams();
+        this.serverParams
             .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 5000)
             .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 10)
             .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false)
             .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true)
             .setParameter(CoreProtocolPNames.ORIGIN_SERVER, "TEST-SERVER/1.1");
-
-        this.server = new HttpSSLServer(serverParams);
+        this.server = new HttpServerNio(new SSLNHttpServerConnectionFactory(
+                SSLTestContexts.createServerSSLContext(), null, this.serverParams));
     }
 
     @After
@@ -107,7 +110,7 @@ public class TestBaseIOReactorSSL {
                 httpproc,
                 new DefaultHttpResponseFactory(),
                 new DefaultConnectionReuseStrategy(),
-                this.server.getParams());
+                this.serverParams);
 
         serviceHandler.setHandlerResolver(
                 new SimpleHttpRequestHandlerResolver(requestHandler));

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactors.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactors.java?rev=1164868&r1=1164867&r2=1164868&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactors.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactors.java Sat Sep  3 14:30:59 2011
@@ -156,7 +156,7 @@ public class TestDefaultIOReactors exten
                 serverHttpProc,
                 new DefaultHttpResponseFactory(),
                 new DefaultConnectionReuseStrategy(),
-                this.server.getParams());
+                this.serverParams);
 
         serviceHandler.setHandlerResolver(
                 new SimpleHttpRequestHandlerResolver(requestHandler));
@@ -190,7 +190,7 @@ public class TestDefaultIOReactors exten
                 clientHttpProc,
                 requestExecutionHandler,
                 new DefaultConnectionReuseStrategy(),
-                this.client.getParams());
+                this.clientParams);
 
         clientHandler.setEventListener(
                 clientEventListener);
@@ -282,7 +282,7 @@ public class TestDefaultIOReactors exten
                 serverHttpProc,
                 new DefaultHttpResponseFactory(),
                 new DefaultConnectionReuseStrategy(),
-                this.server.getParams());
+                this.serverParams);
 
         serviceHandler.setHandlerResolver(
                 new SimpleHttpRequestHandlerResolver(requestHandler));
@@ -300,7 +300,7 @@ public class TestDefaultIOReactors exten
                 clientHttpProc,
                 requestExecutionHandler,
                 new DefaultConnectionReuseStrategy(),
-                this.client.getParams());
+                this.clientParams);
 
         clientHandler.setEventListener(
                 new SimpleEventListener());
@@ -399,7 +399,7 @@ public class TestDefaultIOReactors exten
                 serverHttpProc,
                 new DefaultHttpResponseFactory(),
                 new DefaultConnectionReuseStrategy(),
-                this.server.getParams());
+                this.serverParams);
 
         serviceHandler.setHandlerResolver(
                 new SimpleHttpRequestHandlerResolver(requestHandler));
@@ -417,7 +417,7 @@ public class TestDefaultIOReactors exten
                 clientHttpProc,
                 requestExecutionHandler,
                 new DefaultConnectionReuseStrategy(),
-                this.client.getParams());
+                this.clientParams);
 
         this.server.setExceptionHandler(exceptionHandler);
         this.server.start(serviceHandler);
@@ -517,7 +517,7 @@ public class TestDefaultIOReactors exten
                 serverHttpProc,
                 new DefaultHttpResponseFactory(),
                 new DefaultConnectionReuseStrategy(),
-                this.server.getParams());
+                this.serverParams);
 
         serviceHandler.setHandlerResolver(
                 new SimpleHttpRequestHandlerResolver(requestHandler));
@@ -535,7 +535,7 @@ public class TestDefaultIOReactors exten
                 clientHttpProc,
                 requestExecutionHandler,
                 new DefaultConnectionReuseStrategy(),
-                this.client.getParams());
+                this.clientParams);
 
         this.server.setExceptionHandler(exceptionHandler);
 

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactorsSSL.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactorsSSL.java?rev=1164868&r1=1164867&r2=1164868&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactorsSSL.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactorsSSL.java Sat Sep  3 14:30:59 2011
@@ -153,7 +153,7 @@ public class TestDefaultIOReactorsSSL ex
                 serverHttpProc,
                 new DefaultHttpResponseFactory(),
                 new DefaultConnectionReuseStrategy(),
-                this.server.getParams());
+                this.serverParams);
 
         serviceHandler.setHandlerResolver(
                 new SimpleHttpRequestHandlerResolver(requestHandler));
@@ -187,7 +187,7 @@ public class TestDefaultIOReactorsSSL ex
                 clientHttpProc,
                 requestExecutionHandler,
                 new DefaultConnectionReuseStrategy(),
-                this.client.getParams());
+                this.serverParams);
 
         clientHandler.setEventListener(
                 clientEventListener);

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestAsyncNHttpHandlers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestAsyncNHttpHandlers.java?rev=1164868&r1=1164867&r2=1164868&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestAsyncNHttpHandlers.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestAsyncNHttpHandlers.java Sat Sep  3 14:30:59 2011
@@ -103,7 +103,7 @@ public class TestAsyncNHttpHandlers exte
                 serverHttpProc,
                 new DefaultHttpResponseFactory(),
                 new DefaultConnectionReuseStrategy(),
-                this.server.getParams());
+                this.serverParams);
 
         serviceHandler.setHandlerResolver(
                 new SimpleNHttpRequestHandlerResolver(requestHandler));
@@ -121,7 +121,7 @@ public class TestAsyncNHttpHandlers exte
                 clientHttpProc,
                 requestExecutionHandler,
                 new DefaultConnectionReuseStrategy(),
-                this.client.getParams());
+                this.clientParams);
 
         clientHandler.setEventListener(
                 new SimpleEventListener());
@@ -354,7 +354,7 @@ public class TestAsyncNHttpHandlers exte
                 serverHttpProc,
                 new DefaultHttpResponseFactory(),
                 new DefaultConnectionReuseStrategy(),
-                this.server.getParams());
+                this.serverParams);
 
         serviceHandler.setHandlerResolver(
                 new SimpleNHttpRequestHandlerResolver(new RequestHandler()));
@@ -374,7 +374,7 @@ public class TestAsyncNHttpHandlers exte
                 clientHttpProc,
                 requestExecutionHandler,
                 new DefaultConnectionReuseStrategy(),
-                this.client.getParams());
+                this.clientParams);
 
         clientHandler.setEventListener(new SimpleEventListener());
 
@@ -451,7 +451,7 @@ public class TestAsyncNHttpHandlers exte
                 serverHttpProc,
                 new DefaultHttpResponseFactory(),
                 new DefaultConnectionReuseStrategy(),
-                this.server.getParams());
+                this.serverParams);
 
         serviceHandler.setHandlerResolver(
                 new SimpleNHttpRequestHandlerResolver(new RequestHandler()));
@@ -469,7 +469,7 @@ public class TestAsyncNHttpHandlers exte
                 clientHttpProc,
                 requestExecutionHandler,
                 new DefaultConnectionReuseStrategy(),
-                this.client.getParams());
+                this.clientParams);
 
         clientHandler.setEventListener(new SimpleEventListener());
 
@@ -632,7 +632,7 @@ public class TestAsyncNHttpHandlers exte
                 serverHttpProc,
                 new DefaultHttpResponseFactory(),
                 new DefaultConnectionReuseStrategy(),
-                this.server.getParams());
+                this.serverParams);
 
         serviceHandler.setHandlerResolver(
                 new SimpleNHttpRequestHandlerResolver(requestHandler));
@@ -650,7 +650,7 @@ public class TestAsyncNHttpHandlers exte
                 clientHttpProc,
                 requestExecutionHandler,
                 new DefaultConnectionReuseStrategy(),
-                this.client.getParams());
+                this.clientParams);
 
         clientHandler.setEventListener(new SimpleEventListener());
 
@@ -754,7 +754,7 @@ public class TestAsyncNHttpHandlers exte
                 serverHttpProc,
                 new DefaultHttpResponseFactory(),
                 new DefaultConnectionReuseStrategy(),
-                this.server.getParams());
+                this.serverParams);
 
         serviceHandler.setHandlerResolver(
                 new SimpleNHttpRequestHandlerResolver(requestHandler));
@@ -772,7 +772,7 @@ public class TestAsyncNHttpHandlers exte
                 clientHttpProc,
                 requestExecutionHandler,
                 new DefaultConnectionReuseStrategy(),
-                this.client.getParams());
+                this.clientParams);
 
         clientHandler.setEventListener(new SimpleEventListener());
 
@@ -852,7 +852,7 @@ public class TestAsyncNHttpHandlers exte
                 serverHttpProc,
                 new DefaultHttpResponseFactory(),
                 new DefaultConnectionReuseStrategy(),
-                this.server.getParams());
+                this.serverParams);
 
         serviceHandler.setEventListener(
                 new SimpleEventListener());
@@ -868,7 +868,7 @@ public class TestAsyncNHttpHandlers exte
                 clientHttpProc,
                 requestExecutionHandler,
                 new DefaultConnectionReuseStrategy(),
-                this.client.getParams());
+                this.clientParams);
 
         clientHandler.setEventListener(new SimpleEventListener());
 
@@ -954,7 +954,7 @@ public class TestAsyncNHttpHandlers exte
                 serverHttpProc,
                 new DefaultHttpResponseFactory(),
                 new DefaultConnectionReuseStrategy(),
-                this.server.getParams());
+                this.serverParams);
 
         serviceHandler.setHandlerResolver(
                 new SimpleNHttpRequestHandlerResolver(new RequestHandler()));
@@ -972,7 +972,7 @@ public class TestAsyncNHttpHandlers exte
                 clientHttpProc,
                 requestExecutionHandler,
                 new DefaultConnectionReuseStrategy(),
-                this.client.getParams());
+                this.clientParams);
 
         clientHandler.setEventListener(new SimpleEventListener());
 
@@ -1053,7 +1053,7 @@ public class TestAsyncNHttpHandlers exte
                 serverHttpProc,
                 new DefaultHttpResponseFactory(),
                 new DefaultConnectionReuseStrategy(),
-                this.server.getParams());
+                this.serverParams);
 
         serviceHandler.setHandlerResolver(
                 new SimpleNHttpRequestHandlerResolver(null));
@@ -1071,7 +1071,7 @@ public class TestAsyncNHttpHandlers exte
                 clientHttpProc,
                 requestExecutionHandler,
                 new DefaultConnectionReuseStrategy(),
-                this.client.getParams());
+                this.clientParams);
 
         clientHandler.setEventListener(new SimpleEventListener());
 

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBufferingNHttpHandlers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBufferingNHttpHandlers.java?rev=1164868&r1=1164867&r2=1164868&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBufferingNHttpHandlers.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBufferingNHttpHandlers.java Sat Sep  3 14:30:59 2011
@@ -97,7 +97,7 @@ public class TestBufferingNHttpHandlers 
                 serverHttpProc,
                 new DefaultHttpResponseFactory(),
                 new DefaultConnectionReuseStrategy(),
-                this.server.getParams());
+                this.serverParams);
 
         serviceHandler.setHandlerResolver(
                 new SimpleHttpRequestHandlerResolver(requestHandler));
@@ -115,7 +115,7 @@ public class TestBufferingNHttpHandlers 
                 clientHttpProc,
                 requestExecutionHandler,
                 new DefaultConnectionReuseStrategy(),
-                this.client.getParams());
+                this.clientParams);
 
         clientHandler.setEventListener(
                 new SimpleEventListener());

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncHandlers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncHandlers.java?rev=1164868&r1=1164867&r2=1164868&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncHandlers.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncHandlers.java Sat Sep  3 14:30:59 2011
@@ -108,7 +108,7 @@ public class TestHttpAsyncHandlers exten
                 new BasicHttpAsyncRequestHandlerResolver(requestHandler),
                 serverHttpProc,
                 new DefaultConnectionReuseStrategy(),
-                this.server.getParams());
+                this.serverParams);
 
         HttpProcessor clientHttpProc = new ImmutableHttpProcessor(new HttpRequestInterceptor[] {
                 new RequestContent(),
@@ -121,7 +121,7 @@ public class TestHttpAsyncHandlers exten
                 clientHttpProc,
                 requestExecutionHandler,
                 new DefaultConnectionReuseStrategy(),
-                this.client.getParams());
+                this.clientParams);
 
         clientHandler.setEventListener(
                 new SimpleEventListener());

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestNIOSSLHttp.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestNIOSSLHttp.java?rev=1164868&r1=1164867&r2=1164868&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestNIOSSLHttp.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestNIOSSLHttp.java Sat Sep  3 14:30:59 2011
@@ -95,7 +95,7 @@ public class TestNIOSSLHttp extends Http
                 serverHttpProc,
                 new DefaultHttpResponseFactory(),
                 new DefaultConnectionReuseStrategy(),
-                this.server.getParams());
+                this.serverParams);
 
         serviceHandler.setHandlerResolver(
                 new SimpleNHttpRequestHandlerResolver(requestHandler));
@@ -113,7 +113,7 @@ public class TestNIOSSLHttp extends Http
                 clientHttpProc,
                 requestExecutionHandler,
                 new DefaultConnectionReuseStrategy(),
-                this.client.getParams());
+                this.clientParams);
 
         clientHandler.setEventListener(
                 new SimpleEventListener());

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestThrottlingNHttpHandlers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestThrottlingNHttpHandlers.java?rev=1164868&r1=1164867&r2=1164868&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestThrottlingNHttpHandlers.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestThrottlingNHttpHandlers.java Sat Sep  3 14:30:59 2011
@@ -30,20 +30,13 @@ package org.apache.http.nio.protocol;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.PipedInputStream;
-import java.io.PipedOutputStream;
 import java.io.UnsupportedEncodingException;
 import java.net.InetSocketAddress;
-import java.util.Collections;
-import java.util.HashMap;
 import java.util.LinkedList;
-import java.util.Map;
 import java.util.Queue;
 import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.Executor;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
 
 import org.apache.http.HttpCoreNIOTestBase;
 import org.apache.http.HttpEntity;
@@ -56,7 +49,6 @@ import org.apache.http.HttpResponseInter
 import org.apache.http.HttpStatus;
 import org.apache.http.HttpVersion;
 import org.apache.http.entity.ContentType;
-import org.apache.http.entity.InputStreamEntity;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.DefaultHttpResponseFactory;
@@ -67,7 +59,6 @@ import org.apache.http.nio.entity.NStrin
 import org.apache.http.nio.reactor.IOReactorStatus;
 import org.apache.http.nio.reactor.ListenerEndpoint;
 import org.apache.http.nio.reactor.SessionRequest;
-import org.apache.http.params.CoreConnectionPNames;
 import org.apache.http.params.CoreProtocolPNames;
 import org.apache.http.protocol.HTTP;
 import org.apache.http.protocol.HttpContext;
@@ -90,7 +81,6 @@ import org.apache.http.util.EncodingUtil
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 
 /**
@@ -138,7 +128,7 @@ public class TestThrottlingNHttpHandlers
                 new DefaultHttpResponseFactory(),
                 new DefaultConnectionReuseStrategy(),
                 this.execService,
-                this.server.getParams());
+                this.serverParams);
 
         serviceHandler.setHandlerResolver(
                 new SimpleHttpRequestHandlerResolver(requestHandler));
@@ -157,7 +147,7 @@ public class TestThrottlingNHttpHandlers
                 requestExecutionHandler,
                 new DefaultConnectionReuseStrategy(),
                 this.execService,
-                this.client.getParams());
+                this.clientParams);
 
         clientHandler.setEventListener(
                 new SimpleEventListener());
@@ -273,171 +263,6 @@ public class TestThrottlingNHttpHandlers
     }
 
     /**
-     * This test ensures that an Executor instance
-     * (under the control of a ThrottlingHttpServiceHandler)
-     * terminates when a connection timeout occurs.
-     */
-    @Test @Ignore
-    public void testExecutorTermination() throws Exception {
-        final int SHORT_TIMEOUT = 100;
-        final int DEFAULT_SERVER_SO_TIMEOUT = 60000;
-        this.server.getParams().setIntParameter(
-                CoreConnectionPNames.SO_TIMEOUT, SHORT_TIMEOUT);
-
-        // main expectation: the executor spawned by the service must finish.
-        final String COMMAND_FINISHED = "CommandFinished";
-        final Map<String, Boolean> serverExpectations = Collections.synchronizedMap(
-                new HashMap<String, Boolean>());
-        serverExpectations.put(COMMAND_FINISHED, Boolean.FALSE);
-
-        // secondary expectation: not strictly necessary, the test will wait for the
-        // client to finalize the request
-        final String CLIENT_FINALIZED = "ClientFinalized";
-        final Map<String, Boolean> clientExpectations = Collections.synchronizedMap(
-                new HashMap<String, Boolean>());
-        clientExpectations.put(CLIENT_FINALIZED, Boolean.FALSE);
-
-        // runs the command on a separate thread and updates the server expectation
-        Executor executor = new Executor() {
-
-            public void execute(final Runnable command) {
-                new Thread() {
-                    @Override
-                    public void run() {
-                        command.run();
-                        synchronized (serverExpectations) {
-                            serverExpectations.put(COMMAND_FINISHED, Boolean.TRUE);
-                            serverExpectations.notify();
-                        }
-                    }
-                }.start();
-            }
-
-        };
-
-        HttpRequestHandler requestHandler = new HttpRequestHandler() {
-            public void handle(
-                    HttpRequest request,
-                    HttpResponse response,
-                    HttpContext context) {
-                try {
-                    ((HttpEntityEnclosingRequest) request).getEntity().getContent().read();
-                    response.setStatusCode(HttpStatus.SC_OK);
-                } catch (Exception e){
-                }
-            }
-        };
-
-        // convoluted client-side entity content. The byte expected by the HttpRequest will not
-        // be written.
-        final PipedOutputStream pipe = new PipedOutputStream();
-        final PipedInputStream producer = new PipedInputStream(pipe);
-        pipe.close();
-
-        // A POST request enclosing an entity with (supposedly) a content length of 1 byte.
-        // the connection will be closed at the end of the request.
-        HttpRequestExecutionHandler requestExecutionHandler = new HttpRequestExecutionHandler() {
-            public void initalizeContext(final HttpContext context, final Object attachment) {
-            }
-
-            public void finalizeContext(HttpContext context) {
-                synchronized (clientExpectations) {
-                    clientExpectations.put(CLIENT_FINALIZED, Boolean.TRUE);
-                    clientExpectations.notifyAll();
-                }
-            }
-
-            public HttpRequest submitRequest( HttpContext context ) {
-                HttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/");
-                post.setHeader( "Connection", "Close" );
-                post.setEntity(new InputStreamEntity(producer, 1));
-                return post;
-            }
-
-            public void handleResponse(final HttpResponse response, final HttpContext context) {
-            }
-
-        };
-
-        HttpProcessor serverHttpProc = new ImmutableHttpProcessor(new HttpResponseInterceptor[] {
-                new ResponseDate(),
-                new ResponseServer(),
-                new ResponseContent(),
-                new ResponseConnControl()
-        });
-
-        ThrottlingHttpServiceHandler serviceHandler = new ThrottlingHttpServiceHandler(
-                serverHttpProc,
-                new DefaultHttpResponseFactory(),
-                new DefaultConnectionReuseStrategy(),
-                executor,
-                this.server.getParams());
-
-        serviceHandler.setHandlerResolver(
-                new SimpleHttpRequestHandlerResolver(requestHandler));
-        serviceHandler.setEventListener(
-                new SimpleEventListener());
-
-        HttpProcessor clientHttpProc = new ImmutableHttpProcessor(new HttpRequestInterceptor[] {
-                new RequestContent(),
-                new RequestTargetHost(),
-                new RequestConnControl(),
-                new RequestUserAgent(),
-                new RequestExpectContinue()});
-
-        ThrottlingHttpClientHandler clientHandler = new ThrottlingHttpClientHandler(
-                clientHttpProc,
-                requestExecutionHandler,
-                new DefaultConnectionReuseStrategy(),
-                this.execService,
-                this.client.getParams());
-
-        clientHandler.setEventListener(
-                new SimpleEventListener());
-
-        this.server.start(serviceHandler);
-        this.client.start(clientHandler);
-
-        ListenerEndpoint endpoint = this.server.getListenerEndpoint();
-        endpoint.waitFor();
-        InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
-
-        Assert.assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
-
-        SessionRequest sessionRequest = this.client.openConnection(
-                new InetSocketAddress("localhost", serverAddress.getPort()),
-                null);
-
-        sessionRequest.waitFor();
-        if (sessionRequest.getException() != null) {
-            throw sessionRequest.getException();
-        }
-        Assert.assertNotNull(sessionRequest.getSession());
-
-        Assert.assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
-
-        // wait for the client to invoke finalizeContext().
-        synchronized (clientExpectations) {
-            if (!clientExpectations.get(CLIENT_FINALIZED).booleanValue()) {
-                clientExpectations.wait(DEFAULT_SERVER_SO_TIMEOUT);
-                Assert.assertTrue(clientExpectations.get(CLIENT_FINALIZED).booleanValue());
-            }
-        }
-
-        // wait for server to finish the command within a reasonable amount of time.
-        // the time constraint is not necessary, it only prevents the test from hanging.
-        synchronized (serverExpectations) {
-            if (!serverExpectations.get(COMMAND_FINISHED).booleanValue()) {
-                serverExpectations.wait(SHORT_TIMEOUT);
-                Assert.assertTrue(serverExpectations.get(COMMAND_FINISHED).booleanValue());
-            }
-        }
-
-        this.execService.shutdown();
-        this.execService.awaitTermination(10, TimeUnit.SECONDS);
-    }
-
-    /**
      * This test case executes a series of simple (non-pipelined) HTTP/1.0
      * POST requests over multiple persistent connections.
      */
@@ -551,7 +376,7 @@ public class TestThrottlingNHttpHandlers
                 new DefaultHttpResponseFactory(),
                 new DefaultConnectionReuseStrategy(),
                 this.execService,
-                this.server.getParams());
+                this.serverParams);
 
         serviceHandler.setHandlerResolver(
                 new SimpleHttpRequestHandlerResolver(new RequestHandler()));
@@ -572,7 +397,7 @@ public class TestThrottlingNHttpHandlers
                 requestExecutionHandler,
                 new DefaultConnectionReuseStrategy(),
                 this.execService,
-                this.client.getParams());
+                this.clientParams);
 
         clientHandler.setEventListener(
                 new SimpleEventListener());
@@ -651,7 +476,7 @@ public class TestThrottlingNHttpHandlers
                 new DefaultHttpResponseFactory(),
                 new DefaultConnectionReuseStrategy(),
                 this.execService,
-                this.server.getParams());
+                this.serverParams);
 
         serviceHandler.setHandlerResolver(
                 new SimpleHttpRequestHandlerResolver(new RequestHandler()));
@@ -670,7 +495,7 @@ public class TestThrottlingNHttpHandlers
                 requestExecutionHandler,
                 new DefaultConnectionReuseStrategy(),
                 this.execService,
-                this.client.getParams());
+                this.clientParams);
 
         clientHandler.setEventListener(new SimpleEventListener());
 
@@ -773,7 +598,7 @@ public class TestThrottlingNHttpHandlers
                 new DefaultHttpResponseFactory(),
                 new DefaultConnectionReuseStrategy(),
                 this.execService,
-                this.server.getParams());
+                this.serverParams);
 
         serviceHandler.setHandlerResolver(
                 new SimpleHttpRequestHandlerResolver(requestHandler));
@@ -792,7 +617,7 @@ public class TestThrottlingNHttpHandlers
                 requestExecutionHandler,
                 new DefaultConnectionReuseStrategy(),
                 this.execService,
-                this.client.getParams());
+                this.clientParams);
 
         clientHandler.setEventListener(
                 new SimpleEventListener());
@@ -941,7 +766,7 @@ public class TestThrottlingNHttpHandlers
                 new DefaultHttpResponseFactory(),
                 new DefaultConnectionReuseStrategy(),
                 this.execService,
-                this.server.getParams());
+                this.serverParams);
 
         serviceHandler.setHandlerResolver(
                 new SimpleHttpRequestHandlerResolver(new RequestHandler()));
@@ -960,7 +785,7 @@ public class TestThrottlingNHttpHandlers
                 requestExecutionHandler,
                 new DefaultConnectionReuseStrategy(),
                 this.execService,
-                this.client.getParams());
+                this.clientParams);
 
         clientHandler.setEventListener(
                 new SimpleEventListener());

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestTruncatedChunks.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestTruncatedChunks.java?rev=1164868&r1=1164867&r2=1164868&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestTruncatedChunks.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestTruncatedChunks.java Sat Sep  3 14:30:59 2011
@@ -50,9 +50,9 @@ import org.apache.http.entity.HttpEntity
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.DefaultHttpResponseFactory;
 import org.apache.http.impl.io.HttpTransportMetricsImpl;
+import org.apache.http.impl.nio.DefaultNHttpClientConnectionFactory;
 import org.apache.http.impl.nio.DefaultNHttpServerConnection;
 import org.apache.http.impl.nio.DefaultNHttpServerConnectionFactory;
-import org.apache.http.impl.nio.DefaultServerIODispatch;
 import org.apache.http.impl.nio.codecs.AbstractContentEncoder;
 import org.apache.http.message.BasicHttpRequest;
 import org.apache.http.nio.ContentDecoder;
@@ -60,10 +60,8 @@ import org.apache.http.nio.ContentEncode
 import org.apache.http.nio.IOControl;
 import org.apache.http.nio.NHttpConnection;
 import org.apache.http.nio.NHttpServerIOTarget;
-import org.apache.http.nio.NHttpServiceHandler;
 import org.apache.http.nio.entity.ConsumingNHttpEntity;
 import org.apache.http.nio.entity.ContentInputStream;
-import org.apache.http.nio.reactor.IOEventDispatch;
 import org.apache.http.nio.reactor.IOSession;
 import org.apache.http.nio.reactor.ListenerEndpoint;
 import org.apache.http.nio.reactor.SessionOutputBuffer;
@@ -178,48 +176,34 @@ public class TestTruncatedChunks {
 
     }
 
-    static class CustomTestHttpServer extends HttpServerNio {
-
-        public CustomTestHttpServer(final HttpParams params) throws IOException {
-            super(params);
-        }
-
-        @Override
-        protected IOEventDispatch createIOEventDispatch(
-                NHttpServiceHandler serviceHandler, HttpParams params) {
-            return new DefaultServerIODispatch(serviceHandler, new CustomServerConnectionFactory(params));
-        }
-
-    }
-
-    protected CustomTestHttpServer server;
+    protected HttpParams serverParams;
+    protected HttpParams clientParams;
+    protected HttpServerNio server;
     protected HttpClientNio client;
 
     @Before
     public void initServer() throws Exception {
-        HttpParams serverParams = new SyncBasicHttpParams();
-        serverParams
+        this.serverParams = new SyncBasicHttpParams();
+        this.serverParams
             .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 60000)
             .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024)
             .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false)
             .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true)
             .setParameter(CoreProtocolPNames.ORIGIN_SERVER, "TEST-SERVER/1.1");
-
-        this.server = new CustomTestHttpServer(serverParams);
+        this.server = new HttpServerNio(new CustomServerConnectionFactory(this.serverParams));
     }
 
     @Before
     public void initClient() throws Exception {
-        HttpParams clientParams = new SyncBasicHttpParams();
-        clientParams
+        this.clientParams = new SyncBasicHttpParams();
+        this.clientParams
             .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 60000)
             .setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 30000)
             .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024)
             .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false)
             .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true)
             .setParameter(CoreProtocolPNames.USER_AGENT, "TEST-CLIENT/1.1");
-
-        this.client = new HttpClientNio(clientParams);
+        this.client = new HttpClientNio(new DefaultNHttpClientConnectionFactory(this.clientParams));
     }
 
     @After
@@ -264,7 +248,7 @@ public class TestTruncatedChunks {
                 serverHttpProc,
                 new DefaultHttpResponseFactory(),
                 new DefaultConnectionReuseStrategy(),
-                this.server.getParams());
+                this.serverParams);
 
         serviceHandler.setHandlerResolver(
                 new SimpleNHttpRequestHandlerResolver(new RequestHandler(true)));
@@ -282,7 +266,7 @@ public class TestTruncatedChunks {
                 clientHttpProc,
                 requestExecutionHandler,
                 new DefaultConnectionReuseStrategy(),
-                this.client.getParams());
+                this.clientParams);
 
         clientHandler.setEventListener(
                 new SimpleEventListener() {
@@ -426,7 +410,7 @@ public class TestTruncatedChunks {
                 serverHttpProc,
                 new DefaultHttpResponseFactory(),
                 new DefaultConnectionReuseStrategy(),
-                this.server.getParams());
+                this.serverParams);
 
         serviceHandler.setHandlerResolver(
                 new SimpleNHttpRequestHandlerResolver(new RequestHandler(true)));
@@ -444,7 +428,7 @@ public class TestTruncatedChunks {
                 clientHttpProc,
                 requestExecutionHandler,
                 new DefaultConnectionReuseStrategy(),
-                this.client.getParams());
+                this.clientParams);
 
         clientHandler.setEventListener(
                 new SimpleEventListener());

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/HttpClientNio.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/HttpClientNio.java?rev=1164868&r1=1164867&r2=1164868&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/HttpClientNio.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/HttpClientNio.java Sat Sep  3 14:30:59 2011
@@ -35,6 +35,8 @@ import org.apache.http.impl.nio.DefaultC
 import org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor;
 import org.apache.http.impl.nio.reactor.ExceptionEvent;
 import org.apache.http.nio.NHttpClientHandler;
+import org.apache.http.nio.NHttpClientIOTarget;
+import org.apache.http.nio.NHttpConnectionFactory;
 import org.apache.http.nio.reactor.IOEventDispatch;
 import org.apache.http.nio.reactor.IOReactorExceptionHandler;
 import org.apache.http.nio.reactor.IOReactorStatus;
@@ -44,18 +46,15 @@ import org.apache.http.params.HttpParams
 public class HttpClientNio {
 
     private final DefaultConnectingIOReactor ioReactor;
-    private final HttpParams params;
+    private final NHttpConnectionFactory<NHttpClientIOTarget> connFactory;
 
     private volatile IOReactorThread thread;
 
-    public HttpClientNio(final HttpParams params) throws IOException {
+    public HttpClientNio(
+            final NHttpConnectionFactory<NHttpClientIOTarget> connFactory) throws IOException {
         super();
         this.ioReactor = new DefaultConnectingIOReactor();
-        this.params = params;
-    }
-
-    public HttpParams getParams() {
-        return this.params;
+        this.connFactory = connFactory;
     }
 
     public void setExceptionHandler(final IOReactorExceptionHandler exceptionHandler) {
@@ -68,10 +67,7 @@ public class HttpClientNio {
     }
 
     private void execute(final NHttpClientHandler clientHandler) throws IOException {
-        IOEventDispatch ioEventDispatch = createIOEventDispatch(
-                clientHandler,
-                this.params);
-
+        IOEventDispatch ioEventDispatch = new DefaultClientIODispatch(clientHandler, this.connFactory);
         this.ioReactor.execute(ioEventDispatch);
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/HttpServerNio.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/HttpServerNio.java?rev=1164868&r1=1164867&r2=1164868&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/HttpServerNio.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/HttpServerNio.java Sat Sep  3 14:30:59 2011
@@ -34,12 +34,13 @@ import java.util.List;
 import org.apache.http.impl.nio.DefaultServerIODispatch;
 import org.apache.http.impl.nio.reactor.DefaultListeningIOReactor;
 import org.apache.http.impl.nio.reactor.ExceptionEvent;
+import org.apache.http.nio.NHttpConnectionFactory;
+import org.apache.http.nio.NHttpServerIOTarget;
 import org.apache.http.nio.NHttpServiceHandler;
 import org.apache.http.nio.reactor.IOEventDispatch;
 import org.apache.http.nio.reactor.IOReactorExceptionHandler;
 import org.apache.http.nio.reactor.IOReactorStatus;
 import org.apache.http.nio.reactor.ListenerEndpoint;
-import org.apache.http.params.HttpParams;
 
 /**
  * Trivial test server based on HttpCore NIO
@@ -48,35 +49,24 @@ import org.apache.http.params.HttpParams
 public class HttpServerNio {
 
     private final DefaultListeningIOReactor ioReactor;
-    private final HttpParams params;
+    private final NHttpConnectionFactory<NHttpServerIOTarget> connFactory;
 
     private volatile IOReactorThread thread;
     private ListenerEndpoint endpoint;
 
-    public HttpServerNio(final HttpParams params) throws IOException {
+    public HttpServerNio(
+            final NHttpConnectionFactory<NHttpServerIOTarget> connFactory) throws IOException {
         super();
         this.ioReactor = new DefaultListeningIOReactor();
-        this.params = params;
-    }
-
-    public HttpParams getParams() {
-        return this.params;
+        this.connFactory = connFactory;
     }
 
     public void setExceptionHandler(final IOReactorExceptionHandler exceptionHandler) {
         this.ioReactor.setExceptionHandler(exceptionHandler);
     }
 
-    protected IOEventDispatch createIOEventDispatch(
-            final NHttpServiceHandler serviceHandler, final HttpParams params) {
-        return new DefaultServerIODispatch(serviceHandler, params);
-    }
-
     private void execute(final NHttpServiceHandler serviceHandler) throws IOException {
-        IOEventDispatch ioEventDispatch = createIOEventDispatch(
-                serviceHandler,
-                this.params);
-
+        IOEventDispatch ioEventDispatch = new DefaultServerIODispatch(serviceHandler, this.connFactory);
         this.ioReactor.execute(ioEventDispatch);
     }
 

Copied: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/SSLTestContexts.java (from r1164865, httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/HttpSSLServer.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/SSLTestContexts.java?p2=httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/SSLTestContexts.java&p1=httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/HttpSSLServer.java&r1=1164865&r2=1164868&rev=1164868&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/HttpSSLServer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/SSLTestContexts.java Sat Sep  3 14:30:59 2011
@@ -27,48 +27,19 @@
 
 package org.apache.http.testserver;
 
-import java.io.IOException;
-import java.net.InetSocketAddress;
 import java.net.URL;
 import java.security.KeyStore;
 import java.security.NoSuchAlgorithmException;
-import java.util.List;
 
 import javax.net.ssl.KeyManager;
 import javax.net.ssl.KeyManagerFactory;
 import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactory;
 
-import org.apache.http.impl.nio.DefaultServerIODispatch;
-import org.apache.http.impl.nio.reactor.DefaultListeningIOReactor;
-import org.apache.http.impl.nio.reactor.ExceptionEvent;
-import org.apache.http.nio.NHttpServiceHandler;
-import org.apache.http.nio.reactor.IOEventDispatch;
-import org.apache.http.nio.reactor.IOReactorExceptionHandler;
-import org.apache.http.nio.reactor.IOReactorStatus;
-import org.apache.http.nio.reactor.ListenerEndpoint;
-import org.apache.http.params.HttpParams;
-
-/**
- * Trivial test server based on HttpCore NIO SSL
- *
- */
-public class HttpSSLServer {
-
-    private final SSLContext sslcontext;
-    private final DefaultListeningIOReactor ioReactor;
-    private final HttpParams params;
-
-    private volatile IOReactorThread thread;
-    private ListenerEndpoint endpoint;
-
-    public HttpSSLServer(final HttpParams params) throws Exception {
-        super();
-        this.params = params;
-        this.sslcontext = createSSLContext();
-        this.ioReactor = new DefaultListeningIOReactor();
-    }
+public class SSLTestContexts {
 
-    private KeyManagerFactory createKeyManagerFactory() throws NoSuchAlgorithmException {
+    private static KeyManagerFactory createKeyManagerFactory() throws NoSuchAlgorithmException {
         String algo = KeyManagerFactory.getDefaultAlgorithm();
         try {
             return KeyManagerFactory.getInstance(algo);
@@ -77,8 +48,8 @@ public class HttpSSLServer {
         }
     }
 
-    protected SSLContext createSSLContext() throws Exception {
-        ClassLoader cl = getClass().getClassLoader();
+    public static SSLContext createServerSSLContext() throws Exception {
+        ClassLoader cl = SSLTestContexts.class.getClassLoader();
         URL url = cl.getResource("test.keystore");
         KeyStore keystore  = KeyStore.getInstance("jks");
         keystore.load(url.openStream(), "nopassword".toCharArray());
@@ -90,96 +61,26 @@ public class HttpSSLServer {
         return sslcontext;
     }
 
-    public HttpParams getParams() {
-        return this.params;
-    }
-
-    public IOReactorStatus getStatus() {
-        return this.ioReactor.getStatus();
-    }
-
-    public List<ExceptionEvent> getAuditLog() {
-        return this.ioReactor.getAuditLog();
-    }
-
-    public void setExceptionHandler(final IOReactorExceptionHandler exceptionHandler) {
-        this.ioReactor.setExceptionHandler(exceptionHandler);
-    }
-
-    protected IOEventDispatch createIOEventDispatch(
-            final NHttpServiceHandler serviceHandler,
-            final SSLContext sslcontext,
-            final HttpParams params) {
-        return new DefaultServerIODispatch(serviceHandler, sslcontext, null, params);
-    }
-
-    private void execute(final NHttpServiceHandler serviceHandler) throws IOException {
-        IOEventDispatch ioEventDispatch = createIOEventDispatch(
-                serviceHandler,
-                this.sslcontext,
-                this.params);
-
-        this.ioReactor.execute(ioEventDispatch);
-    }
-
-    public ListenerEndpoint getListenerEndpoint() {
-        return this.endpoint;
-    }
-
-    public void start(final NHttpServiceHandler serviceHandler) {
-        this.endpoint = this.ioReactor.listen(new InetSocketAddress(0));
-        this.thread = new IOReactorThread(serviceHandler);
-        this.thread.start();
-    }
-
-    public void join(long timeout) throws InterruptedException {
-        if (this.thread != null) {
-            this.thread.join(timeout);
-        }
-    }
-
-    public Exception getException() {
-        if (this.thread != null) {
-            return this.thread.getException();
-        } else {
-            return null;
-        }
-    }
-
-    public void shutdown() throws IOException {
-        this.ioReactor.shutdown();
+    private static TrustManagerFactory createTrustManagerFactory() throws NoSuchAlgorithmException {
+        String algo = TrustManagerFactory.getDefaultAlgorithm();
         try {
-            if (this.thread != null) {
-                this.thread.join(500);
-            }
-        } catch (InterruptedException ignore) {
+            return TrustManagerFactory.getInstance(algo);
+        } catch (NoSuchAlgorithmException ex) {
+            return TrustManagerFactory.getInstance("SunX509");
         }
     }
 
-    private class IOReactorThread extends Thread {
-
-        private final NHttpServiceHandler serviceHandler;
-
-        private volatile Exception ex;
-
-        public IOReactorThread(final NHttpServiceHandler serviceHandler) {
-            super();
-            this.serviceHandler = serviceHandler;
-        }
-
-        @Override
-        public void run() {
-            try {
-                execute(this.serviceHandler);
-            } catch (Exception ex) {
-                this.ex = ex;
-            }
-        }
-
-        public Exception getException() {
-            return this.ex;
-        }
-
+    public static SSLContext createClientSSLContext() throws Exception {
+        ClassLoader cl = SSLTestContexts.class.getClassLoader();
+        URL url = cl.getResource("test.keystore");
+        KeyStore keystore  = KeyStore.getInstance("jks");
+        keystore.load(url.openStream(), "nopassword".toCharArray());
+        TrustManagerFactory tmfactory = createTrustManagerFactory();
+        tmfactory.init(keystore);
+        TrustManager[] trustmanagers = tmfactory.getTrustManagers();
+        SSLContext sslcontext = SSLContext.getInstance("TLS");
+        sslcontext.init(null, trustmanagers, null);
+        return sslcontext;
     }
 
 }



Mime
View raw message