hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1350988 [2/2] - in /httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http: client/protocol/ client/utils/ conn/ conn/ssl/ impl/auth/ impl/client/ impl/client/integration/ impl/conn/ impl/conn/tsc...
Date Sat, 16 Jun 2012 19:43:07 GMT
Modified: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestBasicConnManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestBasicConnManager.java?rev=1350988&r1=1350987&r2=1350988&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestBasicConnManager.java
(original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestBasicConnManager.java
Sat Jun 16 19:43:06 2012
@@ -31,44 +31,55 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.http.HttpHost;
 import org.apache.http.HttpRequest;
+import org.apache.http.HttpRequestInterceptor;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
 import org.apache.http.HttpVersion;
 import org.apache.http.conn.ManagedClientConnection;
 import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.conn.scheme.SchemeRegistry;
-import org.apache.http.localserver.ServerTestBase;
+import org.apache.http.localserver.LocalServerTestBase;
 import org.apache.http.message.BasicHttpRequest;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpParams;
+import org.apache.http.protocol.BasicHttpContext;
 import org.apache.http.protocol.ExecutionContext;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.HttpProcessor;
+import org.apache.http.protocol.HttpRequestExecutor;
+import org.apache.http.protocol.ImmutableHttpProcessor;
+import org.apache.http.protocol.RequestConnControl;
+import org.apache.http.protocol.RequestContent;
 import org.apache.http.util.EntityUtils;
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
 
-public class TestBasicConnManager extends ServerTestBase {
+public class TestBasicConnManager extends LocalServerTestBase {
 
-    public BasicClientConnectionManager createConnManager(SchemeRegistry schreg) {
-        if (schreg == null)
-            schreg = supportedSchemes;
-        return new BasicClientConnectionManager(schreg);
+    @Before 
+    public void setup() throws Exception {
+        startServer();
     }
-
+    
     /**
      * Tests that SCM can still connect to the same host after
      * a connection was aborted.
      */
     @Test
     public void testOpenAfterAbort() throws Exception {
-        BasicClientConnectionManager mgr = createConnManager(null);
+        BasicClientConnectionManager mgr = new BasicClientConnectionManager();
 
-        final HttpHost target = getServerHttp();
-        final HttpRoute route = new HttpRoute(target, null, false);
+        HttpHost target = getServerHttp();
+        HttpRoute route = new HttpRoute(target, null, false);
+        HttpContext context = new BasicHttpContext();
+        HttpParams params = new BasicHttpParams();
 
         ManagedClientConnection conn = mgr.getConnection(route, null);
         conn.abortConnection();
 
         conn = mgr.getConnection(route, null);
         Assert.assertFalse("connection should have been closed", conn.isOpen());
-        conn.open(route, httpContext, defaultParams);
+        conn.open(route, context, params);
 
         mgr.releaseConnection(conn, -1, null);
         mgr.shutdown();
@@ -79,24 +90,30 @@ public class TestBasicConnManager extend
      */
     @Test
     public void testReleaseConnectionWithTimeLimits() throws Exception {
+        BasicClientConnectionManager mgr = new BasicClientConnectionManager();
 
-        BasicClientConnectionManager mgr = createConnManager(null);
-
-        final HttpHost target = getServerHttp();
-        final HttpRoute route = new HttpRoute(target, null, false);
-        final int      rsplen = 8;
-        final String      uri = "/random/" + rsplen;
+        HttpHost target = getServerHttp();
+        HttpRoute route = new HttpRoute(target, null, false);
+        HttpContext context = new BasicHttpContext();
+        HttpParams params = new BasicHttpParams();
+        int      rsplen = 8;
+        String      uri = "/random/" + rsplen;
 
-        HttpRequest request =
-            new BasicHttpRequest("GET", uri, HttpVersion.HTTP_1_1);
+        HttpRequest request = new BasicHttpRequest("GET", uri, HttpVersion.HTTP_1_1);
 
         ManagedClientConnection conn = mgr.getConnection(route, null);
-        conn.open(route, httpContext, defaultParams);
+        conn.open(route, context, params);
 
-        // a new context is created for each testcase, no need to reset
-        HttpResponse response = Helper.execute(
-                request, conn, target,
-                httpExecutor, httpProcessor, defaultParams, httpContext);
+        // a new context is created for each test case, no need to reset
+        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
+        context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, target);
+
+        HttpProcessor httpProcessor = new ImmutableHttpProcessor(
+                new HttpRequestInterceptor[] { new RequestContent(), new RequestConnControl()
});
+        
+        HttpRequestExecutor exec = new HttpRequestExecutor();
+        exec.preProcess(request, httpProcessor, context);
+        HttpResponse response = exec.execute(request, conn, context);
 
         Assert.assertEquals("wrong status in first response",
                      HttpStatus.SC_OK,
@@ -113,10 +130,9 @@ public class TestBasicConnManager extend
         Assert.assertFalse("connection should have been closed", conn.isOpen());
 
         // repeat the communication, no need to prepare the request again
-        conn.open(route, httpContext, defaultParams);
-        httpContext.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
-        response = httpExecutor.execute(request, conn, httpContext);
-        httpExecutor.postProcess(response, httpProcessor, httpContext);
+        conn.open(route, context, params);
+        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
+        response = exec.execute(request, conn, context);
 
         Assert.assertEquals("wrong status in second response",
                      HttpStatus.SC_OK,
@@ -134,9 +150,8 @@ public class TestBasicConnManager extend
         Assert.assertTrue("connection should have been open", conn.isOpen());
 
         // repeat the communication, no need to prepare the request again
-        httpContext.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
-        response = httpExecutor.execute(request, conn, httpContext);
-        httpExecutor.postProcess(response, httpProcessor, httpContext);
+        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
+        response = exec.execute(request, conn, context);
 
         Assert.assertEquals("wrong status in third response",
                      HttpStatus.SC_OK,
@@ -153,10 +168,9 @@ public class TestBasicConnManager extend
         Assert.assertTrue("connection should have been closed", !conn.isOpen());
 
         // repeat the communication, no need to prepare the request again
-        conn.open(route, httpContext, defaultParams);
-        httpContext.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
-        response = httpExecutor.execute(request, conn, httpContext);
-        httpExecutor.postProcess(response, httpProcessor, httpContext);
+        conn.open(route, context, params);
+        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
+        response = exec.execute(request, conn, context);
 
         Assert.assertEquals("wrong status in third response",
                      HttpStatus.SC_OK,
@@ -171,14 +185,15 @@ public class TestBasicConnManager extend
 
     @Test
     public void testCloseExpiredConnections() throws Exception {
+        BasicClientConnectionManager mgr = new BasicClientConnectionManager();
 
-        BasicClientConnectionManager mgr = createConnManager(null);
-
-        final HttpHost target = getServerHttp();
-        final HttpRoute route = new HttpRoute(target, null, false);
+        HttpHost target = getServerHttp();
+        HttpRoute route = new HttpRoute(target, null, false);
+        HttpContext context = new BasicHttpContext();
+        HttpParams params = new BasicHttpParams();
 
         ManagedClientConnection conn =  mgr.getConnection(route, null);
-        conn.open(route, httpContext, defaultParams);
+        conn.open(route, context, params);
         conn.markReusable();
         mgr.releaseConnection(conn, 100, TimeUnit.MILLISECONDS);
 
@@ -198,11 +213,10 @@ public class TestBasicConnManager extend
 
     @Test(expected=IllegalStateException.class)
     public void testAlreadyLeased() throws Exception {
+        BasicClientConnectionManager mgr = new BasicClientConnectionManager();
 
-        BasicClientConnectionManager mgr = createConnManager(null);
-
-        final HttpHost target = getServerHttp();
-        final HttpRoute route = new HttpRoute(target, null, false);
+        HttpHost target = getServerHttp();
+        HttpRoute route = new HttpRoute(target, null, false);
 
         ManagedClientConnection conn =  mgr.getConnection(route, null);
         mgr.releaseConnection(conn, 100, TimeUnit.MILLISECONDS);

Modified: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestIdleConnectionEviction.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestIdleConnectionEviction.java?rev=1350988&r1=1350987&r2=1350988&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestIdleConnectionEviction.java
(original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestIdleConnectionEviction.java
Sat Jun 16 19:43:06 2012
@@ -42,7 +42,7 @@ import org.apache.http.conn.scheme.Schem
 import org.apache.http.conn.scheme.SchemeRegistry;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.localserver.LocalTestServer;
-import org.apache.http.localserver.ServerTestBase;
+import org.apache.http.localserver.LocalServerTestBase;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
@@ -50,9 +50,8 @@ import org.apache.http.util.EntityUtils;
 import org.junit.Before;
 import org.junit.Test;
 
-public class TestIdleConnectionEviction extends ServerTestBase {
+public class TestIdleConnectionEviction extends LocalServerTestBase {
 
-    @Override
     @Before
     public void setUp() throws Exception {
         this.localServer = new LocalTestServer(null, null);

Modified: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingConnManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingConnManager.java?rev=1350988&r1=1350987&r2=1350988&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingConnManager.java
(original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingConnManager.java
Sat Jun 16 19:43:06 2012
@@ -39,6 +39,7 @@ import java.util.concurrent.atomic.Atomi
 
 import org.apache.http.HttpHost;
 import org.apache.http.HttpRequest;
+import org.apache.http.HttpRequestInterceptor;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
 import org.apache.http.HttpVersion;
@@ -54,22 +55,34 @@ import org.apache.http.conn.scheme.Plain
 import org.apache.http.conn.scheme.Scheme;
 import org.apache.http.conn.scheme.SchemeRegistry;
 import org.apache.http.conn.scheme.SchemeSocketFactory;
-import org.apache.http.localserver.ServerTestBase;
+import org.apache.http.localserver.LocalServerTestBase;
 import org.apache.http.message.BasicHttpRequest;
+import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParams;
 import org.apache.http.protocol.BasicHttpContext;
 import org.apache.http.protocol.ExecutionContext;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.HttpProcessor;
+import org.apache.http.protocol.HttpRequestExecutor;
+import org.apache.http.protocol.ImmutableHttpProcessor;
+import org.apache.http.protocol.RequestConnControl;
+import org.apache.http.protocol.RequestContent;
 import org.apache.http.util.EntityUtils;
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
 
 /**
  * Tests for <code>PoolingClientConnectionManager</code> that do require a server
  * to communicate with.
  */
-public class TestPoolingConnManager extends ServerTestBase {
+public class TestPoolingConnManager extends LocalServerTestBase {
 
+    @Before 
+    public void setup() throws Exception {
+        startServer();
+    }
+    
     /**
      * Tests executing several requests in parallel.
      */
@@ -90,22 +103,8 @@ public class TestPoolingConnManager exte
 
         ExecReqThread[] threads = new ExecReqThread [COUNT];
         for (int i=0; i<COUNT; i++) {
-
-            HttpRequest request = new BasicHttpRequest
-                ("GET", uri, HttpVersion.HTTP_1_1);
-
-            ExecReqThread.RequestSpec ertrs = new ExecReqThread.RequestSpec();
-            ertrs.executor = httpExecutor;
-            ertrs.processor = httpProcessor;
-            ertrs.context = new BasicHttpContext(null);
-            ertrs.params = defaultParams;
-
-            ertrs.context.setAttribute
-                (ExecutionContext.HTTP_TARGET_HOST, target);
-            ertrs.context.setAttribute
-                (ExecutionContext.HTTP_REQUEST, request);
-
-            threads[i] = new ExecReqThread(mgr, route, 5000L, ertrs);
+            HttpRequest request = new BasicHttpRequest("GET", uri, HttpVersion.HTTP_1_1);
+            threads[i] = new ExecReqThread(request, route, mgr, 5000L);
         }
 
         for (int i=0; i<threads.length; i++) {
@@ -155,21 +154,27 @@ public class TestPoolingConnManager exte
         PoolingClientConnectionManager mgr = new PoolingClientConnectionManager();
         mgr.setMaxTotal(1);
 
-        final HttpHost target = getServerHttp();
-        final HttpRoute route = new HttpRoute(target, null, false);
-        final int      rsplen = 8;
-        final String      uri = "/random/" + rsplen;
-
-        HttpRequest request =
-            new BasicHttpRequest("GET", uri, HttpVersion.HTTP_1_1);
-
+        HttpHost target = getServerHttp();
+        HttpRoute route = new HttpRoute(target, null, false);
+        int      rsplen = 8;
+        String      uri = "/random/" + rsplen;
+
+        HttpRequest request = new BasicHttpRequest("GET", uri, HttpVersion.HTTP_1_1);
+        HttpContext context = new BasicHttpContext();
+        HttpParams params = new BasicHttpParams();
+        
         ManagedClientConnection conn = getConnection(mgr, route);
-        conn.open(route, httpContext, defaultParams);
+        conn.open(route, context, params);
+
+        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
+        context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, target);
 
-        // a new context is created for each testcase, no need to reset
-        HttpResponse response = Helper.execute(
-                request, conn, target,
-                httpExecutor, httpProcessor, defaultParams, httpContext);
+        HttpProcessor httpProcessor = new ImmutableHttpProcessor(
+                new HttpRequestInterceptor[] { new RequestContent(), new RequestConnControl()
});
+        
+        HttpRequestExecutor exec = new HttpRequestExecutor();
+        exec.preProcess(request, httpProcessor, context);
+        HttpResponse response = exec.execute(request, conn, context);
 
         Assert.assertEquals("wrong status in first response",
                      HttpStatus.SC_OK,
@@ -194,11 +199,11 @@ public class TestPoolingConnManager exte
         conn = getConnection(mgr, route);
         Assert.assertFalse("connection should have been closed", conn.isOpen());
 
+        conn.open(route, context, params);
+
         // repeat the communication, no need to prepare the request again
-        conn.open(route, httpContext, defaultParams);
-        httpContext.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
-        response = httpExecutor.execute(request, conn, httpContext);
-        httpExecutor.postProcess(response, httpProcessor, httpContext);
+        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
+        response = exec.execute(request, conn, context);
 
         Assert.assertEquals("wrong status in second response",
                      HttpStatus.SC_OK,
@@ -216,9 +221,8 @@ public class TestPoolingConnManager exte
         Assert.assertTrue("connection should have been open", conn.isOpen());
 
         // repeat the communication, no need to prepare the request again
-        httpContext.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
-        response = httpExecutor.execute(request, conn, httpContext);
-        httpExecutor.postProcess(response, httpProcessor, httpContext);
+        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
+        response = exec.execute(request, conn, context);
 
         Assert.assertEquals("wrong status in third response",
                      HttpStatus.SC_OK,
@@ -241,21 +245,27 @@ public class TestPoolingConnManager exte
         PoolingClientConnectionManager mgr = new PoolingClientConnectionManager();
         mgr.setMaxTotal(1);
 
-        final HttpHost target = getServerHttp();
-        final HttpRoute route = new HttpRoute(target, null, false);
-        final int      rsplen = 8;
-        final String      uri = "/random/" + rsplen;
-
-        HttpRequest request =
-            new BasicHttpRequest("GET", uri, HttpVersion.HTTP_1_1);
+        HttpHost target = getServerHttp();
+        HttpRoute route = new HttpRoute(target, null, false);
+        int      rsplen = 8;
+        String      uri = "/random/" + rsplen;
+
+        HttpRequest request = new BasicHttpRequest("GET", uri, HttpVersion.HTTP_1_1);
+        HttpContext context = new BasicHttpContext();
+        HttpParams params = new BasicHttpParams();
 
         ManagedClientConnection conn = getConnection(mgr, route);
-        conn.open(route, httpContext, defaultParams);
+        conn.open(route, context, params);
+
+        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
+        context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, target);
 
-        // a new context is created for each testcase, no need to reset
-        HttpResponse response = Helper.execute(
-                request, conn, target,
-                httpExecutor, httpProcessor, defaultParams, httpContext);
+        HttpProcessor httpProcessor = new ImmutableHttpProcessor(
+                new HttpRequestInterceptor[] { new RequestContent(), new RequestConnControl()
});
+        
+        HttpRequestExecutor exec = new HttpRequestExecutor();
+        exec.preProcess(request, httpProcessor, context);
+        HttpResponse response = exec.execute(request, conn, context);
 
         Assert.assertEquals("wrong status in first response",
                      HttpStatus.SC_OK,
@@ -281,10 +291,10 @@ public class TestPoolingConnManager exte
         Assert.assertFalse("connection should have been closed", conn.isOpen());
 
         // repeat the communication, no need to prepare the request again
-        conn.open(route, httpContext, defaultParams);
-        httpContext.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
-        response = httpExecutor.execute(request, conn, httpContext);
-        httpExecutor.postProcess(response, httpProcessor, httpContext);
+        conn.open(route, context, params);
+        
+        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
+        response = exec.execute(request, conn, context);
 
         Assert.assertEquals("wrong status in second response",
                      HttpStatus.SC_OK,
@@ -302,9 +312,8 @@ public class TestPoolingConnManager exte
         Assert.assertTrue("connection should have been open", conn.isOpen());
 
         // repeat the communication, no need to prepare the request again
-        httpContext.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
-        response = httpExecutor.execute(request, conn, httpContext);
-        httpExecutor.postProcess(response, httpProcessor, httpContext);
+        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
+        response = exec.execute(request, conn, context);
 
         Assert.assertEquals("wrong status in third response",
                      HttpStatus.SC_OK,
@@ -321,10 +330,10 @@ public class TestPoolingConnManager exte
         Assert.assertTrue("connection should have been closed", !conn.isOpen());
 
         // repeat the communication, no need to prepare the request again
-        conn.open(route, httpContext, defaultParams);
-        httpContext.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
-        response = httpExecutor.execute(request, conn, httpContext);
-        httpExecutor.postProcess(response, httpProcessor, httpContext);
+        conn.open(route, context, params);
+        
+        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
+        response = exec.execute(request, conn, context);
 
         Assert.assertEquals("wrong status in third response",
                      HttpStatus.SC_OK,
@@ -343,11 +352,13 @@ public class TestPoolingConnManager exte
         PoolingClientConnectionManager mgr = new PoolingClientConnectionManager();
         mgr.setMaxTotal(1);
 
-        final HttpHost target = getServerHttp();
-        final HttpRoute route = new HttpRoute(target, null, false);
+        HttpHost target = getServerHttp();
+        HttpRoute route = new HttpRoute(target, null, false);
+        HttpContext context = new BasicHttpContext();
+        HttpParams params = new BasicHttpParams();
 
         ManagedClientConnection conn = getConnection(mgr, route);
-        conn.open(route, httpContext, defaultParams);
+        conn.open(route, context, params);
 
         Assert.assertEquals(1, mgr.getTotalStats().getLeased());
         Assert.assertEquals(1, mgr.getStats(route).getLeased());
@@ -382,11 +393,13 @@ public class TestPoolingConnManager exte
                 SchemeRegistryFactory.createDefault(), 100, TimeUnit.MILLISECONDS);
         mgr.setMaxTotal(1);
 
-        final HttpHost target = getServerHttp();
-        final HttpRoute route = new HttpRoute(target, null, false);
+        HttpHost target = getServerHttp();
+        HttpRoute route = new HttpRoute(target, null, false);
+        HttpContext context = new BasicHttpContext();
+        HttpParams params = new BasicHttpParams();
 
         ManagedClientConnection conn = getConnection(mgr, route);
-        conn.open(route, httpContext, defaultParams);
+        conn.open(route, context, params);
 
         Assert.assertEquals(1, mgr.getTotalStats().getLeased());
         Assert.assertEquals(1, mgr.getStats(route).getLeased());
@@ -425,21 +438,28 @@ public class TestPoolingConnManager exte
         PoolingClientConnectionManager mgr = new PoolingClientConnectionManager();
         mgr.setMaxTotal(1);
 
-        final HttpHost target = getServerHttp();
-        final HttpRoute route = new HttpRoute(target, null, false);
-        final int      rsplen = 8;
-        final String      uri = "/random/" + rsplen;
+        HttpHost target = getServerHttp();
+        HttpRoute route = new HttpRoute(target, null, false);
+        int      rsplen = 8;
+        String      uri = "/random/" + rsplen;
+        HttpContext context = new BasicHttpContext();
+        HttpParams params = new BasicHttpParams();
 
         HttpRequest request =
             new BasicHttpRequest("GET", uri, HttpVersion.HTTP_1_1);
 
         ManagedClientConnection conn = getConnection(mgr, route);
-        conn.open(route, httpContext, defaultParams);
+        conn.open(route, context, params);
 
-        // a new context is created for each testcase, no need to reset
-        HttpResponse response = Helper.execute(
-                request, conn, target,
-                httpExecutor, httpProcessor, defaultParams, httpContext);
+        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
+        context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, target);
+
+        HttpProcessor httpProcessor = new ImmutableHttpProcessor(
+                new HttpRequestInterceptor[] { new RequestContent(), new RequestConnControl()
});
+        
+        HttpRequestExecutor exec = new HttpRequestExecutor();
+        exec.preProcess(request, httpProcessor, context);
+        HttpResponse response = exec.execute(request, conn, context);
 
         Assert.assertEquals("wrong status in first response",
                      HttpStatus.SC_OK,
@@ -478,8 +498,10 @@ public class TestPoolingConnManager exte
         PoolingClientConnectionManager mgr = new PoolingClientConnectionManager(registry);
         mgr.setMaxTotal(1);
 
-        final HttpHost target = getServerHttp();
-        final HttpRoute route = new HttpRoute(target, null, false);
+        HttpHost target = getServerHttp();
+        HttpRoute route = new HttpRoute(target, null, false);
+        HttpContext context = new BasicHttpContext();
+        HttpParams params = new BasicHttpParams();
 
         final ManagedClientConnection conn = getConnection(mgr, route);
 
@@ -498,7 +520,7 @@ public class TestPoolingConnManager exte
         abortingThread.start();
 
         try {
-            conn.open(route, httpContext, defaultParams);
+            conn.open(route, context, params);
             Assert.fail("expected SocketException");
         } catch(SocketException expected) {}
 
@@ -529,8 +551,10 @@ public class TestPoolingConnManager exte
         PoolingClientConnectionManager mgr = new PoolingClientConnectionManager(registry);
         mgr.setMaxTotal(1);
 
-        final HttpHost target = getServerHttp();
-        final HttpRoute route = new HttpRoute(target, null, false);
+        HttpHost target = getServerHttp();
+        HttpRoute route = new HttpRoute(target, null, false);
+        HttpContext context = new BasicHttpContext();
+        HttpParams params = new BasicHttpParams();
 
         final ManagedClientConnection conn = getConnection(mgr, route);
 
@@ -549,7 +573,7 @@ public class TestPoolingConnManager exte
         abortingThread.start();
 
         try {
-            conn.open(route, httpContext, defaultParams);
+            conn.open(route, context, params);
             Assert.fail("expected exception");
         } catch(IOException expected) {
             Assert.assertEquals("Connection already shutdown", expected.getMessage());
@@ -582,8 +606,10 @@ public class TestPoolingConnManager exte
         PoolingClientConnectionManager mgr = new PoolingClientConnectionManager(registry);
         mgr.setMaxTotal(1);
 
-        final HttpHost target = getServerHttp();
-        final HttpRoute route = new HttpRoute(target, null, false);
+        HttpHost target = getServerHttp();
+        HttpRoute route = new HttpRoute(target, null, false);
+        HttpContext context = new BasicHttpContext();
+        HttpParams params = new BasicHttpParams();
 
         final ManagedClientConnection conn = getConnection(mgr, route);
 
@@ -602,7 +628,7 @@ public class TestPoolingConnManager exte
         abortingThread.start();
 
         try {
-            conn.open(route, httpContext, defaultParams);
+            conn.open(route, context, params);
             Assert.fail("expected SocketException");
         } catch(SocketException expected) {}
 
@@ -644,8 +670,10 @@ public class TestPoolingConnManager exte
         mgr.setMaxTotal(1);
         Assert.assertNotNull(operatorRef.get());
 
-        final HttpHost target = getServerHttp();
-        final HttpRoute route = new HttpRoute(target, null, false);
+        HttpHost target = getServerHttp();
+        HttpRoute route = new HttpRoute(target, null, false);
+        HttpContext context = new BasicHttpContext();
+        HttpParams params = new BasicHttpParams();
 
         final ManagedClientConnection conn = getConnection(mgr, route);
 
@@ -664,7 +692,7 @@ public class TestPoolingConnManager exte
         abortingThread.start();
 
         try {
-            conn.open(route, httpContext, defaultParams);
+            conn.open(route, context, params);
             Assert.fail("expected exception");
         } catch(IOException iox) {
         }

Modified: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingConnManagerNoServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingConnManagerNoServer.java?rev=1350988&r1=1350987&r2=1350988&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingConnManagerNoServer.java
(original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingConnManagerNoServer.java
Sat Jun 16 19:43:06 2012
@@ -36,6 +36,7 @@ import org.apache.http.conn.ClientConnec
 import org.apache.http.conn.ConnectionPoolTimeoutException;
 import org.apache.http.conn.ManagedClientConnection;
 import org.apache.http.conn.routing.HttpRoute;
+import org.apache.http.impl.conn.tsccm.GetConnThread;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.HttpProtocolParams;

Copied: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/GetConnThread.java
(from r1350987, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/GetConnThread.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/GetConnThread.java?p2=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/GetConnThread.java&p1=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/GetConnThread.java&r1=1350987&r2=1350988&rev=1350988&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/GetConnThread.java
(original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/GetConnThread.java
Sat Jun 16 19:43:06 2012
@@ -25,7 +25,7 @@
  *
  */
 
-package org.apache.http.impl.conn;
+package org.apache.http.impl.conn.tsccm;
 
 import java.util.concurrent.TimeUnit;
 

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/GetConnThread.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/GetConnThread.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/GetConnThread.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestConnPoolByRoute.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestConnPoolByRoute.java?rev=1350988&r1=1350987&r2=1350988&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestConnPoolByRoute.java
(original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestConnPoolByRoute.java
Sat Jun 16 19:43:06 2012
@@ -40,19 +40,21 @@ import org.apache.http.conn.OperatedClie
 import org.apache.http.conn.params.ConnPerRouteBean;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.impl.conn.DefaultClientConnectionOperator;
-import org.apache.http.localserver.ServerTestBase;
+import org.apache.http.impl.conn.SchemeRegistryFactory;
+import org.apache.http.localserver.LocalServerTestBase;
 import org.apache.http.params.BasicHttpParams;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
+import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
 
 @SuppressWarnings("deprecation")
 @RunWith(MockitoJUnitRunner.class)
 @Deprecated
-public class TestConnPoolByRoute extends ServerTestBase {
+public class TestConnPoolByRoute extends LocalServerTestBase {
 
     private ConnPoolByRoute impl;
     private HttpRoute route = new HttpRoute(new HttpHost("localhost"));
@@ -63,19 +65,18 @@ public class TestConnPoolByRoute extends
     @Mock private ClientConnectionOperator mockOperator;
 
     @Before
-    @Override
     public void setUp() throws Exception {
-        super.setUp();
+        startServer();
         impl = new ConnPoolByRoute(
-                new DefaultClientConnectionOperator(supportedSchemes),
+                new DefaultClientConnectionOperator(SchemeRegistryFactory.createDefault()),
                 new ConnPerRouteBean(), 1, -1, TimeUnit.MILLISECONDS);
     }
 
     private void useMockOperator() {
-        reset(mockOperator);
+        Mockito.reset(mockOperator);
         impl = new ConnPoolByRoute(
                 mockOperator, new ConnPerRouteBean(), 1, -1, TimeUnit.MILLISECONDS);
-        when(mockOperator.createConnection()).thenReturn(mockConnection);
+        Mockito.when(mockOperator.createConnection()).thenReturn(mockConnection);
     }
 
     @Test
@@ -84,7 +85,7 @@ public class TestConnPoolByRoute extends
         final HttpRoute route = new HttpRoute(target, null, false);
 
         ClientConnectionOperator operator = new DefaultClientConnectionOperator(
-                supportedSchemes);
+                SchemeRegistryFactory.createDefault());
 
         ConnPerRouteBean connPerRoute = new ConnPerRouteBean(3);
         ConnPoolByRoute connPool = new ConnPoolByRoute(operator, connPerRoute, 20);
@@ -129,7 +130,7 @@ public class TestConnPoolByRoute extends
         final HttpRoute route = new HttpRoute(target, null, false);
 
         ClientConnectionOperator operator = new DefaultClientConnectionOperator(
-                supportedSchemes);
+                SchemeRegistryFactory.createDefault());
 
         ConnPerRouteBean connPerRoute = new ConnPerRouteBean(3);
         ConnPoolByRoute connPool = new ConnPoolByRoute(operator, connPerRoute, 20);
@@ -198,13 +199,15 @@ public class TestConnPoolByRoute extends
 
     @Test(expected=IllegalArgumentException.class)
     public void nullConnPerRouteIsNotAllowed() {
-        new ConnPoolByRoute(new DefaultClientConnectionOperator(supportedSchemes),
+        new ConnPoolByRoute(new DefaultClientConnectionOperator(
+                SchemeRegistryFactory.createDefault()),
                 null, 1, -1, TimeUnit.MILLISECONDS);
     }
 
     @Test
     public void deprecatedConstructorIsStillSupported() {
-        new ConnPoolByRoute(new DefaultClientConnectionOperator(supportedSchemes),
+        new ConnPoolByRoute(new DefaultClientConnectionOperator(
+                SchemeRegistryFactory.createDefault()),
                 new BasicHttpParams());
     }
 
@@ -269,7 +272,7 @@ public class TestConnPoolByRoute extends
         BasicPoolEntry entry = impl.requestPoolEntry(route, new Object()).getPoolEntry(-1,
TimeUnit.MILLISECONDS);
         impl.shutdown();
         impl.freeEntry(entry, true, Long.MAX_VALUE, TimeUnit.MILLISECONDS);
-        verify(mockConnection, atLeastOnce()).close();
+        Mockito.verify(mockConnection, Mockito.atLeastOnce()).close();
     }
 
     @Test
@@ -278,7 +281,7 @@ public class TestConnPoolByRoute extends
         BasicPoolEntry entry = impl.requestPoolEntry(route, new Object()).getPoolEntry(-1,
TimeUnit.MILLISECONDS);
         impl.freeEntry(entry, true, Long.MAX_VALUE, TimeUnit.MILLISECONDS);
         assertFalse(impl.freeConnections.isEmpty());
-        when(mockConnection.isOpen()).thenReturn(false);
+        Mockito.when(mockConnection.isOpen()).thenReturn(false);
         impl.deleteClosedConnections();
         assertTrue(impl.freeConnections.isEmpty());
         assertEquals(0, impl.numConnections);
@@ -290,7 +293,7 @@ public class TestConnPoolByRoute extends
         BasicPoolEntry entry = impl.requestPoolEntry(route, new Object()).getPoolEntry(-1,
TimeUnit.MILLISECONDS);
         impl.freeEntry(entry, true, Long.MAX_VALUE, TimeUnit.MILLISECONDS);
         assertFalse(impl.freeConnections.isEmpty());
-        when(mockConnection.isOpen()).thenReturn(true);
+        Mockito.when(mockConnection.isOpen()).thenReturn(true);
         impl.deleteClosedConnections();
         assertFalse(impl.freeConnections.isEmpty());
         assertEquals(1, impl.numConnections);
@@ -303,7 +306,7 @@ public class TestConnPoolByRoute extends
         impl.freeEntry(entry, true, Long.MAX_VALUE, TimeUnit.MILLISECONDS);
         Thread.sleep(200L);
         impl.closeIdleConnections(1, TimeUnit.MILLISECONDS);
-        verify(mockConnection, atLeastOnce()).close();
+        Mockito.verify(mockConnection, Mockito.atLeastOnce()).close();
     }
 
     @Test
@@ -312,7 +315,7 @@ public class TestConnPoolByRoute extends
         BasicPoolEntry entry = impl.requestPoolEntry(route, new Object()).getPoolEntry(-1,
TimeUnit.MILLISECONDS);
         impl.freeEntry(entry, true, Long.MAX_VALUE, TimeUnit.MILLISECONDS);
         impl.closeIdleConnections(3, TimeUnit.SECONDS);
-        verify(mockConnection, never()).close();
+        Mockito.verify(mockConnection, Mockito.never()).close();
     }
 
     @Test
@@ -322,7 +325,7 @@ public class TestConnPoolByRoute extends
         impl.freeEntry(entry, true, 1, TimeUnit.MILLISECONDS);
         Thread.sleep(200L);
         impl.closeExpiredConnections();
-        verify(mockConnection, atLeastOnce()).close();
+        Mockito.verify(mockConnection, Mockito.atLeastOnce()).close();
     }
 
     @Test
@@ -332,7 +335,7 @@ public class TestConnPoolByRoute extends
         impl.freeEntry(entry, true, 10, TimeUnit.SECONDS);
         Thread.sleep(200L);
         impl.closeExpiredConnections();
-        verify(mockConnection, never()).close();
+        Mockito.verify(mockConnection, Mockito.never()).close();
     }
 
     @Test
@@ -340,21 +343,21 @@ public class TestConnPoolByRoute extends
         useMockOperator();
         BasicPoolEntry entry = impl.requestPoolEntry(route, new Object()).getPoolEntry(-1,
TimeUnit.MILLISECONDS);
         impl.freeEntry(entry, false, 0, TimeUnit.MILLISECONDS);
-        verify(mockConnection, atLeastOnce()).close();
+        Mockito.verify(mockConnection, Mockito.atLeastOnce()).close();
     }
 
     @Test
     public void handlesExceptionsWhenClosingConnections() throws Exception {
         useMockOperator();
         BasicPoolEntry entry = impl.requestPoolEntry(route, new Object()).getPoolEntry(-1,
TimeUnit.MILLISECONDS);
-        doThrow(new IOException()).when(mockConnection).close();
+        Mockito.doThrow(new IOException()).when(mockConnection).close();
         impl.freeEntry(entry, false, 0, TimeUnit.MILLISECONDS);
     }
 
     @Test
     public void wakesUpWaitingThreadsWhenEntryAvailable() throws Exception {
         useMockOperator();
-        when(mockOperator.createConnection()).thenReturn(mockConnection);
+        Mockito.when(mockOperator.createConnection()).thenReturn(mockConnection);
         impl.setMaxTotalConnections(1);
         BasicPoolEntry entry = impl.requestPoolEntry(route, new Object()).getPoolEntry(-1,
TimeUnit.MILLISECONDS);
         final Flag f = new Flag(false);
@@ -378,7 +381,7 @@ public class TestConnPoolByRoute extends
     @Test
     public void wakesUpWaitingThreadsOnOtherRoutesWhenEntryAvailable() throws Exception {
         useMockOperator();
-        when(mockOperator.createConnection()).thenReturn(mockConnection);
+        Mockito.when(mockOperator.createConnection()).thenReturn(mockConnection);
         impl.setMaxTotalConnections(1);
         BasicPoolEntry entry = impl.requestPoolEntry(route, new Object()).getPoolEntry(-1,
TimeUnit.MILLISECONDS);
         final Flag f = new Flag(false);
@@ -402,7 +405,7 @@ public class TestConnPoolByRoute extends
     @Test
     public void doesNotRecycleExpiredConnections() throws Exception {
         useMockOperator();
-        when(mockOperator.createConnection()).thenReturn(mockConnection, mockConnection2);
+        Mockito.when(mockOperator.createConnection()).thenReturn(mockConnection, mockConnection2);
         BasicPoolEntry entry = impl.requestPoolEntry(route, new Object()).getPoolEntry(-1,
TimeUnit.MILLISECONDS);
         impl.freeEntry(entry, true, 1, TimeUnit.MILLISECONDS);
         Thread.sleep(200L);
@@ -413,20 +416,20 @@ public class TestConnPoolByRoute extends
     @Test
     public void closesExpiredConnectionsWhenNotReusingThem() throws Exception {
         useMockOperator();
-        when(mockOperator.createConnection()).thenReturn(mockConnection, mockConnection2);
+        Mockito.when(mockOperator.createConnection()).thenReturn(mockConnection, mockConnection2);
         BasicPoolEntry entry = impl.requestPoolEntry(route, new Object()).getPoolEntry(-1,
TimeUnit.MILLISECONDS);
         impl.freeEntry(entry, true, 1, TimeUnit.MILLISECONDS);
         Thread.sleep(200L);
         impl.requestPoolEntry(route, new Object()).getPoolEntry(-1, TimeUnit.MILLISECONDS);
-        verify(mockConnection, atLeastOnce()).close();
+        Mockito.verify(mockConnection, Mockito.atLeastOnce()).close();
     }
 
 
     @Test
     public void wakesUpWaitingThreadsOnShutdown() throws Exception {
         useMockOperator();
-        when(mockOperator.createConnection()).thenReturn(mockConnection);
-        when(mockOperator.createConnection()).thenReturn(mockConnection);
+        Mockito.when(mockOperator.createConnection()).thenReturn(mockConnection);
+        Mockito.when(mockOperator.createConnection()).thenReturn(mockConnection);
         impl.setMaxTotalConnections(1);
         impl.requestPoolEntry(route, new Object()).getPoolEntry(-1, TimeUnit.MILLISECONDS);
         final Flag f = new Flag(false);

Modified: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestSpuriousWakeup.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestSpuriousWakeup.java?rev=1350988&r1=1350987&r2=1350988&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestSpuriousWakeup.java
(original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestSpuriousWakeup.java
Sat Jun 16 19:43:06 2012
@@ -41,7 +41,6 @@ import org.apache.http.conn.scheme.Plain
 import org.apache.http.conn.scheme.Scheme;
 import org.apache.http.conn.scheme.SchemeRegistry;
 import org.apache.http.conn.scheme.SchemeSocketFactory;
-import org.apache.http.impl.conn.GetConnThread;
 import org.junit.Assert;
 import org.junit.Test;
 

Copied: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/localserver/LocalServerTestBase.java
(from r1350987, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/localserver/BasicServerTestBase.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/localserver/LocalServerTestBase.java?p2=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/localserver/LocalServerTestBase.java&p1=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/localserver/BasicServerTestBase.java&r1=1350987&r2=1350988&rev=1350988&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/localserver/BasicServerTestBase.java
(original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/localserver/LocalServerTestBase.java
Sat Jun 16 19:43:06 2012
@@ -30,26 +30,16 @@ package org.apache.http.localserver;
 import java.net.InetSocketAddress;
 
 import org.apache.http.HttpHost;
-import org.apache.http.impl.client.DefaultHttpClient;
 import org.junit.After;
-import org.mockito.Mockito;
 
 /**
  * Base class for tests using {@link LocalTestServer}. The server will not be started
  * per default.
  */
-public abstract class BasicServerTestBase extends Mockito {
+public abstract class LocalServerTestBase {
 
     /** The local server for testing. */
     protected LocalTestServer localServer;
-    protected DefaultHttpClient httpclient;
-
-    @After
-    public void shutDownClient() throws Exception {
-        if (httpclient != null) {
-            httpclient.getConnectionManager().shutdown();
-        }
-    }
 
     @After
     public void shutDownServer() throws Exception {
@@ -58,6 +48,14 @@ public abstract class BasicServerTestBas
         }
     }
 
+    protected void startServer() throws Exception {
+        if (localServer == null) {
+            localServer = new LocalTestServer(null, null);
+            localServer.registerDefaultHandlers();
+        }
+        localServer.start();
+    }
+    
     /**
      * Obtains the address of the local test server.
      *

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/localserver/LocalServerTestBase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/localserver/LocalServerTestBase.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/localserver/LocalServerTestBase.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message