hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r542937 - in /jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio: mockup/TestHttpClient.java mockup/TestHttpServer.java protocol/TestNIOHttp.java
Date Wed, 30 May 2007 21:19:46 GMT
Author: olegk
Date: Wed May 30 14:19:45 2007
New Revision: 542937

URL: http://svn.apache.org/viewvc?view=rev&rev=542937
Log:
Some code cleanups in test cases

Modified:
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/mockup/TestHttpClient.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/mockup/TestHttpServer.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/protocol/TestNIOHttp.java

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/mockup/TestHttpClient.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/mockup/TestHttpClient.java?view=diff&rev=542937&r1=542936&r2=542937
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/mockup/TestHttpClient.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/mockup/TestHttpClient.java
Wed May 30 14:19:45 2007
@@ -34,7 +34,9 @@
 import java.io.IOException;
 import java.net.InetSocketAddress;
 
+import org.apache.http.impl.nio.DefaultClientIOEventDispatch;
 import org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor;
+import org.apache.http.nio.NHttpClientHandler;
 import org.apache.http.nio.reactor.ConnectingIOReactor;
 import org.apache.http.nio.reactor.IOEventDispatch;
 import org.apache.http.params.HttpParams;
@@ -56,7 +58,11 @@
         return this.params;
     }
     
-    private void execute(final IOEventDispatch ioEventDispatch) throws IOException {
+    private void execute(final NHttpClientHandler clientHandler) throws IOException {
+        IOEventDispatch ioEventDispatch = new DefaultClientIOEventDispatch(
+                clientHandler, 
+                this.params);        
+        
         this.ioReactor.execute(ioEventDispatch);
     }
     
@@ -64,8 +70,8 @@
         this.ioReactor.connect(address, null, attachment, null);
     }
  
