hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r546633 - /jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/protocol/TestNIOHttp.java
Date Tue, 12 Jun 2007 20:57:42 GMT
Author: olegk
Date: Tue Jun 12 13:57:42 2007
New Revision: 546633

URL: http://svn.apache.org/viewvc?view=rev&rev=546633
Log:
Added test decorators for the throttling HTTP client handler. 

Modified:
    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/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=546633&r1=546632&r2=546633
==============================================================================
--- 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
Tue Jun 12 13:57:42 2007
@@ -131,16 +131,19 @@
 
     static class ServerModeDecorator extends TestSetup {
 
-        private int mode;
+        private int clientMode;
+        private int serverMode;
         
-        public ServerModeDecorator(final TestNIOHttp test, int mode) {
+        public ServerModeDecorator(final TestNIOHttp test, int clientMode, int serverMode)
{
             super(test);
-            this.mode = mode;
+            this.clientMode = clientMode;
+            this.serverMode = serverMode;
         }
                 
         protected void setUp() throws Exception {
             TestNIOHttp testcase = (TestNIOHttp)getTest();
-            testcase.setServerMode(this.mode);
+            testcase.setServerMode(this.serverMode);
+            testcase.setClientMode(this.clientMode);
         }  
     }
     
@@ -152,11 +155,19 @@
         TestSuite suite = new TestSuite();
         for (Enumeration en = source.tests(); en.hasMoreElements(); ) {
             TestNIOHttp test = (TestNIOHttp) en.nextElement();
-            suite.addTest(new ServerModeDecorator(test, MODE_BUFFERING));            
+            suite.addTest(new ServerModeDecorator(test, MODE_BUFFERING, MODE_BUFFERING));
           
         }
         for (Enumeration en = source.tests(); en.hasMoreElements(); ) {
             TestNIOHttp test = (TestNIOHttp) en.nextElement();
-            suite.addTest(new ServerModeDecorator(test, MODE_THROTTLING));            
+            suite.addTest(new ServerModeDecorator(test, MODE_THROTTLING, MODE_BUFFERING));
           
+        }
+        for (Enumeration en = source.tests(); en.hasMoreElements(); ) {
+            TestNIOHttp test = (TestNIOHttp) en.nextElement();
+            suite.addTest(new ServerModeDecorator(test, MODE_BUFFERING, MODE_THROTTLING));
           
+        }
+        for (Enumeration en = source.tests(); en.hasMoreElements(); ) {
+            TestNIOHttp test = (TestNIOHttp) en.nextElement();
+            suite.addTest(new ServerModeDecorator(test, MODE_THROTTLING, MODE_THROTTLING));
           
         }
         return suite;
     }
@@ -246,16 +257,29 @@
         httpproc.addInterceptor(new RequestConnControl());
         httpproc.addInterceptor(new RequestUserAgent());
         httpproc.addInterceptor(new RequestExpectContinue());
-        
-        BufferingHttpClientHandler clientHandler = new BufferingHttpClientHandler(
-                httpproc,
-                requestExecutionHandler,
-                new DefaultConnectionReuseStrategy(),
-                this.client.getParams());
 
-        clientHandler.setEventListener(eventListener);
+        if (this.clientMode == MODE_BUFFERING) {
+            BufferingHttpClientHandler clientHandler = new BufferingHttpClientHandler(
+                    httpproc,
+                    requestExecutionHandler,
+                    new DefaultConnectionReuseStrategy(),
+                    this.client.getParams());
+
+            clientHandler.setEventListener(eventListener);
+            return clientHandler;
+        }
+        if (this.clientMode == MODE_THROTTLING) {
+            ThrottlingHttpClientHandler clientHandler = new ThrottlingHttpClientHandler(
+                    httpproc,
+                    requestExecutionHandler,
+                    new DefaultConnectionReuseStrategy(),
+                    this.executor,
+                    this.client.getParams());
 
-        return clientHandler;
+            clientHandler.setEventListener(eventListener);
+            return clientHandler;
+        }
+        throw new IllegalStateException();
     }
     
     /**



Mime
View raw message