hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1350988 [1/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
Author: olegk
Date: Sat Jun 16 19:43:06 2012
New Revision: 1350988

URL: http://svn.apache.org/viewvc?rev=1350988&view=rev
Log:
Restructured HttpClient integration test suite

Added:
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/IntegrationTestBase.java   (with props)
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java   (contents, props changed)
      - copied, changed from r1350987, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestAbortHandling.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthentication.java   (contents, props changed)
      - copied, changed from r1350987, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthentication.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthenticationFallBack.java   (contents, props changed)
      - copied, changed from r1350987, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthenticationFallBack.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientReauthentication.java   (contents, props changed)
      - copied, changed from r1350987, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestClientReauthentication.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientRequestExecution.java   (contents, props changed)
      - copied, changed from r1350987, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultClientRequestDirector.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionAutoRelease.java   (contents, props changed)
      - copied, changed from r1350987, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/conn/TestConnectionAutoRelease.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestContentCodings.java   (contents, props changed)
      - copied, changed from r1350987, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestContentCodings.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestCookie2Support.java   (contents, props changed)
      - copied, changed from r1350987, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/client/protocol/TestCookie2Support.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestRedirects.java   (contents, props changed)
      - copied, changed from r1350987, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/client/protocol/TestRedirects.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestSPNegoScheme.java   (contents, props changed)
      - copied, changed from r1350987, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/auth/TestSPNegoScheme.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestStatefulConnManagement.java   (contents, props changed)
      - copied, changed from r1350987, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestStatefulConnManagement.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/GetConnThread.java   (contents, props changed)
      - copied, changed from r1350987, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/GetConnThread.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/localserver/LocalServerTestBase.java   (contents, props changed)
      - copied, changed from r1350987, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/localserver/BasicServerTestBase.java
Removed:
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/client/protocol/TestCookie2Support.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/client/protocol/TestRedirects.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/client/protocol/TestUriEscapes.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/conn/TestConnectionAutoRelease.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/auth/TestSPNegoScheme.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthentication.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthenticationFallBack.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestClientReauthentication.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestContentCodings.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultClientRequestDirector.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestRequestWrapper.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestStatefulConnManagement.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/GetConnThread.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/Helper.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestAbortHandling.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestLocalServer.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/localserver/BasicServerTestBase.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/localserver/ServerTestBase.java
Modified:
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/client/utils/TestHttpClientUtils.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/conn/ssl/TestSSLSocketFactory.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/ExecReqThread.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestBasicConnManager.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestIdleConnectionEviction.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingConnManager.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingConnManagerNoServer.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestConnPoolByRoute.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestSpuriousWakeup.java

Modified: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/client/utils/TestHttpClientUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/client/utils/TestHttpClientUtils.java?rev=1350988&r1=1350987&r2=1350988&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/client/utils/TestHttpClientUtils.java (original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/client/utils/TestHttpClientUtils.java Sat Jun 16 19:43:06 2012
@@ -26,40 +26,11 @@
  */
 package org.apache.http.client.utils;
 
-import org.apache.http.HttpHost;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.impl.conn.PoolingClientConnectionManager;
-import org.apache.http.localserver.BasicServerTestBase;
-import org.apache.http.localserver.LocalTestServer;
-import org.apache.http.protocol.BasicHttpProcessor;
-import org.apache.http.protocol.ResponseConnControl;
-import org.apache.http.protocol.ResponseContent;
-import org.apache.http.protocol.ResponseDate;
-import org.apache.http.protocol.ResponseServer;
-import org.apache.http.util.EntityUtils;
-import org.junit.Before;
 import org.junit.Test;
 
-public class TestHttpClientUtils extends BasicServerTestBase {
-
-    @Before
-    public void setUp() throws Exception {
-        BasicHttpProcessor httpproc = new BasicHttpProcessor();
-        httpproc.addInterceptor(new ResponseDate());
-        httpproc.addInterceptor(new ResponseServer());
-        httpproc.addInterceptor(new ResponseContent());
-        httpproc.addInterceptor(new ResponseConnControl());
-        this.localServer = new LocalTestServer(httpproc, null);
-    }
-
-    @Test
-    public void testCloseQuietlyClient() throws Exception {
-        HttpClient httpClient = new DefaultHttpClient();
-        HttpClientUtils.closeQuietly(httpClient);
-    }
+public class TestHttpClientUtils {
 
     @Test
     public void testCloseQuietlyNullClient() throws Exception {
@@ -68,58 +39,9 @@ public class TestHttpClientUtils extends
     }
 
     @Test
-    public void testCloseQuietlyClientTwice() {
-        PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager();
-        HttpClient httpClient = new DefaultHttpClient(connectionManager);
-        HttpClientUtils.closeQuietly(httpClient);
-        HttpClientUtils.closeQuietly(httpClient);
-    }
-
-    @Test
-    public void testCloseQuietlyResponse() throws Exception {
-        this.localServer.registerDefaultHandlers();
-        this.localServer.start();
-        PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager();
-        HttpClient httpClient = new DefaultHttpClient(connectionManager);
-        HttpHost target = getServerHttp();
-        HttpResponse response = httpClient.execute(target, new HttpGet("/"));
-        HttpClientUtils.closeQuietly(response);
-        HttpClientUtils.closeQuietly(httpClient);
-    }
-
-    @Test
     public void testCloseQuietlyResponseNull() throws Exception {
-        PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager();
-        HttpClient httpClient = new DefaultHttpClient(connectionManager);
         HttpResponse response = null;
         HttpClientUtils.closeQuietly(response);
-        HttpClientUtils.closeQuietly(httpClient);
-    }
-
-    @Test
-    public void testCloseQuietlyResponseTwice() throws Exception {
-        this.localServer.registerDefaultHandlers();
-        this.localServer.start();
-        PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager();
-        HttpClient httpClient = new DefaultHttpClient(connectionManager);
-        HttpHost target = getServerHttp();
-        HttpResponse response = httpClient.execute(target, new HttpGet("/"));
-        HttpClientUtils.closeQuietly(response);
-        HttpClientUtils.closeQuietly(response);
-        HttpClientUtils.closeQuietly(httpClient);
-    }
-
-    @Test
-    public void testCloseQuietlyResponseAfterConsumeContent() throws Exception {
-        this.localServer.registerDefaultHandlers();
-        this.localServer.start();
-        PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager();
-        HttpClient httpClient = new DefaultHttpClient(connectionManager);
-        HttpHost target = getServerHttp();
-        HttpResponse response = httpClient.execute(target, new HttpGet("/"));
-        EntityUtils.consume(response.getEntity());
-        HttpClientUtils.closeQuietly(response);
-        HttpClientUtils.closeQuietly(httpClient);
     }
 
 }

Modified: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/conn/ssl/TestSSLSocketFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/conn/ssl/TestSSLSocketFactory.java?rev=1350988&r1=1350987&r2=1350988&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/conn/ssl/TestSSLSocketFactory.java (original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/conn/ssl/TestSSLSocketFactory.java Sat Jun 16 19:43:06 2012
@@ -46,12 +46,10 @@ import javax.net.ssl.TrustManager;
 import javax.net.ssl.TrustManagerFactory;
 
 import org.apache.http.HttpHost;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.conn.scheme.Scheme;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.localserver.BasicServerTestBase;
+import org.apache.http.localserver.LocalServerTestBase;
 import org.apache.http.localserver.LocalTestServer;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpParams;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -59,7 +57,7 @@ import org.junit.Test;
 /**
  * Unit tests for {@link SSLSocketFactory}.
  */
-public class TestSSLSocketFactory extends BasicServerTestBase {
+public class TestSSLSocketFactory extends LocalServerTestBase {
 
     private KeyManagerFactory createKeyManagerFactory() throws NoSuchAlgorithmException {
         String algo = KeyManagerFactory.getDefaultAlgorithm();
@@ -108,7 +106,6 @@ public class TestSSLSocketFactory extend
         this.localServer.registerDefaultHandlers();
 
         this.localServer.start();
-        this.httpclient = new DefaultHttpClient();
     }
 
     @Override
@@ -148,15 +145,14 @@ public class TestSSLSocketFactory extend
     public void testBasicSSL() throws Exception {
         TestX509HostnameVerifier hostVerifier = new TestX509HostnameVerifier();
 
+        HttpParams params = new BasicHttpParams();
         SSLSocketFactory socketFactory = new SSLSocketFactory(this.clientSSLContext, hostVerifier);
-        Scheme https = new Scheme("https", 443, socketFactory);
-
-        this.httpclient.getConnectionManager().getSchemeRegistry().register(https);
+        SSLSocket socket = (SSLSocket) socketFactory.createSocket(params);
+        InetSocketAddress address = this.localServer.getServiceAddress();
+        socket = (SSLSocket) socketFactory.connectSocket(socket, address, null, params);
+        SSLSession sslsession = socket.getSession();
 
-        HttpHost target = getServerHttp();
-        HttpGet httpget = new HttpGet("/random/100");
-        HttpResponse response = this.httpclient.execute(target, httpget);
-        Assert.assertEquals(200, response.getStatusLine().getStatusCode());
+        Assert.assertNotNull(sslsession);
         Assert.assertTrue(hostVerifier.isFired());
     }
 
@@ -169,12 +165,10 @@ public class TestSSLSocketFactory extend
         SSLSocketFactory socketFactory = new SSLSocketFactory(defaultsslcontext,
                 SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
 
-        Scheme https = new Scheme("https", 443, socketFactory);
-        this.httpclient.getConnectionManager().getSchemeRegistry().register(https);
-
-        HttpHost target = getServerHttp();
-        HttpGet httpget = new HttpGet("/random/100");
-        this.httpclient.execute(target, httpget);
+        HttpParams params = new BasicHttpParams();
+        SSLSocket socket = (SSLSocket) socketFactory.createSocket(params);
+        InetSocketAddress address = this.localServer.getServiceAddress();
+        socketFactory.connectSocket(socket, address, null, params);
     }
 
     @Test
@@ -192,13 +186,10 @@ public class TestSSLSocketFactory extend
 
         }, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
 
-        Scheme https = new Scheme("https", 443, socketFactory);
-        this.httpclient.getConnectionManager().getSchemeRegistry().register(https);
-
-        HttpHost target = getServerHttp();
-        HttpGet httpget = new HttpGet("/random/100");
-        HttpResponse response = this.httpclient.execute(target, httpget);
-        Assert.assertEquals(200, response.getStatusLine().getStatusCode());
+        HttpParams params = new BasicHttpParams();
+        SSLSocket socket = (SSLSocket) socketFactory.createSocket(params);
+        InetSocketAddress address = this.localServer.getServiceAddress();
+        socketFactory.connectSocket(socket, address, null, params);
     }
 
 }

Added: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/IntegrationTestBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/IntegrationTestBase.java?rev=1350988&view=auto
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/IntegrationTestBase.java (added)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/IntegrationTestBase.java Sat Jun 16 19:43:06 2012
@@ -0,0 +1,47 @@
+/*
+ * ====================================================================
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+package org.apache.http.impl.client.integration;
+
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.localserver.LocalServerTestBase;
+import org.junit.After;
+
+public class IntegrationTestBase extends LocalServerTestBase {
+
+    protected DefaultHttpClient httpclient;
+
+    @After
+    public void shutDownClient() throws Exception {
+        if (this.httpclient != null) {
+            this.httpclient.getConnectionManager().shutdown();
+        }
+    }
+    
+    protected void initClient() {
+        this.httpclient = new DefaultHttpClient();
+    }
+    
+}

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/IntegrationTestBase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/IntegrationTestBase.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/IntegrationTestBase.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java (from r1350987, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestAbortHandling.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java?p2=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java&p1=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestAbortHandling.java&r1=1350987&r2=1350988&rev=1350988&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/TestAbortHandling.java (original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java Sat Jun 16 19:43:06 2012
@@ -24,7 +24,7 @@
  *
  */
 
-package org.apache.http.impl.conn;
+package org.apache.http.impl.client.integration;
 
 import java.io.IOException;
 import java.net.ConnectException;
@@ -50,9 +50,8 @@ import org.apache.http.conn.scheme.Schem
 import org.apache.http.conn.scheme.SchemeRegistry;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.impl.client.DefaultRequestDirector;
-import org.apache.http.localserver.BasicServerTestBase;
-import org.apache.http.localserver.LocalTestServer;
+import org.apache.http.impl.conn.PoolingClientConnectionManager;
+import org.apache.http.impl.conn.SchemeRegistryFactory;
 import org.apache.http.message.BasicHeader;
 import org.apache.http.mockup.SocketFactoryMockup;
 import org.apache.http.params.BasicHttpParams;
@@ -69,14 +68,12 @@ import org.mockito.Mockito;
 /**
  *  Tests for Abort handling.
  */
-public class TestAbortHandling extends BasicServerTestBase {
+public class TestAbortHandling extends IntegrationTestBase {
 
     @Before
     public void setUp() throws Exception {
-        this.localServer = new LocalTestServer(null, null);
-        this.localServer.registerDefaultHandlers();
-        this.localServer.start();
-        this.httpclient = new DefaultHttpClient();
+        initClient();
+        startServer();
     }
 
     @Test

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthentication.java (from r1350987, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthentication.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthentication.java?p2=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthentication.java&p1=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthentication.java&r1=1350987&r2=1350988&rev=1350988&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthentication.java (original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthentication.java Sat Jun 16 19:43:06 2012
@@ -23,7 +23,7 @@
  * <http://www.apache.org/>.
  */
 
-package org.apache.http.impl.client;
+package org.apache.http.impl.client.integration;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
@@ -46,8 +46,9 @@ import org.apache.http.client.methods.Ht
 import org.apache.http.client.methods.HttpPut;
 import org.apache.http.entity.InputStreamEntity;
 import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.TargetAuthenticationStrategy;
 import org.apache.http.localserver.BasicAuthTokenExtractor;
-import org.apache.http.localserver.BasicServerTestBase;
 import org.apache.http.localserver.LocalTestServer;
 import org.apache.http.localserver.RequestBasicAuth;
 import org.apache.http.localserver.ResponseBasicUnauthorized;
@@ -69,7 +70,7 @@ import org.junit.Test;
 /**
  * Unit tests for automatic client authentication.
  */
-public class TestClientAuthentication extends BasicServerTestBase {
+public class TestClientAuthentication extends IntegrationTestBase {
 
     @Before
     public void setUp() throws Exception {
@@ -80,9 +81,9 @@ public class TestClientAuthentication ex
         httpproc.addInterceptor(new ResponseConnControl());
         httpproc.addInterceptor(new RequestBasicAuth());
         httpproc.addInterceptor(new ResponseBasicUnauthorized());
-
         this.localServer = new LocalTestServer(httpproc, null);
-        this.httpclient = new DefaultHttpClient();
+        startServer();
+        initClient();
     }
 
     static class AuthHandler implements HttpRequestHandler {
@@ -156,11 +157,9 @@ public class TestClientAuthentication ex
     @Test
     public void testBasicAuthenticationNoCreds() throws Exception {
         this.localServer.register("*", new AuthHandler());
-        this.localServer.start();
 
         TestCredentialsProvider credsProvider = new TestCredentialsProvider(null);
 
-
         this.httpclient.setCredentialsProvider(credsProvider);
 
         HttpGet httpget = new HttpGet("/");
@@ -178,12 +177,10 @@ public class TestClientAuthentication ex
     @Test
     public void testBasicAuthenticationFailure() throws Exception {
         this.localServer.register("*", new AuthHandler());
-        this.localServer.start();
 
         TestCredentialsProvider credsProvider = new TestCredentialsProvider(
                 new UsernamePasswordCredentials("test", "all-wrong"));
 
-
         this.httpclient.setCredentialsProvider(credsProvider);
 
         HttpGet httpget = new HttpGet("/");
@@ -201,12 +198,10 @@ public class TestClientAuthentication ex
     @Test
     public void testBasicAuthenticationSuccess() throws Exception {
         this.localServer.register("*", new AuthHandler());
-        this.localServer.start();
 
         TestCredentialsProvider credsProvider = new TestCredentialsProvider(
                 new UsernamePasswordCredentials("test", "test"));
 
-
         this.httpclient.setCredentialsProvider(credsProvider);
 
         HttpGet httpget = new HttpGet("/");
@@ -257,7 +252,6 @@ public class TestClientAuthentication ex
     @Test(expected=ClientProtocolException.class)
     public void testBasicAuthenticationFailureOnNonRepeatablePutDontExpectContinue() throws Exception {
         this.localServer.register("*", new AuthHandler());
-        this.localServer.start();
 
         TestCredentialsProvider credsProvider = new TestCredentialsProvider(
                 new UsernamePasswordCredentials("test", "test"));
@@ -286,7 +280,6 @@ public class TestClientAuthentication ex
     @Test
     public void testBasicAuthenticationSuccessOnRepeatablePost() throws Exception {
         this.localServer.register("*", new AuthHandler());
-        this.localServer.start();
 
         TestCredentialsProvider credsProvider = new TestCredentialsProvider(
                 new UsernamePasswordCredentials("test", "test"));
@@ -310,19 +303,16 @@ public class TestClientAuthentication ex
     @Test(expected=ClientProtocolException.class)
     public void testBasicAuthenticationFailureOnNonRepeatablePost() throws Exception {
         this.localServer.register("*", new AuthHandler());
-        this.localServer.start();
 
         TestCredentialsProvider credsProvider = new TestCredentialsProvider(
                 new UsernamePasswordCredentials("test", "test"));
 
-
         this.httpclient.setCredentialsProvider(credsProvider);
 
         HttpPost httppost = new HttpPost("/");
         httppost.setEntity(new InputStreamEntity(
                 new ByteArrayInputStream(
                         new byte[] { 0,1,2,3,4,5,6,7,8,9 }), -1));
-
         try {
             this.httpclient.execute(getServerHttp(), httppost);
             Assert.fail("ClientProtocolException should have been thrown");
@@ -368,7 +358,6 @@ public class TestClientAuthentication ex
     @Test
     public void testBasicAuthenticationCredentialsCaching() throws Exception {
         this.localServer.register("*", new AuthHandler());
-        this.localServer.start();
 
         BasicCredentialsProvider credsProvider = new BasicCredentialsProvider();
         credsProvider.setCredentials(AuthScope.ANY,
@@ -401,7 +390,6 @@ public class TestClientAuthentication ex
     @Test
     public void testAuthenticationUserinfoInRequestSuccess() throws Exception {
         this.localServer.register("*", new AuthHandler());
-        this.localServer.start();
 
         HttpHost target = getServerHttp();
         HttpGet httpget = new HttpGet("http://test:test@" +  target.toHostString() + "/");
@@ -416,7 +404,6 @@ public class TestClientAuthentication ex
     @Test
     public void testAuthenticationUserinfoInRequestFailure() throws Exception {
         this.localServer.register("*", new AuthHandler());
-        this.localServer.start();
 
         HttpHost target = getServerHttp();
         HttpGet httpget = new HttpGet("http://test:all-wrong@" +  target.toHostString() + "/");

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthentication.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthentication.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthentication.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthenticationFallBack.java (from r1350987, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthenticationFallBack.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthenticationFallBack.java?p2=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthenticationFallBack.java&p1=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthenticationFallBack.java&r1=1350987&r2=1350988&rev=1350988&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthenticationFallBack.java (original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthenticationFallBack.java Sat Jun 16 19:43:06 2012
@@ -23,7 +23,7 @@
  * <http://www.apache.org/>.
  */
 
-package org.apache.http.impl.client;
+package org.apache.http.impl.client.integration;
 
 import java.io.IOException;
 
@@ -41,7 +41,6 @@ import org.apache.http.auth.UsernamePass
 import org.apache.http.client.CredentialsProvider;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.entity.StringEntity;
-import org.apache.http.localserver.BasicServerTestBase;
 import org.apache.http.localserver.LocalTestServer;
 import org.apache.http.localserver.RequestBasicAuth;
 import org.apache.http.protocol.BasicHttpProcessor;
@@ -56,7 +55,7 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
-public class TestClientAuthenticationFallBack extends BasicServerTestBase {
+public class TestClientAuthenticationFallBack extends IntegrationTestBase {
 
     public class ResponseBasicUnauthorized implements HttpResponseInterceptor {
 
@@ -82,7 +81,8 @@ public class TestClientAuthenticationFal
         httpproc.addInterceptor(new ResponseBasicUnauthorized());
 
         this.localServer = new LocalTestServer(httpproc, null);
-        this.httpclient = new DefaultHttpClient();
+        startServer();
+        initClient();
     }
 
     static class AuthHandler implements HttpRequestHandler {
@@ -133,7 +133,6 @@ public class TestClientAuthenticationFal
     @Test
     public void testBasicAuthenticationSuccess() throws Exception {
         this.localServer.register("*", new AuthHandler());
-        this.localServer.start();
 
         TestCredentialsProvider credsProvider = new TestCredentialsProvider(
                 new UsernamePasswordCredentials("test", "test"));

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthenticationFallBack.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthenticationFallBack.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthenticationFallBack.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientReauthentication.java (from r1350987, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestClientReauthentication.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientReauthentication.java?p2=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientReauthentication.java&p1=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestClientReauthentication.java&r1=1350987&r2=1350988&rev=1350988&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestClientReauthentication.java (original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientReauthentication.java Sat Jun 16 19:43:06 2012
@@ -23,7 +23,7 @@
  * <http://www.apache.org/>.
  */
 
-package org.apache.http.impl.client;
+package org.apache.http.impl.client.integration;
 
 import java.io.IOException;
 import java.util.concurrent.atomic.AtomicLong;
@@ -42,7 +42,6 @@ import org.apache.http.auth.UsernamePass
 import org.apache.http.client.CredentialsProvider;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.entity.StringEntity;
-import org.apache.http.localserver.BasicServerTestBase;
 import org.apache.http.localserver.LocalTestServer;
 import org.apache.http.localserver.RequestBasicAuth;
 import org.apache.http.protocol.BasicHttpContext;
@@ -58,7 +57,7 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
-public class TestClientReauthentication extends BasicServerTestBase {
+public class TestClientReauthentication extends IntegrationTestBase {
 
     public class ResponseBasicUnauthorized implements HttpResponseInterceptor {
 
@@ -83,7 +82,8 @@ public class TestClientReauthentication 
         httpproc.addInterceptor(new ResponseBasicUnauthorized());
 
         this.localServer = new LocalTestServer(httpproc, null);
-        this.httpclient = new DefaultHttpClient();
+        startServer();
+        initClient();
     }
 
     static class AuthHandler implements HttpRequestHandler {
@@ -141,7 +141,6 @@ public class TestClientReauthentication 
     @Test
     public void testBasicAuthenticationSuccess() throws Exception {
         this.localServer.register("*", new AuthHandler());
-        this.localServer.start();
 
         TestCredentialsProvider credsProvider = new TestCredentialsProvider(
                 new UsernamePasswordCredentials("test", "test"));

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientReauthentication.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientReauthentication.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientReauthentication.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientRequestExecution.java (from r1350987, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultClientRequestDirector.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientRequestExecution.java?p2=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientRequestExecution.java&p1=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultClientRequestDirector.java&r1=1350987&r2=1350988&rev=1350988&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultClientRequestDirector.java (original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientRequestExecution.java Sat Jun 16 19:43:06 2012
@@ -23,7 +23,7 @@
  * <http://www.apache.org/>.
  */
 
-package org.apache.http.impl.client;
+package org.apache.http.impl.client.integration;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
@@ -44,8 +44,7 @@ import org.apache.http.client.methods.Ht
 import org.apache.http.client.params.ClientPNames;
 import org.apache.http.entity.InputStreamEntity;
 import org.apache.http.entity.StringEntity;
-import org.apache.http.localserver.BasicServerTestBase;
-import org.apache.http.localserver.LocalTestServer;
+import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.protocol.BasicHttpContext;
 import org.apache.http.protocol.ExecutionContext;
 import org.apache.http.protocol.HttpContext;
@@ -57,16 +56,14 @@ import org.junit.Before;
 import org.junit.Test;
 
 /**
- * Unit tests for {@link DefaultRequestDirector}
+ * Client protocol handling tests.
  */
-public class TestDefaultClientRequestDirector extends BasicServerTestBase {
+public class TestClientRequestExecution extends IntegrationTestBase {
 
     @Before
     public void setUp() throws Exception {
-        this.localServer = new LocalTestServer(null, null);
-        this.localServer.registerDefaultHandlers();
-        this.localServer.start();
-        this.httpclient = new DefaultHttpClient();
+        startServer();
+        initClient();
     }
 
     private static class SimpleService implements HttpRequestHandler {

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientRequestExecution.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientRequestExecution.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientRequestExecution.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionAutoRelease.java (from r1350987, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/conn/TestConnectionAutoRelease.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionAutoRelease.java?p2=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionAutoRelease.java&p1=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/conn/TestConnectionAutoRelease.java&r1=1350987&r2=1350988&rev=1350988&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/conn/TestConnectionAutoRelease.java (original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionAutoRelease.java Sat Jun 16 19:43:06 2012
@@ -25,7 +25,7 @@
  *
  */
 
-package org.apache.http.conn;
+package org.apache.http.impl.client.integration;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -39,41 +39,50 @@ import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
 import org.apache.http.MalformedChunkCodingException;
 import org.apache.http.client.methods.HttpGet;
+import org.apache.http.conn.ClientConnectionRequest;
+import org.apache.http.conn.ConnectionPoolTimeoutException;
+import org.apache.http.conn.ManagedClientConnection;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.entity.BasicHttpEntity;
 import org.apache.http.impl.DefaultHttpServerConnection;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.impl.conn.PoolingClientConnectionManager;
-import org.apache.http.localserver.ServerTestBase;
 import org.apache.http.pool.PoolStats;
 import org.apache.http.protocol.ExecutionContext;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpRequestHandler;
 import org.apache.http.util.EntityUtils;
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
 
-public class TestConnectionAutoRelease extends ServerTestBase {
+public class TestConnectionAutoRelease extends IntegrationTestBase {
 
+    private PoolingClientConnectionManager mgr;
+    
+    @Before
+    public void setUp() throws Exception {
+        startServer();
+        this.mgr = new PoolingClientConnectionManager();
+        this.httpclient = new DefaultHttpClient(this.mgr);
+    }
+    
     @Test
     public void testReleaseOnEntityConsumeContent() throws Exception {
-        PoolingClientConnectionManager mgr = new PoolingClientConnectionManager();
-        mgr.setDefaultMaxPerRoute(1);
-        mgr.setMaxTotal(1);
+        this.mgr.setDefaultMaxPerRoute(1);
+        this.mgr.setMaxTotal(1);
 
         // Zero connections in the pool
-        PoolStats stats = mgr.getTotalStats();
+        PoolStats stats = this.mgr.getTotalStats();
         Assert.assertEquals(0, stats.getAvailable());
 
-        DefaultHttpClient client = new DefaultHttpClient(mgr);
-
         // Get some random data
         HttpGet httpget = new HttpGet("/random/20000");
         HttpHost target = getServerHttp();
 
-        HttpResponse response = client.execute(target, httpget);
+        HttpResponse response = this.httpclient.execute(target, httpget);
 
-        ClientConnectionRequest connreq = mgr.requestConnection(new HttpRoute(target), null);
+        ClientConnectionRequest connreq = this.mgr.requestConnection(new HttpRoute(target), null);
         try {
             connreq.getConnection(250, TimeUnit.MILLISECONDS);
             Assert.fail("ConnectionPoolTimeoutException should have been thrown");
@@ -85,37 +94,32 @@ public class TestConnectionAutoRelease e
         EntityUtils.consume(e);
 
         // Expect one connection in the pool
-        stats = mgr.getTotalStats();
+        stats = this.mgr.getTotalStats();
         Assert.assertEquals(1, stats.getAvailable());
 
         // Make sure one connection is available
-        connreq = mgr.requestConnection(new HttpRoute(target), null);
+        connreq = this.mgr.requestConnection(new HttpRoute(target), null);
         ManagedClientConnection conn = connreq.getConnection(250, TimeUnit.MILLISECONDS);
 
-        mgr.releaseConnection(conn, -1, null);
-
-        mgr.shutdown();
+        this.mgr.releaseConnection(conn, -1, null);
     }
 
     @Test
     public void testReleaseOnEntityWriteTo() throws Exception {
-        PoolingClientConnectionManager mgr = new PoolingClientConnectionManager();
-        mgr.setDefaultMaxPerRoute(1);
-        mgr.setMaxTotal(1);
+        this.mgr.setDefaultMaxPerRoute(1);
+        this.mgr.setMaxTotal(1);
 
         // Zero connections in the pool
-        PoolStats stats = mgr.getTotalStats();
+        PoolStats stats = this.mgr.getTotalStats();
         Assert.assertEquals(0, stats.getAvailable());
 
-        DefaultHttpClient client = new DefaultHttpClient(mgr);
-
         // Get some random data
         HttpGet httpget = new HttpGet("/random/20000");
         HttpHost target = getServerHttp();
 
-        HttpResponse response = client.execute(target, httpget);
+        HttpResponse response = this.httpclient.execute(target, httpget);
 
-        ClientConnectionRequest connreq = mgr.requestConnection(new HttpRoute(target), null);
+        ClientConnectionRequest connreq = this.mgr.requestConnection(new HttpRoute(target), null);
         try {
             connreq.getConnection(250, TimeUnit.MILLISECONDS);
             Assert.fail("ConnectionPoolTimeoutException should have been thrown");
@@ -128,37 +132,32 @@ public class TestConnectionAutoRelease e
         e.writeTo(outsteam);
 
         // Expect one connection in the pool
-        stats = mgr.getTotalStats();
+        stats = this.mgr.getTotalStats();
         Assert.assertEquals(1, stats.getAvailable());
 
         // Make sure one connection is available
-        connreq = mgr.requestConnection(new HttpRoute(target), null);
+        connreq = this.mgr.requestConnection(new HttpRoute(target), null);
         ManagedClientConnection conn = connreq.getConnection(250, TimeUnit.MILLISECONDS);
 
-        mgr.releaseConnection(conn, -1, null);
-
-        mgr.shutdown();
+        this.mgr.releaseConnection(conn, -1, null);
     }
 
     @Test
     public void testReleaseOnAbort() throws Exception {
-        PoolingClientConnectionManager mgr = new PoolingClientConnectionManager();
-        mgr.setDefaultMaxPerRoute(1);
-        mgr.setMaxTotal(1);
+        this.mgr.setDefaultMaxPerRoute(1);
+        this.mgr.setMaxTotal(1);
 
         // Zero connections in the pool
-        PoolStats stats = mgr.getTotalStats();
+        PoolStats stats = this.mgr.getTotalStats();
         Assert.assertEquals(0, stats.getAvailable());
 
-        DefaultHttpClient client = new DefaultHttpClient(mgr);
-
         // Get some random data
         HttpGet httpget = new HttpGet("/random/20000");
         HttpHost target = getServerHttp();
 
-        HttpResponse response = client.execute(target, httpget);
+        HttpResponse response = this.httpclient.execute(target, httpget);
 
-        ClientConnectionRequest connreq = mgr.requestConnection(new HttpRoute(target), null);
+        ClientConnectionRequest connreq = this.mgr.requestConnection(new HttpRoute(target), null);
         try {
             connreq.getConnection(250, TimeUnit.MILLISECONDS);
             Assert.fail("ConnectionPoolTimeoutException should have been thrown");
@@ -170,21 +169,18 @@ public class TestConnectionAutoRelease e
         httpget.abort();
 
         // Expect zero connections in the pool
-        Assert.assertEquals(0, mgr.getTotalStats().getAvailable());
+        Assert.assertEquals(0, this.mgr.getTotalStats().getAvailable());
 
         // Make sure one connection is available
-        connreq = mgr.requestConnection(new HttpRoute(target), null);
+        connreq = this.mgr.requestConnection(new HttpRoute(target), null);
         ManagedClientConnection conn = connreq.getConnection(250, TimeUnit.MILLISECONDS);
 
-        mgr.releaseConnection(conn, -1, null);
-
-        mgr.shutdown();
+        this.mgr.releaseConnection(conn, -1, null);
     }
 
     @Test
     public void testReleaseOnIOException() throws Exception {
-
-        localServer.register("/dropdead", new HttpRequestHandler() {
+        this.localServer.register("/dropdead", new HttpRequestHandler() {
 
             public void handle(
                     final HttpRequest request,
@@ -216,22 +212,19 @@ public class TestConnectionAutoRelease e
 
         });
 
-        PoolingClientConnectionManager mgr = new PoolingClientConnectionManager();
-        mgr.setDefaultMaxPerRoute(1);
-        mgr.setMaxTotal(1);
+        this.mgr.setDefaultMaxPerRoute(1);
+        this.mgr.setMaxTotal(1);
 
         // Zero connections in the pool
-        Assert.assertEquals(0, mgr.getTotalStats().getAvailable());
-
-        DefaultHttpClient client = new DefaultHttpClient(mgr);
+        Assert.assertEquals(0, this.mgr.getTotalStats().getAvailable());
 
         // Get some random data
         HttpGet httpget = new HttpGet("/dropdead");
         HttpHost target = getServerHttp();
 
-        HttpResponse response = client.execute(target, httpget);
+        HttpResponse response = this.httpclient.execute(target, httpget);
 
-        ClientConnectionRequest connreq = mgr.requestConnection(new HttpRoute(target), null);
+        ClientConnectionRequest connreq = this.mgr.requestConnection(new HttpRoute(target), null);
         try {
             connreq.getConnection(250, TimeUnit.MILLISECONDS);
             Assert.fail("ConnectionPoolTimeoutException should have been thrown");
@@ -249,15 +242,13 @@ public class TestConnectionAutoRelease e
         }
 
         // Expect zero connections in the pool
-        Assert.assertEquals(0, mgr.getTotalStats().getAvailable());
+        Assert.assertEquals(0, this.mgr.getTotalStats().getAvailable());
 
         // Make sure one connection is available
-        connreq = mgr.requestConnection(new HttpRoute(target), null);
+        connreq = this.mgr.requestConnection(new HttpRoute(target), null);
         ManagedClientConnection conn = connreq.getConnection(250, TimeUnit.MILLISECONDS);
 
-        mgr.releaseConnection(conn, -1, null);
-
-        mgr.shutdown();
+        this.mgr.releaseConnection(conn, -1, null);
     }
 
 }

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionAutoRelease.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionAutoRelease.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionAutoRelease.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestContentCodings.java (from r1350987, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestContentCodings.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestContentCodings.java?p2=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestContentCodings.java&p1=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestContentCodings.java&r1=1350987&r2=1350988&rev=1350988&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestContentCodings.java (original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestContentCodings.java Sat Jun 16 19:43:06 2012
@@ -25,7 +25,7 @@
  *
  */
 
-package org.apache.http.impl.client;
+package org.apache.http.impl.client.integration;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -54,12 +54,15 @@ import org.apache.http.conn.scheme.Schem
 import org.apache.http.conn.scheme.SchemeRegistry;
 import org.apache.http.entity.InputStreamEntity;
 import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.BasicResponseHandler;
+import org.apache.http.impl.client.DecompressingHttpClient;
+import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.impl.conn.PoolingClientConnectionManager;
-import org.apache.http.localserver.ServerTestBase;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpRequestHandler;
 import org.apache.http.util.EntityUtils;
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
 
 /**
@@ -67,8 +70,14 @@ import org.junit.Test;
  * require no intervention from the user of HttpClient, but we still want to let clients do their
  * own thing if they so wish.
  */
-public class TestContentCodings extends ServerTestBase {
+public class TestContentCodings extends IntegrationTestBase {
 
+    @Before
+    public void setUp() throws Exception {
+        startServer();
+        initClient();
+    }
+    
     /**
      * Test for when we don't get an entity back; e.g. for a 204 or 304 response; nothing blows
      * up with the new behaviour.

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestContentCodings.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestContentCodings.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestContentCodings.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestCookie2Support.java (from r1350987, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/client/protocol/TestCookie2Support.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestCookie2Support.java?p2=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestCookie2Support.java&p1=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/client/protocol/TestCookie2Support.java&r1=1350987&r2=1350988&rev=1350988&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/client/protocol/TestCookie2Support.java (original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestCookie2Support.java Sat Jun 16 19:43:06 2012
@@ -23,7 +23,7 @@
  * <http://www.apache.org/>.
  */
 
-package org.apache.http.client.protocol;
+package org.apache.http.impl.client.integration;
 
 import java.io.IOException;
 import java.util.List;
@@ -39,14 +39,12 @@ import org.apache.http.client.CookieStor
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.params.ClientPNames;
 import org.apache.http.client.params.CookiePolicy;
+import org.apache.http.client.protocol.ClientContext;
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.SM;
 import org.apache.http.cookie.SetCookie2;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.BasicCookieStore;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.localserver.BasicServerTestBase;
-import org.apache.http.localserver.LocalTestServer;
 import org.apache.http.message.BasicHeader;
 import org.apache.http.protocol.BasicHttpContext;
 import org.apache.http.protocol.ExecutionContext;
@@ -60,14 +58,12 @@ import org.junit.Test;
 /**
  * Cookie2 support tests.
  */
-public class TestCookie2Support extends BasicServerTestBase {
+public class TestCookie2Support extends IntegrationTestBase {
 
     @Before
     public void setUp() throws Exception {
-        this.localServer = new LocalTestServer(null, null);
-        this.localServer.registerDefaultHandlers();
-        this.localServer.start();
-        this.httpclient = new DefaultHttpClient();
+        startServer();
+        initClient();
     }
 
     private static class CookieVer0Service implements HttpRequestHandler {

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestCookie2Support.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestCookie2Support.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestCookie2Support.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestRedirects.java (from r1350987, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/client/protocol/TestRedirects.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestRedirects.java?p2=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestRedirects.java&p1=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/client/protocol/TestRedirects.java&r1=1350987&r2=1350988&rev=1350988&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/client/protocol/TestRedirects.java (original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestRedirects.java Sat Jun 16 19:43:06 2012
@@ -24,7 +24,7 @@
  *
  */
 
-package org.apache.http.client.protocol;
+package org.apache.http.impl.client.integration;
 
 import java.io.IOException;
 import java.net.InetSocketAddress;
@@ -49,10 +49,7 @@ import org.apache.http.client.params.Cli
 import org.apache.http.cookie.SM;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.BasicCookieStore;
-import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.impl.cookie.BasicClientCookie;
-import org.apache.http.localserver.BasicServerTestBase;
-import org.apache.http.localserver.LocalTestServer;
 import org.apache.http.message.BasicHeader;
 import org.apache.http.protocol.BasicHttpContext;
 import org.apache.http.protocol.ExecutionContext;
@@ -67,14 +64,12 @@ import org.junit.Test;
 /**
  * Redirection test cases.
  */
-public class TestRedirects extends BasicServerTestBase {
+public class TestRedirects extends IntegrationTestBase {
 
     @Before
     public void setUp() throws Exception {
-        this.localServer = new LocalTestServer(null, null);
-        this.localServer.registerDefaultHandlers();
-        this.localServer.start();
-        this.httpclient = new DefaultHttpClient();
+        startServer();
+        initClient();
     }
 
     private static class BasicRedirectService implements HttpRequestHandler {

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestRedirects.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestRedirects.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestRedirects.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestSPNegoScheme.java (from r1350987, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/auth/TestSPNegoScheme.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestSPNegoScheme.java?p2=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestSPNegoScheme.java&p1=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/auth/TestSPNegoScheme.java&r1=1350987&r2=1350988&rev=1350988&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/auth/TestSPNegoScheme.java (original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestSPNegoScheme.java Sat Jun 16 19:43:06 2012
@@ -24,7 +24,7 @@
  * <http://www.apache.org/>.
  *
  */
-package org.apache.http.impl.auth;
+package org.apache.http.impl.client.integration;
 
 import java.io.IOException;
 import java.security.Principal;
@@ -41,9 +41,8 @@ import org.apache.http.client.methods.Ht
 import org.apache.http.client.params.AuthPolicy;
 import org.apache.http.client.params.ClientPNames;
 import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.localserver.BasicServerTestBase;
-import org.apache.http.localserver.LocalTestServer;
+import org.apache.http.impl.auth.SPNegoScheme;
+import org.apache.http.impl.auth.SPNegoSchemeFactory;
 import org.apache.http.message.BasicHeader;
 import org.apache.http.params.HttpParams;
 import org.apache.http.protocol.HttpContext;
@@ -64,15 +63,12 @@ import org.mockito.Mockito;
 /**
  * Tests for {@link NegotiateScheme}.
  */
-public class TestSPNegoScheme extends BasicServerTestBase {
+public class TestSPNegoScheme extends IntegrationTestBase {
 
     @Before
     public void setUp() throws Exception {
-        this.localServer = new LocalTestServer(null, null);
-
-        this.localServer.registerDefaultHandlers();
-        this.localServer.start();
-        this.httpclient = new DefaultHttpClient();
+        startServer();
+        initClient();
     }
 
     /**

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestSPNegoScheme.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestSPNegoScheme.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestSPNegoScheme.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestStatefulConnManagement.java (from r1350987, httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestStatefulConnManagement.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestStatefulConnManagement.java?p2=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestStatefulConnManagement.java&p1=httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestStatefulConnManagement.java&r1=1350987&r2=1350988&rev=1350988&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/TestStatefulConnManagement.java (original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestStatefulConnManagement.java Sat Jun 16 19:43:06 2012
@@ -23,7 +23,7 @@
  * <http://www.apache.org/>.
  */
 
-package org.apache.http.impl.client;
+package org.apache.http.impl.client.integration;
 
 import java.io.IOException;
 
@@ -37,8 +37,8 @@ import org.apache.http.client.UserTokenH
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.conn.ManagedClientConnection;
 import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.impl.conn.PoolingClientConnectionManager;
-import org.apache.http.localserver.ServerTestBase;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
@@ -48,12 +48,18 @@ import org.apache.http.protocol.HttpCont
 import org.apache.http.protocol.HttpRequestHandler;
 import org.apache.http.util.EntityUtils;
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
 
 /**
- * Unit tests for {@link DefaultRequestDirector}
+ * Test cases for state-ful connections.
  */
-public class TestStatefulConnManagement extends ServerTestBase {
+public class TestStatefulConnManagement extends IntegrationTestBase {
+
+    @Before
+    public void setUp() throws Exception {
+        startServer();
+    }
 
     private static class SimpleService implements HttpRequestHandler {
 
@@ -85,12 +91,12 @@ public class TestStatefulConnManagement 
         HttpParams params = new BasicHttpParams();
         HttpConnectionParams.setConnectionTimeout(params, 10);
 
-        PoolingClientConnectionManager mgr = new PoolingClientConnectionManager(supportedSchemes);
+        PoolingClientConnectionManager mgr = new PoolingClientConnectionManager();
+        this.httpclient = new DefaultHttpClient(mgr);
         mgr.setMaxTotal(workerCount);
         mgr.setDefaultMaxPerRoute(workerCount);
 
-
-        DefaultHttpClient client = new DefaultHttpClient(mgr, params);
+        this.httpclient.setParams(params);
 
         HttpContext[] contexts = new HttpContext[workerCount];
         HttpWorker[] workers = new HttpWorker[workerCount];
@@ -98,10 +104,10 @@ public class TestStatefulConnManagement 
             HttpContext context = new BasicHttpContext();
             context.setAttribute("user", Integer.valueOf(i));
             contexts[i] = context;
-            workers[i] = new HttpWorker(context, requestCount, target, client);
+            workers[i] = new HttpWorker(context, requestCount, target, this.httpclient);
         }
 
-        client.setUserTokenHandler(new UserTokenHandler() {
+        this.httpclient.setUserTokenHandler(new UserTokenHandler() {
 
             public Object getUserToken(final HttpContext context) {
                 Integer id = (Integer) context.getAttribute("user");
@@ -207,13 +213,12 @@ public class TestStatefulConnManagement 
         this.localServer.register("*", new SimpleService());
 
         // We build a client with 2 max active // connections, and 2 max per route.
-        PoolingClientConnectionManager connMngr = new PoolingClientConnectionManager(supportedSchemes);
+        PoolingClientConnectionManager connMngr = new PoolingClientConnectionManager();
+        this.httpclient = new DefaultHttpClient(connMngr);
         connMngr.setMaxTotal(maxConn);
         connMngr.setDefaultMaxPerRoute(maxConn);
 
-        DefaultHttpClient client = new DefaultHttpClient(connMngr);
-
-        client.setUserTokenHandler(new UserTokenHandler() {
+        this.httpclient.setUserTokenHandler(new UserTokenHandler() {
 
             public Object getUserToken(final HttpContext context) {
                 return context.getAttribute("user");
@@ -224,7 +229,7 @@ public class TestStatefulConnManagement 
         // Bottom of the pool : a *keep alive* connection to Route 1.
         HttpContext context1 = new BasicHttpContext();
         context1.setAttribute("user", "stuff");
-        HttpResponse response1 = client.execute(
+        HttpResponse response1 = this.httpclient.execute(
                 new HttpHost("localhost", port), new HttpGet("/"), context1);
         EntityUtils.consume(response1.getEntity());
 
@@ -237,7 +242,7 @@ public class TestStatefulConnManagement 
         // Send a very simple HTTP get (it MUST be simple, no auth, no proxy, no 302, no 401, ...)
         // Send it to another route. Must be a keepalive.
         HttpContext context2 = new BasicHttpContext();
-        HttpResponse response2 = client.execute(
+        HttpResponse response2 = this.httpclient.execute(
                 new HttpHost("127.0.0.1", port), new HttpGet("/"), context2);
         EntityUtils.consume(response2.getEntity());
         // ConnPoolByRoute now has 2 free connexions, out of its 2 max.
@@ -252,7 +257,7 @@ public class TestStatefulConnManagement 
         // The killed conn is the oldest, which means the first HTTPGet ([localhost][stuff]).
         // When this happens, the RouteSpecificPool becomes empty.
         HttpContext context3 = new BasicHttpContext();
-        HttpResponse response3 = client.execute(
+        HttpResponse response3 = this.httpclient.execute(
                 new HttpHost("localhost", port), new HttpGet("/"), context3);
 
         // If the ConnPoolByRoute did not behave coherently with the RouteSpecificPool

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestStatefulConnManagement.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestStatefulConnManagement.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/client/integration/TestStatefulConnManagement.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/ExecReqThread.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/ExecReqThread.java?rev=1350988&r1=1350987&r2=1350988&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/ExecReqThread.java (original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/test/java/org/apache/http/impl/conn/ExecReqThread.java Sat Jun 16 19:43:06 2012
@@ -27,126 +27,94 @@
 
 package org.apache.http.impl.conn;
 
+import java.util.concurrent.TimeUnit;
+
 import org.apache.http.HttpRequest;
+import org.apache.http.HttpRequestInterceptor;
 import org.apache.http.HttpResponse;
+import org.apache.http.client.protocol.ClientContext;
 import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.ClientConnectionRequest;
+import org.apache.http.conn.ManagedClientConnection;
 import org.apache.http.conn.routing.HttpRoute;
+import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParams;
+import org.apache.http.protocol.BasicHttpContext;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.ExecutionContext;
 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;
 
+class ExecReqThread extends Thread {
 
-/**
- * Executes a request from a new thread.
- *
- */
-public class ExecReqThread extends GetConnThread {
-
-    protected final ClientConnectionManager conn_manager;
-    protected final RequestSpec     request_spec;
-    protected volatile HttpResponse response;
-    protected volatile byte[]       response_data;
-
-
-    /**
-     * Executes a request.
-     * This involves the following steps:
-     * <ol>
-     * <li>obtain a connection (see base class)</li>
-     * <li>open the connection</li>
-     * <li>prepare context and request</li>
-     * <li>execute request to obtain the response</li>
-     * <li>consume the response entity (if there is one)</li>
-     * <li>release the connection</li>
-     * </ol>
-     */
-    public ExecReqThread(ClientConnectionManager mgr,
-                         HttpRoute route, long timeout,
-                         RequestSpec reqspec) {
-        super(mgr, route, timeout);
-        this.conn_manager = mgr;
-
-        request_spec = reqspec;
+    private final HttpRequest request;
+    private final HttpRoute route;
+    private final ClientConnectionManager connman;
+    private final long timeout;
+    
+    private volatile Exception exception;
+    private volatile HttpResponse response;
+    private volatile byte[] response_data;
+
+    public ExecReqThread(
+            HttpRequest request,
+            HttpRoute route, 
+            ClientConnectionManager mgr,
+            long timeout) {
+        super();
+        this.request = request;
+        this.route = route;
+        this.connman = mgr;
+        this.timeout = timeout;
     }
 
+    public Exception getException() {
+        return this.exception;
+    }
 
     public HttpResponse getResponse() {
-        return response;
+        return this.response;
     }
 
     public byte[] getResponseData() {
-        return response_data;
+        return this.response_data;
     }
 
-
-    /**
-     * This method is invoked when the thread is started.
-     * It invokes the base class implementation.
-     */
     @Override
     public void run() {
-        super.run();    // obtain connection
-        if (connection == null)
-            return;     // problem obtaining connection
-
         try {
-            request_spec.context.setAttribute
-                (ExecutionContext.HTTP_CONNECTION, connection);
-
-            doOpenConnection();
-
-            HttpRequest request = (HttpRequest) request_spec.context.
-                getAttribute(ExecutionContext.HTTP_REQUEST);
-            request_spec.executor.preProcess
-                (request, request_spec.processor, request_spec.context);
-
-            response = request_spec.executor.execute
-                (request, connection, request_spec.context);
-
-            request_spec.executor.postProcess
-                (response, request_spec.processor, request_spec.context);
-
-            doConsumeResponse();
-
+            
+            HttpProcessor processor = new ImmutableHttpProcessor(
+                    new HttpRequestInterceptor[] { new RequestContent(), new RequestConnControl() });
+            HttpRequestExecutor executor = new HttpRequestExecutor();
+            HttpContext context = new BasicHttpContext();
+            HttpParams params = new BasicHttpParams();
+            
+            ClientConnectionRequest connRequest = this.connman.requestConnection(this.route, null);
+            ManagedClientConnection conn = connRequest.getConnection(this.timeout, TimeUnit.MILLISECONDS);
+            try {
+                context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, this.route.getTargetHost());
+                context.setAttribute(ClientContext.ROUTE, this.route);
+                context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
+
+                conn.open(this.route, context, params);
+
+                executor.preProcess(this.request, processor, context);
+
+                this.response = executor.execute(this.request, conn, context);
+                if (this.response.getEntity() != null) {
+                    this.response_data = EntityUtils.toByteArray(this.response.getEntity());
+                }
+            } finally {
+                this.connman.releaseConnection(conn, -1, null);
+            }
         } catch (Exception ex) {
-            if (exception != null)
-                exception = ex;
-
-        } finally {
-            conn_manager.releaseConnection(connection, -1, null);
+            this.exception = ex;
         }
     }
 
-
-    /**
-     * Opens the connection after it has been obtained.
-     */
-    protected void doOpenConnection() throws Exception {
-        connection.open
-            (conn_route, request_spec.context, request_spec.params);
-    }
-
-    /**
-     * Reads the response entity, if there is one.
-     */
-    protected void doConsumeResponse() throws Exception {
-        if (response.getEntity() != null)
-            response_data = EntityUtils.toByteArray(response.getEntity());
-    }
-
-
-    /**
-     * Helper class collecting request data.
-     * The request and target are expected in the context.
-     */
-    public static class RequestSpec {
-        public HttpRequestExecutor executor;
-        public HttpProcessor processor;
-        public HttpContext context;
-        public HttpParams params;
-    }
-
 }



Mime
View raw message