-    public void start(final IOEventDispatch ioEventDispatch) {
-        this.thread = new IOReactorThread(ioEventDispatch);
+    public void start(final NHttpClientHandler clientHandler) {
+        this.thread = new IOReactorThread(clientHandler);
         this.thread.start();
     }
     
@@ -79,16 +85,16 @@
     
     private class IOReactorThread extends Thread {
 
-        private final IOEventDispatch ioEventDispatch;
+        private final NHttpClientHandler clientHandler;
         
-        public IOReactorThread(final IOEventDispatch ioEventDispatch) {
+        public IOReactorThread(final NHttpClientHandler clientHandler) {
             super();
-            this.ioEventDispatch = ioEventDispatch;
+            this.clientHandler = clientHandler;
         }
         
         public void run() {
             try {
-                execute(this.ioEventDispatch);
+                execute(this.clientHandler);
             } catch (IOException ex) {
                 ex.printStackTrace();
             }

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/mockup/TestHttpServer.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/mockup/TestHttpServer.java?view=diff&rev=542937&r1=542936&r2=542937
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/mockup/TestHttpServer.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/mockup/TestHttpServer.java
Wed May 30 14:19:45 2007
@@ -34,7 +34,9 @@
 import java.io.IOException;
 import java.net.InetSocketAddress;
 
+import org.apache.http.impl.nio.DefaultServerIOEventDispatch;
 import org.apache.http.impl.nio.reactor.DefaultListeningIOReactor;
+import org.apache.http.nio.NHttpServiceHandler;
 import org.apache.http.nio.reactor.IOEventDispatch;
 import org.apache.http.nio.reactor.ListeningIOReactor;
 import org.apache.http.params.HttpParams;
@@ -64,12 +66,17 @@
         return this.params;
     }
     
-    private void execute(final IOEventDispatch ioEventDispatch) throws IOException {
+    private void execute(final NHttpServiceHandler serviceHandler) throws IOException {
         synchronized (this.socketMutex) {
             this.address = (InetSocketAddress) this.ioReactor.listen(
                     new InetSocketAddress(0));
             this.socketMutex.notifyAll();
         }
+        
+        IOEventDispatch ioEventDispatch = new DefaultServerIOEventDispatch(
+                serviceHandler, 
+                this.params);
+        
         this.ioReactor.execute(ioEventDispatch);
     }
     
@@ -82,8 +89,8 @@
         return this.address;
     }
 
-    public void start(final IOEventDispatch ioEventDispatch) {
-        this.thread = new IOReactorThread(ioEventDispatch);
+    public void start(final NHttpServiceHandler serviceHandler) {
+        this.thread = new IOReactorThread(serviceHandler);
         this.thread.start();
     }
     
@@ -97,16 +104,16 @@
     
     private class IOReactorThread extends Thread {
 
-        private final IOEventDispatch ioEventDispatch;
+        private final NHttpServiceHandler serviceHandler;
         
-        public IOReactorThread(final IOEventDispatch ioEventDispatch) {
+        public IOReactorThread(final NHttpServiceHandler serviceHandler) {
             super();
-            this.ioEventDispatch = ioEventDispatch;
+            this.serviceHandler = serviceHandler;
         }
         
         public void run() {
             try {
-                execute(this.ioEventDispatch);
+                execute(this.serviceHandler);
             } catch (IOException ex) {
                 ex.printStackTrace();
             }

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/protocol/TestNIOHttp.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/protocol/TestNIOHttp.java?view=diff&rev=542937&r1=542936&r2=542937
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/protocol/TestNIOHttp.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/protocol/TestNIOHttp.java
Wed May 30 14:19:45 2007
@@ -54,8 +54,6 @@
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.DefaultHttpResponseFactory;
-import org.apache.http.impl.nio.DefaultClientIOEventDispatch;
-import org.apache.http.impl.nio.DefaultServerIOEventDispatch;
 import org.apache.http.message.BasicHttpEntityEnclosingRequest;
 import org.apache.http.message.BasicHttpRequest;
 import org.apache.http.nio.NHttpClientHandler;
@@ -65,7 +63,6 @@
 import org.apache.http.nio.mockup.SimpleHttpRequestHandlerResolver;
 import org.apache.http.nio.mockup.TestHttpClient;
 import org.apache.http.nio.mockup.TestHttpServer;
-import org.apache.http.nio.reactor.IOEventDispatch;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
@@ -292,20 +289,12 @@
                 null,
                 serverEventListener);
 
-        IOEventDispatch serverEventDispatch = new DefaultServerIOEventDispatch(
-                serviceHandler, 
-                this.server.getParams());
-        
         NHttpClientHandler clientHandler = createHttpClientHandler(
                 requestExecutionHandler, 
                 clientEventListener);
 
-        IOEventDispatch clientEventDispatch = new DefaultClientIOEventDispatch(
-                clientHandler, 
-                this.client.getParams());        
-        
-        this.server.start(serverEventDispatch);
-        this.client.start(clientEventDispatch);
+        this.server.start(serviceHandler);
+        this.client.start(clientHandler);
         
         InetSocketAddress serverAddress = (InetSocketAddress) this.server.getSocketAddress();
         
@@ -445,20 +434,12 @@
                 null,
                 serverEventListener);
 
-        IOEventDispatch serverEventDispatch = new DefaultServerIOEventDispatch(
-                serviceHandler, 
-                this.server.getParams());
-        
         NHttpClientHandler clientHandler = createHttpClientHandler(
                 requestExecutionHandler, 
                 clientEventListener);
 
-        IOEventDispatch clientEventDispatch = new DefaultClientIOEventDispatch(
-                clientHandler, 
-                this.client.getParams());        
-        
-        this.server.start(serverEventDispatch);
-        this.client.start(clientEventDispatch);
+        this.server.start(serviceHandler);
+        this.client.start(clientHandler);
         
         InetSocketAddress serverAddress = (InetSocketAddress) this.server.getSocketAddress();
         
@@ -598,20 +579,12 @@
                 null,
                 serverEventListener);
 
-        IOEventDispatch serverEventDispatch = new DefaultServerIOEventDispatch(
-                serviceHandler, 
-                this.server.getParams());
-        
         NHttpClientHandler clientHandler = createHttpClientHandler(
                 requestExecutionHandler, 
                 clientEventListener);
 
-        IOEventDispatch clientEventDispatch = new DefaultClientIOEventDispatch(
-                clientHandler, 
-                this.client.getParams());        
-        
-        this.server.start(serverEventDispatch);
-        this.client.start(clientEventDispatch);
+        this.server.start(serviceHandler);
+        this.client.start(clientHandler);
         
         InetSocketAddress serverAddress = (InetSocketAddress) this.server.getSocketAddress();
         
@@ -756,20 +729,12 @@
                 null,
                 serverEventListener);
 
-        IOEventDispatch serverEventDispatch = new DefaultServerIOEventDispatch(
-                serviceHandler, 
-                this.server.getParams());
-        
         NHttpClientHandler clientHandler = createHttpClientHandler(
                 requestExecutionHandler, 
                 clientEventListener);
 
-        IOEventDispatch clientEventDispatch = new DefaultClientIOEventDispatch(
-                clientHandler, 
-                this.client.getParams());        
-        
-        this.server.start(serverEventDispatch);
-        this.client.start(clientEventDispatch);
+        this.server.start(serviceHandler);
+        this.client.start(clientHandler);
         
         InetSocketAddress serverAddress = (InetSocketAddress) this.server.getSocketAddress();
         
@@ -912,20 +877,12 @@
                 null,
                 serverEventListener);
 
-        IOEventDispatch serverEventDispatch = new DefaultServerIOEventDispatch(
-                serviceHandler, 
-                this.server.getParams());
-        
         NHttpClientHandler clientHandler = createHttpClientHandler(
                 requestExecutionHandler, 
                 clientEventListener);
 
-        IOEventDispatch clientEventDispatch = new DefaultClientIOEventDispatch(
-                clientHandler, 
-                this.client.getParams());        
-        
-        this.server.start(serverEventDispatch);
-        this.client.start(clientEventDispatch);
+        this.server.start(serviceHandler);
+        this.client.start(clientHandler);
         
         InetSocketAddress serverAddress = (InetSocketAddress) this.server.getSocketAddress();
         
@@ -1073,20 +1030,12 @@
                 expectationVerifier,
                 serverEventListener);
 
-        IOEventDispatch serverEventDispatch = new DefaultServerIOEventDispatch(
-                serviceHandler, 
-                this.server.getParams());
-        
         NHttpClientHandler clientHandler = createHttpClientHandler(
                 requestExecutionHandler, 
                 clientEventListener);
 
-        IOEventDispatch clientEventDispatch = new DefaultClientIOEventDispatch(
-                clientHandler, 
-                this.client.getParams());        
-        
-        this.server.start(serverEventDispatch);
-        this.client.start(clientEventDispatch);
+        this.server.start(serviceHandler);
+        this.client.start(clientHandler);
         
         InetSocketAddress serverAddress = (InetSocketAddress) this.server.getSocketAddress();
         
@@ -1208,20 +1157,12 @@
                 null,
                 serverEventListener);
 
-        IOEventDispatch serverEventDispatch = new DefaultServerIOEventDispatch(
-                serviceHandler, 
-                this.server.getParams());
-        
         NHttpClientHandler clientHandler = createHttpClientHandler(
                 requestExecutionHandler, 
                 clientEventListener);
 
-        IOEventDispatch clientEventDispatch = new DefaultClientIOEventDispatch(
-                clientHandler, 
-                this.client.getParams());        
-        
-        this.server.start(serverEventDispatch);
-        this.client.start(clientEventDispatch);
+        this.server.start(serviceHandler);
+        this.client.start(clientHandler);
         
         InetSocketAddress serverAddress = (InetSocketAddress) this.server.getSocketAddress();
 



Mime
View raw message