diff --git a/src/test/org/apache/http/impl/conn/TestAllConnImpl.java b/src/test/org/apache/http/impl/conn/TestAllConnImpl.java
index 96675ec9b..d3799c090 100644
--- a/src/test/org/apache/http/impl/conn/TestAllConnImpl.java
+++ b/src/test/org/apache/http/impl/conn/TestAllConnImpl.java
@@ -45,6 +45,7 @@ public class TestAllConnImpl extends TestCase {
suite.addTest(TestLocalServer.suite());
suite.addTest(TestTSCCMNoServer.suite());
+ suite.addTest(TestTSCCMWithServer.suite());
return suite;
}
diff --git a/src/test/org/apache/http/impl/conn/TestTSCCMNoServer.java b/src/test/org/apache/http/impl/conn/TestTSCCMNoServer.java
index bb4fbf8ab..5044e988a 100644
--- a/src/test/org/apache/http/impl/conn/TestTSCCMNoServer.java
+++ b/src/test/org/apache/http/impl/conn/TestTSCCMNoServer.java
@@ -374,7 +374,7 @@ public class TestTSCCMNoServer extends TestCase {
HostConfiguration hcfg = route.toHostConfig(); //@@@ deprecated
ManagedClientConnection conn = mgr.getConnection(route);
-
+
assertEquals("connectionsInPool",
mgr.getConnectionsInPool(), 1);
assertEquals("connectionsInPool(host)",
@@ -399,5 +399,6 @@ public class TestTSCCMNoServer extends TestCase {
// testShutdownAll, depends on parameterization and extra threads
// testShutdown, depends on parameterization and extra threads
// testHostReusePreference, depends on parameterization and extra threads
+ // testWaitingThreadInterrupted - depends on extra thread
} // class TestTSCCMNoServer
diff --git a/src/test/org/apache/http/impl/conn/TestTSCCMWithServer.java b/src/test/org/apache/http/impl/conn/TestTSCCMWithServer.java
new file mode 100644
index 000000000..a8b0de55b
--- /dev/null
+++ b/src/test/org/apache/http/impl/conn/TestTSCCMWithServer.java
@@ -0,0 +1,169 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ * ====================================================================
+ * 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
+ * .
+ *
+ */
+
+package org.apache.http.impl.conn;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+
+import org.apache.http.HttpHost;
+import org.apache.http.HttpStatus;
+import org.apache.http.HttpVersion;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.params.HttpParams;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpProtocolParams;
+import org.apache.http.message.BasicHttpRequest;
+import org.apache.http.util.EntityUtils;
+import org.apache.http.conn.Scheme;
+import org.apache.http.conn.SchemeRegistry;
+import org.apache.http.conn.SocketFactory;
+import org.apache.http.conn.PlainSocketFactory;
+import org.apache.http.conn.HttpRoute;
+import org.apache.http.conn.HostConfiguration; //@@@ deprecated
+import org.apache.http.conn.ManagedClientConnection;
+import org.apache.http.conn.ConnectionPoolTimeoutException;
+import org.apache.http.conn.params.HttpConnectionManagerParams;
+import org.apache.http.localserver.ServerTestBase;
+
+
+/**
+ * Tests for ThreadSafeClientConnManager
that do require
+ * a server to communicate with.
+ */
+public class TestTSCCMWithServer extends ServerTestBase {
+
+ public TestTSCCMWithServer(String testName) {
+ super(testName);
+ }
+
+ public static void main(String args[]) {
+ String[] testCaseName = { TestTSCCMWithServer.class.getName() };
+ junit.textui.TestRunner.main(testCaseName);
+ }
+
+ public static Test suite() {
+ return new TestSuite(TestTSCCMWithServer.class);
+ }
+
+
+ /**
+ * Helper to instantiate a ThreadSafeClientConnManager
.
+ *
+ * @param params the parameters, or
+ * null
to use defaults
+ * @param schreg the scheme registry, or
+ * null
to use defaults
+ *
+ * @return a connection manager to test
+ */
+ public ThreadSafeClientConnManager createTSCCM(HttpParams params,
+ SchemeRegistry schreg) {
+ if (params == null)
+ params = defaultParams;
+ if (schreg == null)
+ schreg = supportedSchemes;
+
+ return new ThreadSafeClientConnManager(params, schreg);
+ }
+
+
+ /**
+ * Instantiates default parameters for a connection manager.
+ *
+ * @return the default parameters
+ */
+ public HttpParams createManagerParams() {
+
+ HttpParams params = new BasicHttpParams();
+ HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
+ HttpProtocolParams.setUseExpectContinue(params, false);
+
+ return params;
+ }
+
+
+ /**
+ * Tests releasing and re-using a connection after a response is read.
+ */
+ // public void testReleaseConnection() throws Exception {
+ public void testSkeleton() throws Exception {
+ //@@@ this testcase is not yet complete
+
+ HttpParams mgrpar = createManagerParams();
+ HttpConnectionManagerParams.setDefaultMaxConnectionsPerHost(mgrpar, 1);
+ HttpConnectionManagerParams.setMaxTotalConnections(mgrpar, 3);
+
+ ThreadSafeClientConnManager mgr = createTSCCM(mgrpar, null);
+
+ final HttpRoute route = new HttpRoute(getServerHttp(), null, false);
+ final String uri = "/random/8"; // read 8 bytes
+
+ HttpRequest request =
+ new BasicHttpRequest("GET", uri, HttpVersion.HTTP_1_1);
+
+ ManagedClientConnection conn = mgr.getConnection(route);
+ conn.open(route, httpContext, defaultParams);
+
+ HttpResponse response =
+ httpExecutor.execute(request, conn, httpContext);
+
+ assertEquals("wrong status in response",
+ HttpStatus.SC_OK,
+ response.getStatusLine().getStatusCode());
+ byte[] data = EntityUtils.toByteArray(response.getEntity());
+ // ignore data, but it must be read
+
+ mgr.releaseConnection(conn);
+
+ //@@@ to be checked:
+ // - connection is NOT re-used if not marked before release
+ // - connection is re-used if marked before release
+ // - re-using the connections works
+ }
+
+
+ // List of server-based tests in 3.x TestHttpConnectionManager
+ // The execution framework (HttpClient) used by some of them
+ // can probably be replaced by hand-coded request execution
+ //
+ // testConnectMethodFailureRelease
+ // testDroppedThread
+ // testWriteRequestReleaseConnection, depends on execution framework
+ // testReleaseConnection, depends on execution framework
+ // testResponseAutoRelease
+ // testMaxConnectionsPerServer - what's the server used/needed for?
+ // testReclaimUnusedConnection, depends on execution framework
+ // testGetFromMultipleThreads, depends on execution framework
+
+} // class TestTSCCMWithServer