You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2010/04/23 21:19:31 UTC
svn commit: r937479 [10/12] - in /httpcomponents/httpclient/trunk:
httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/
httpclient-contrib/src/main/java/org/apache/http/contrib/auth/
httpclient/src/main/java/org/apache/http/auth/ httpcl...
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthentication.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthentication.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthentication.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthentication.java Fri Apr 23 19:19:23 2010
@@ -87,15 +87,15 @@ public class TestClientAuthentication ex
httpproc.addInterceptor(new ResponseConnControl());
httpproc.addInterceptor(new RequestBasicAuth());
httpproc.addInterceptor(new ResponseBasicUnauthorized());
-
+
localServer = new LocalTestServer(httpproc, null);
}
-
+
static class AuthHandler implements HttpRequestHandler {
public void handle(
- final HttpRequest request,
- final HttpResponse response,
+ final HttpRequest request,
+ final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
String creds = (String) context.getAttribute("creds");
if (creds == null || !creds.equals("test:test")) {
@@ -106,19 +106,19 @@ public class TestClientAuthentication ex
response.setEntity(entity);
}
}
-
+
}
-
+
static class TestCredentialsProvider implements CredentialsProvider {
private final Credentials creds;
private AuthScope authscope;
-
+
TestCredentialsProvider(final Credentials creds) {
super();
this.creds = creds;
}
-
+
public void clear() {
}
@@ -129,24 +129,24 @@ public class TestClientAuthentication ex
public void setCredentials(AuthScope authscope, Credentials credentials) {
}
-
+
public AuthScope getAuthScope() {
return this.authscope;
}
-
+
}
-
+
public void testBasicAuthenticationNoCreds() throws Exception {
localServer.register("*", new AuthHandler());
localServer.start();
-
+
TestCredentialsProvider credsProvider = new TestCredentialsProvider(null);
-
+
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.setCredentialsProvider(credsProvider);
-
+
HttpGet httpget = new HttpGet("/");
-
+
HttpResponse response = httpclient.execute(getServerHttp(), httpget);
HttpEntity entity = response.getEntity();
assertEquals(HttpStatus.SC_UNAUTHORIZED, response.getStatusLine().getStatusCode());
@@ -156,19 +156,19 @@ public class TestClientAuthentication ex
assertNotNull(authscope);
assertEquals("test realm", authscope.getRealm());
}
-
+
public void testBasicAuthenticationFailure() throws Exception {
localServer.register("*", new AuthHandler());
localServer.start();
-
+
TestCredentialsProvider credsProvider = new TestCredentialsProvider(
new UsernamePasswordCredentials("test", "all-wrong"));
-
+
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.setCredentialsProvider(credsProvider);
-
+
HttpGet httpget = new HttpGet("/");
-
+
HttpResponse response = httpclient.execute(getServerHttp(), httpget);
HttpEntity entity = response.getEntity();
assertEquals(HttpStatus.SC_UNAUTHORIZED, response.getStatusLine().getStatusCode());
@@ -178,19 +178,19 @@ public class TestClientAuthentication ex
assertNotNull(authscope);
assertEquals("test realm", authscope.getRealm());
}
-
+
public void testBasicAuthenticationSuccess() throws Exception {
localServer.register("*", new AuthHandler());
localServer.start();
-
+
TestCredentialsProvider credsProvider = new TestCredentialsProvider(
new UsernamePasswordCredentials("test", "test"));
-
+
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.setCredentialsProvider(credsProvider);
-
+
HttpGet httpget = new HttpGet("/");
-
+
HttpResponse response = httpclient.execute(getServerHttp(), httpget);
HttpEntity entity = response.getEntity();
assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
@@ -204,16 +204,16 @@ public class TestClientAuthentication ex
public void testBasicAuthenticationSuccessOnRepeatablePost() throws Exception {
localServer.register("*", new AuthHandler());
localServer.start();
-
+
TestCredentialsProvider credsProvider = new TestCredentialsProvider(
new UsernamePasswordCredentials("test", "test"));
-
+
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.setCredentialsProvider(credsProvider);
-
+
HttpPost httppost = new HttpPost("/");
httppost.setEntity(new StringEntity("some important stuff", HTTP.ISO_8859_1));
-
+
HttpResponse response = httpclient.execute(getServerHttp(), httppost);
HttpEntity entity = response.getEntity();
assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
@@ -227,18 +227,18 @@ public class TestClientAuthentication ex
public void testBasicAuthenticationFailureOnNonRepeatablePost() throws Exception {
localServer.register("*", new AuthHandler());
localServer.start();
-
+
TestCredentialsProvider credsProvider = new TestCredentialsProvider(
new UsernamePasswordCredentials("test", "test"));
-
+
DefaultHttpClient httpclient = new DefaultHttpClient();
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 {
httpclient.execute(getServerHttp(), httppost);
fail("ClientProtocolException should have been thrown");
@@ -252,51 +252,51 @@ public class TestClientAuthentication ex
static class TestTargetAuthenticationHandler extends DefaultTargetAuthenticationHandler {
private int count;
-
+
public TestTargetAuthenticationHandler() {
super();
this.count = 0;
}
-
+
@Override
public boolean isAuthenticationRequested(
- final HttpResponse response,
+ final HttpResponse response,
final HttpContext context) {
boolean res = super.isAuthenticationRequested(response, context);
if (res == true) {
synchronized (this) {
this.count++;
- }
+ }
}
return res;
}
-
+
public int getCount() {
synchronized (this) {
return this.count;
- }
+ }
}
-
+
}
-
+
public void testBasicAuthenticationCredentialsCaching() throws Exception {
localServer.register("*", new AuthHandler());
localServer.start();
-
+
BasicCredentialsProvider credsProvider = new BasicCredentialsProvider();
- credsProvider.setCredentials(AuthScope.ANY,
+ credsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials("test", "test"));
-
- TestTargetAuthenticationHandler authHandler = new TestTargetAuthenticationHandler();
-
+
+ TestTargetAuthenticationHandler authHandler = new TestTargetAuthenticationHandler();
+
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.setCredentialsProvider(credsProvider);
httpclient.setTargetAuthenticationHandler(authHandler);
-
+
HttpContext context = new BasicHttpContext();
-
+
HttpGet httpget = new HttpGet("/");
-
+
HttpResponse response1 = httpclient.execute(getServerHttp(), httpget, context);
HttpEntity entity1 = response1.getEntity();
assertEquals(HttpStatus.SC_OK, response1.getStatusLine().getStatusCode());
@@ -308,7 +308,7 @@ public class TestClientAuthentication ex
assertEquals(HttpStatus.SC_OK, response2.getStatusLine().getStatusCode());
assertNotNull(entity2);
entity1.consumeContent();
-
+
assertEquals(1, authHandler.getCount());
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestContentCodings.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestContentCodings.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestContentCodings.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestContentCodings.java Fri Apr 23 19:19:23 2010
@@ -64,8 +64,8 @@ import org.apache.http.protocol.HttpRequ
import org.apache.http.util.EntityUtils;
/**
- * Test case for how Content Codings are processed. By default, we want to do the right thing and
- * require no intervention from the user of HttpClient, but we still want to let clients do their
+ * Test case for how Content Codings are processed. By default, we want to do the right thing and
+ * 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 {
@@ -75,9 +75,9 @@ public class TestContentCodings extends
}
/**
- * Test for when we don't get an entity back; e.g. for a 204 or 304 response; nothing blows
+ * 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.
- *
+ *
* @throws Exception
* if there was a problem
*/
@@ -88,8 +88,8 @@ public class TestContentCodings extends
* {@inheritDoc}
*/
public void handle(
- HttpRequest request,
- HttpResponse response,
+ HttpRequest request,
+ HttpResponse response,
HttpContext context) throws HttpException, IOException {
response.setStatusCode(HttpStatus.SC_NO_CONTENT);
}
@@ -106,9 +106,9 @@ public class TestContentCodings extends
}
/**
- * Test for when we are handling content from a server that has correctly interpreted RFC2616
+ * Test for when we are handling content from a server that has correctly interpreted RFC2616
* to return RFC1950 streams for <code>deflate</code> content coding.
- *
+ *
* @throws Exception
* @see DeflateDecompressingEntity
*/
@@ -121,16 +121,16 @@ public class TestContentCodings extends
HttpGet request = new HttpGet("/some-resource");
HttpResponse response = client.execute(getServerHttp(), request);
- assertEquals("The entity text is correctly transported", entityText,
+ assertEquals("The entity text is correctly transported", entityText,
EntityUtils.toString(response.getEntity()));
client.getConnectionManager().shutdown();
}
/**
- * Test for when we are handling content from a server that has incorrectly interpreted RFC2616
+ * Test for when we are handling content from a server that has incorrectly interpreted RFC2616
* to return RFC1951 streams for <code>deflate</code> content coding.
- *
+ *
* @throws Exception
* @see DeflateDecompressingEntity
*/
@@ -142,7 +142,7 @@ public class TestContentCodings extends
DefaultHttpClient client = createHttpClient();
HttpGet request = new HttpGet("/some-resource");
HttpResponse response = client.execute(getServerHttp(), request);
- assertEquals("The entity text is correctly transported", entityText,
+ assertEquals("The entity text is correctly transported", entityText,
EntityUtils.toString(response.getEntity()));
client.getConnectionManager().shutdown();
@@ -150,7 +150,7 @@ public class TestContentCodings extends
/**
* Test for a server returning gzipped content.
- *
+ *
* @throws Exception
*/
public void testGzipSupport() throws Exception {
@@ -161,7 +161,7 @@ public class TestContentCodings extends
DefaultHttpClient client = createHttpClient();
HttpGet request = new HttpGet("/some-resource");
HttpResponse response = client.execute(getServerHttp(), request);
- assertEquals("The entity text is correctly transported", entityText,
+ assertEquals("The entity text is correctly transported", entityText,
EntityUtils.toString(response.getEntity()));
client.getConnectionManager().shutdown();
@@ -169,7 +169,7 @@ public class TestContentCodings extends
/**
* Try with a bunch of client threads, to check that it's thread-safe.
- *
+ *
* @throws Exception
* if there was a problem
*/
@@ -179,7 +179,7 @@ public class TestContentCodings extends
this.localServer.register("*", createGzipEncodingRequestHandler(entityText));
/*
- * Create a load of workers which will access the resource. Half will use the default
+ * Create a load of workers which will access the resource. Half will use the default
* gzip behaviour; half will require identity entity.
*/
int clients = 100;
@@ -189,7 +189,7 @@ public class TestContentCodings extends
ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(schemeRegistry);
cm.setMaxTotalConnections(clients);
-
+
final HttpClient httpClient = new DefaultHttpClient(cm);
ExecutorService executor = Executors.newFixedThreadPool(clients);
@@ -223,9 +223,9 @@ public class TestContentCodings extends
}
/**
- * This test is no longer relevant, since the functionality has been added via a new subclass of
+ * This test is no longer relevant, since the functionality has been added via a new subclass of
* {@link DefaultHttpClient} rather than changing the existing class.
- *
+ *
* @throws Exception
*/
public void removedTestExistingProtocolInterceptorsAreNotAffected() throws Exception {
@@ -283,9 +283,9 @@ public class TestContentCodings extends
client.getConnectionManager().shutdown();
}
/**
- * Checks that we can turn off the new Content-Coding support. The default is that it's on, but that is a change
+ * Checks that we can turn off the new Content-Coding support. The default is that it's on, but that is a change
* to existing behaviour and might not be desirable in some situations.
- *
+ *
* @throws Exception
*/
public void testCanBeDisabledAtRequestTime() throws Exception {
@@ -293,9 +293,9 @@ public class TestContentCodings extends
/* Assume that server will see an Accept-Encoding header. */
final boolean [] sawAcceptEncodingHeader = { true };
-
+
this.localServer.register("*", new HttpRequestHandler() {
-
+
/**
* {@inheritDoc}
*/
@@ -303,30 +303,30 @@ public class TestContentCodings extends
response.setEntity(new StringEntity(entityText));
response.addHeader("Content-Type", "text/plain");
Header[] acceptEncodings = request.getHeaders("Accept-Encoding");
-
+
sawAcceptEncodingHeader[0] = acceptEncodings.length > 0;
}
-
+
});
AbstractHttpClient client = createHttpClient();
HttpGet request = new HttpGet("/some-resource");
client.removeRequestInterceptorByClass(RequestAcceptEncoding.class);
-
+
HttpResponse response = client.execute(getServerHttp(), request);
-
+
assertFalse("The Accept-Encoding header was not there", sawAcceptEncodingHeader[0]);
- assertEquals("The entity isn't treated as gzip or zip content", entityText,
+ assertEquals("The entity isn't treated as gzip or zip content", entityText,
EntityUtils.toString(response.getEntity()));
client.getConnectionManager().shutdown();
}
/**
- * Test that the returned {@link HttpEntity} in the response correctly overrides
+ * Test that the returned {@link HttpEntity} in the response correctly overrides
* {@link HttpEntity#writeTo(OutputStream)} for gzip-encoding.
- *
+ *
* @throws Exception
*/
public void testHttpEntityWriteToForGzip() throws Exception {
@@ -338,18 +338,18 @@ public class TestContentCodings extends
HttpGet request = new HttpGet("/some-resource");
HttpResponse response = client.execute(getServerHttp(), request);
ByteArrayOutputStream out = new ByteArrayOutputStream();
-
+
response.getEntity().writeTo(out);
-
+
assertEquals(entityText, out.toString("utf-8"));
client.getConnectionManager().shutdown();
}
-
+
/**
- * Test that the returned {@link HttpEntity} in the response correctly overrides
+ * Test that the returned {@link HttpEntity} in the response correctly overrides
* {@link HttpEntity#writeTo(OutputStream)} for deflate-encoding.
- *
+ *
* @throws Exception
*/
public void testHttpEntityWriteToForDeflate() throws Exception {
@@ -361,23 +361,23 @@ public class TestContentCodings extends
HttpGet request = new HttpGet("/some-resource");
HttpResponse response = client.execute(getServerHttp(), request);
ByteArrayOutputStream out = new ByteArrayOutputStream();
-
+
response.getEntity().writeTo(out);
-
+
assertEquals(entityText, out.toString("utf-8"));
client.getConnectionManager().shutdown();
}
-
+
/**
- * Creates a new {@link HttpRequestHandler} that will attempt to provide a deflate stream
+ * Creates a new {@link HttpRequestHandler} that will attempt to provide a deflate stream
* Content-Coding.
- *
+ *
* @param entityText
* the non-null String entity text to be returned by the server
* @param rfc1951
- * if true, then the stream returned will be a raw RFC1951 deflate stream, which
- * some servers return as a result of misinterpreting the HTTP 1.1 RFC. If false,
+ * if true, then the stream returned will be a raw RFC1951 deflate stream, which
+ * some servers return as a result of misinterpreting the HTTP 1.1 RFC. If false,
* then it will return an RFC2616 compliant deflate encoded zlib stream.
* @return a non-null {@link HttpRequestHandler}
*/
@@ -389,8 +389,8 @@ public class TestContentCodings extends
* {@inheritDoc}
*/
public void handle(
- HttpRequest request,
- HttpResponse response,
+ HttpRequest request,
+ HttpResponse response,
HttpContext context) throws HttpException, IOException {
response.setEntity(new StringEntity(entityText));
response.addHeader("Content-Type", "text/plain");
@@ -424,9 +424,9 @@ public class TestContentCodings extends
}
/**
- * Returns an {@link HttpRequestHandler} implementation that will attempt to provide a gzip
+ * Returns an {@link HttpRequestHandler} implementation that will attempt to provide a gzip
* Content-Encoding.
- *
+ *
* @param entityText
* the non-null String entity to be returned by the server
* @return a non-null {@link HttpRequestHandler}
@@ -438,8 +438,8 @@ public class TestContentCodings extends
* {@inheritDoc}
*/
public void handle(
- HttpRequest request,
- HttpResponse response,
+ HttpRequest request,
+ HttpResponse response,
HttpContext context) throws HttpException, IOException {
response.setEntity(new StringEntity(entityText));
response.addHeader("Content-Type", "text/plain");
@@ -451,11 +451,11 @@ public class TestContentCodings extends
response.addHeader("Content-Encoding", "gzip");
/*
- * We have to do a bit more work with gzip versus deflate, since
- * Gzip doesn't appear to have an equivalent to DeflaterInputStream in
+ * We have to do a bit more work with gzip versus deflate, since
+ * Gzip doesn't appear to have an equivalent to DeflaterInputStream in
* the JDK.
- *
- * UPDATE: DeflaterInputStream is Java 6 anyway, so we have to do a bit
+ *
+ * UPDATE: DeflaterInputStream is Java 6 anyway, so we have to do a bit
* of work there too!
*/
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
@@ -474,7 +474,7 @@ public class TestContentCodings extends
out.close();
byte[] arr = bytes.toByteArray();
- response.setEntity(new InputStreamEntity(new ByteArrayInputStream(arr),
+ response.setEntity(new InputStreamEntity(new ByteArrayInputStream(arr),
arr.length));
return;
@@ -491,9 +491,9 @@ public class TestContentCodings extends
/**
* Sub-ordinate task passed off to a different thread to be executed.
- *
+ *
* @author jabley
- *
+ *
*/
class WorkerTask implements Runnable {
@@ -539,7 +539,7 @@ public class TestContentCodings extends
/**
* Returns the text of the HTTP entity.
- *
+ *
* @return a String - may be null.
*/
public String getText() {
@@ -567,7 +567,7 @@ public class TestContentCodings extends
/**
* Returns true if this task failed, otherwise false.
- *
+ *
* @return a flag
*/
boolean isFailed() {
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestCookieIdentityComparator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestCookieIdentityComparator.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestCookieIdentityComparator.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestCookieIdentityComparator.java Fri Apr 23 19:19:23 2010
@@ -32,7 +32,7 @@ import junit.framework.*;
/**
* Simple tests for {@link CookieIdentityComparator}.
- *
+ *
* @version $Id:$
*/
public class TestCookieIdentityComparator extends TestCase {
@@ -58,94 +58,94 @@ public class TestCookieIdentityComparato
// ----------------------------------------------------------- Test Methods
public void testCookieIdentityComparasionByName() {
- CookieIdentityComparator comparator = new CookieIdentityComparator();
- BasicClientCookie c1 = new BasicClientCookie("name", "value1");
- BasicClientCookie c2 = new BasicClientCookie("name", "value2");
- assertTrue(comparator.compare(c1, c2) == 0);
-
- BasicClientCookie c3 = new BasicClientCookie("name1", "value");
- BasicClientCookie c4 = new BasicClientCookie("name2", "value");
+ CookieIdentityComparator comparator = new CookieIdentityComparator();
+ BasicClientCookie c1 = new BasicClientCookie("name", "value1");
+ BasicClientCookie c2 = new BasicClientCookie("name", "value2");
+ assertTrue(comparator.compare(c1, c2) == 0);
+
+ BasicClientCookie c3 = new BasicClientCookie("name1", "value");
+ BasicClientCookie c4 = new BasicClientCookie("name2", "value");
assertFalse(comparator.compare(c3, c4) == 0);
}
public void testCookieIdentityComparasionByNameAndDomain() {
- CookieIdentityComparator comparator = new CookieIdentityComparator();
+ CookieIdentityComparator comparator = new CookieIdentityComparator();
BasicClientCookie c1 = new BasicClientCookie("name", "value1");
c1.setDomain("www.domain.com");
- BasicClientCookie c2 = new BasicClientCookie("name", "value2");
+ BasicClientCookie c2 = new BasicClientCookie("name", "value2");
c2.setDomain("www.domain.com");
assertTrue(comparator.compare(c1, c2) == 0);
-
- BasicClientCookie c3 = new BasicClientCookie("name", "value1");
+
+ BasicClientCookie c3 = new BasicClientCookie("name", "value1");
c3.setDomain("www.domain.com");
- BasicClientCookie c4 = new BasicClientCookie("name", "value2");
+ BasicClientCookie c4 = new BasicClientCookie("name", "value2");
c4.setDomain("domain.com");
assertFalse(comparator.compare(c3, c4) == 0);
}
public void testCookieIdentityComparasionByNameAndNullDomain() {
- CookieIdentityComparator comparator = new CookieIdentityComparator();
+ CookieIdentityComparator comparator = new CookieIdentityComparator();
BasicClientCookie c1 = new BasicClientCookie("name", "value1");
c1.setDomain(null);
- BasicClientCookie c2 = new BasicClientCookie("name", "value2");
+ BasicClientCookie c2 = new BasicClientCookie("name", "value2");
c2.setDomain(null);
assertTrue(comparator.compare(c1, c2) == 0);
-
- BasicClientCookie c3 = new BasicClientCookie("name", "value1");
+
+ BasicClientCookie c3 = new BasicClientCookie("name", "value1");
c3.setDomain("www.domain.com");
- BasicClientCookie c4 = new BasicClientCookie("name", "value2");
+ BasicClientCookie c4 = new BasicClientCookie("name", "value2");
c4.setDomain(null);
assertFalse(comparator.compare(c3, c4) == 0);
}
public void testCookieIdentityComparasionByNameAndLocalHost() {
- CookieIdentityComparator comparator = new CookieIdentityComparator();
+ CookieIdentityComparator comparator = new CookieIdentityComparator();
BasicClientCookie c1 = new BasicClientCookie("name", "value1");
c1.setDomain("localhost");
- BasicClientCookie c2 = new BasicClientCookie("name", "value2");
+ BasicClientCookie c2 = new BasicClientCookie("name", "value2");
c2.setDomain("localhost");
assertTrue(comparator.compare(c1, c2) == 0);
-
- BasicClientCookie c3 = new BasicClientCookie("name", "value1");
+
+ BasicClientCookie c3 = new BasicClientCookie("name", "value1");
c3.setDomain("localhost.local");
- BasicClientCookie c4 = new BasicClientCookie("name", "value2");
+ BasicClientCookie c4 = new BasicClientCookie("name", "value2");
c4.setDomain("localhost");
assertTrue(comparator.compare(c3, c4) == 0);
}
public void testCookieIdentityComparasionByNameDomainAndPath() {
- CookieIdentityComparator comparator = new CookieIdentityComparator();
+ CookieIdentityComparator comparator = new CookieIdentityComparator();
BasicClientCookie c1 = new BasicClientCookie("name", "value1");
c1.setDomain("www.domain.com");
c1.setPath("/whatever");
- BasicClientCookie c2 = new BasicClientCookie("name", "value2");
+ BasicClientCookie c2 = new BasicClientCookie("name", "value2");
c2.setDomain("www.domain.com");
c2.setPath("/whatever");
assertTrue(comparator.compare(c1, c2) == 0);
-
- BasicClientCookie c3 = new BasicClientCookie("name", "value1");
+
+ BasicClientCookie c3 = new BasicClientCookie("name", "value1");
c3.setDomain("www.domain.com");
c3.setPath("/whatever");
- BasicClientCookie c4 = new BasicClientCookie("name", "value2");
+ BasicClientCookie c4 = new BasicClientCookie("name", "value2");
c4.setDomain("domain.com");
c4.setPath("/whatever-not");
assertFalse(comparator.compare(c3, c4) == 0);
}
public void testCookieIdentityComparasionByNameDomainAndNullPath() {
- CookieIdentityComparator comparator = new CookieIdentityComparator();
+ CookieIdentityComparator comparator = new CookieIdentityComparator();
BasicClientCookie c1 = new BasicClientCookie("name", "value1");
c1.setDomain("www.domain.com");
c1.setPath("/");
- BasicClientCookie c2 = new BasicClientCookie("name", "value2");
+ BasicClientCookie c2 = new BasicClientCookie("name", "value2");
c2.setDomain("www.domain.com");
c2.setPath(null);
assertTrue(comparator.compare(c1, c2) == 0);
-
- BasicClientCookie c3 = new BasicClientCookie("name", "value1");
+
+ BasicClientCookie c3 = new BasicClientCookie("name", "value1");
c3.setDomain("www.domain.com");
c3.setPath("/whatever");
- BasicClientCookie c4 = new BasicClientCookie("name", "value2");
+ BasicClientCookie c4 = new BasicClientCookie("name", "value2");
c4.setDomain("domain.com");
c4.setPath(null);
assertFalse(comparator.compare(c3, c4) == 0);
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultClientRequestDirector.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultClientRequestDirector.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultClientRequestDirector.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultClientRequestDirector.java Fri Apr 23 19:19:23 2010
@@ -95,14 +95,14 @@ public class TestDefaultClientRequestDir
public static Test suite() {
return new TestSuite(TestDefaultClientRequestDirector.class);
}
-
+
@Override
protected void setUp() throws Exception {
localServer = new LocalTestServer(null, null);
localServer.registerDefaultHandlers();
localServer.start();
}
-
+
/**
* Tests that if abort is called on an {@link AbortableHttpRequest} while
* {@link DefaultRequestDirector} is allocating a connection, that the
@@ -111,13 +111,13 @@ public class TestDefaultClientRequestDir
public void testAbortInAllocate() throws Exception {
CountDownLatch connLatch = new CountDownLatch(1);
CountDownLatch awaitLatch = new CountDownLatch(1);
- final ConMan conMan = new ConMan(connLatch, awaitLatch);
+ final ConMan conMan = new ConMan(connLatch, awaitLatch);
final AtomicReference<Throwable> throwableRef = new AtomicReference<Throwable>();
final CountDownLatch getLatch = new CountDownLatch(1);
- final DefaultHttpClient client = new DefaultHttpClient(conMan, new BasicHttpParams());
+ final DefaultHttpClient client = new DefaultHttpClient(conMan, new BasicHttpParams());
final HttpContext context = new BasicHttpContext();
final HttpGet httpget = new HttpGet("http://www.example.com/a");
-
+
new Thread(new Runnable() {
public void run() {
try {
@@ -129,36 +129,36 @@ public class TestDefaultClientRequestDir
}
}
}).start();
-
+
assertTrue("should have tried to get a connection", connLatch.await(1, TimeUnit.SECONDS));
-
+
httpget.abort();
-
+
assertTrue("should have finished get request", getLatch.await(1, TimeUnit.SECONDS));
assertTrue("should be instanceof IOException, was: " + throwableRef.get(),
throwableRef.get() instanceof IOException);
assertTrue("cause should be InterruptedException, was: " + throwableRef.get().getCause(),
throwableRef.get().getCause() instanceof InterruptedException);
}
-
+
/**
* Tests that an abort called after the connection has been retrieved
* but before a release trigger is set does still abort the request.
*/
public void testAbortAfterAllocateBeforeRequest() throws Exception {
this.localServer.register("*", new BasicService());
-
+
CountDownLatch releaseLatch = new CountDownLatch(1);
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
-
+
SingleClientConnManager conMan = new SingleClientConnManager(registry);
final AtomicReference<Throwable> throwableRef = new AtomicReference<Throwable>();
final CountDownLatch getLatch = new CountDownLatch(1);
- final DefaultHttpClient client = new DefaultHttpClient(conMan, new BasicHttpParams());
+ final DefaultHttpClient client = new DefaultHttpClient(conMan, new BasicHttpParams());
final HttpContext context = new BasicHttpContext();
final HttpGet httpget = new CustomGet("a", releaseLatch);
-
+
new Thread(new Runnable() {
public void run() {
try {
@@ -170,36 +170,36 @@ public class TestDefaultClientRequestDir
}
}
}).start();
-
+
Thread.sleep(100); // Give it a little time to proceed to release...
-
+
httpget.abort();
-
+
releaseLatch.countDown();
-
+
assertTrue("should have finished get request", getLatch.await(1, TimeUnit.SECONDS));
assertTrue("should be instanceof IOException, was: " + throwableRef.get(),
throwableRef.get() instanceof IOException);
}
-
+
/**
* Tests that an abort called completely before execute
* still aborts the request.
*/
public void testAbortBeforeExecute() throws Exception {
this.localServer.register("*", new BasicService());
-
+
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
-
+
SingleClientConnManager conMan = new SingleClientConnManager(registry);
final AtomicReference<Throwable> throwableRef = new AtomicReference<Throwable>();
final CountDownLatch getLatch = new CountDownLatch(1);
final CountDownLatch startLatch = new CountDownLatch(1);
- final DefaultHttpClient client = new DefaultHttpClient(conMan, new BasicHttpParams());
+ final DefaultHttpClient client = new DefaultHttpClient(conMan, new BasicHttpParams());
final HttpContext context = new BasicHttpContext();
final HttpGet httpget = new HttpGet("a");
-
+
new Thread(new Runnable() {
public void run() {
try {
@@ -217,15 +217,15 @@ public class TestDefaultClientRequestDir
}
}
}).start();
-
+
httpget.abort();
startLatch.countDown();
-
+
assertTrue("should have finished get request", getLatch.await(1, TimeUnit.SECONDS));
assertTrue("should be instanceof IOException, was: " + throwableRef.get(),
throwableRef.get() instanceof IOException);
}
-
+
/**
* Tests that an abort called after a redirect has found a new host
* still aborts in the correct place (while trying to get the new
@@ -234,19 +234,19 @@ public class TestDefaultClientRequestDir
public void testAbortAfterRedirectedRoute() throws Exception {
final int port = this.localServer.getServiceAddress().getPort();
this.localServer.register("*", new BasicRedirectService(port));
-
+
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
-
+
CountDownLatch connLatch = new CountDownLatch(1);
CountDownLatch awaitLatch = new CountDownLatch(1);
ConnMan4 conMan = new ConnMan4(registry, connLatch, awaitLatch);
final AtomicReference<Throwable> throwableRef = new AtomicReference<Throwable>();
final CountDownLatch getLatch = new CountDownLatch(1);
- final DefaultHttpClient client = new DefaultHttpClient(conMan, new BasicHttpParams());
+ final DefaultHttpClient client = new DefaultHttpClient(conMan, new BasicHttpParams());
final HttpContext context = new BasicHttpContext();
final HttpGet httpget = new HttpGet("a");
-
+
new Thread(new Runnable() {
public void run() {
try {
@@ -259,44 +259,44 @@ public class TestDefaultClientRequestDir
}
}
}).start();
-
+
assertTrue("should have tried to get a connection", connLatch.await(1, TimeUnit.SECONDS));
-
+
httpget.abort();
-
+
assertTrue("should have finished get request", getLatch.await(1, TimeUnit.SECONDS));
assertTrue("should be instanceof IOException, was: " + throwableRef.get(),
throwableRef.get() instanceof IOException);
assertTrue("cause should be InterruptedException, was: " + throwableRef.get().getCause(),
throwableRef.get().getCause() instanceof InterruptedException);
}
-
-
+
+
/**
* Tests that if a socket fails to connect, the allocated connection is
* properly released back to the connection manager.
*/
public void testSocketConnectFailureReleasesConnection() throws Exception {
final ConnMan2 conMan = new ConnMan2();
- final DefaultHttpClient client = new DefaultHttpClient(conMan, new BasicHttpParams());
+ final DefaultHttpClient client = new DefaultHttpClient(conMan, new BasicHttpParams());
final HttpContext context = new BasicHttpContext();
final HttpGet httpget = new HttpGet("http://www.example.com/a");
-
+
try {
client.execute(httpget, context);
fail("expected IOException");
} catch(IOException expected) {}
-
+
assertNotNull(conMan.allocatedConnection);
assertSame(conMan.allocatedConnection, conMan.releasedConnection);
}
-
+
public void testRequestFailureReleasesConnection() throws Exception {
this.localServer.register("*", new ThrowingService());
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
-
+
ConnMan3 conMan = new ConnMan3(registry);
DefaultHttpClient client = new DefaultHttpClient(conMan, new BasicHttpParams());
HttpGet httpget = new HttpGet("/a");
@@ -309,25 +309,25 @@ public class TestDefaultClientRequestDir
assertNotNull(conMan.allocatedConnection);
assertSame(conMan.allocatedConnection, conMan.releasedConnection);
}
-
+
private static class ThrowingService implements HttpRequestHandler {
public void handle(
- final HttpRequest request,
- final HttpResponse response,
+ final HttpRequest request,
+ final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
throw new IOException();
}
}
-
+
private static class BasicService implements HttpRequestHandler {
- public void handle(final HttpRequest request,
- final HttpResponse response,
+ public void handle(final HttpRequest request,
+ final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
response.setStatusCode(200);
response.setEntity(new StringEntity("Hello World"));
}
}
-
+
private static class BasicRedirectService implements HttpRequestHandler {
private int statuscode = HttpStatus.SC_SEE_OTHER;
private int port;
@@ -350,87 +350,87 @@ public class TestDefaultClientRequestDir
private static class ConnMan4 extends ThreadSafeClientConnManager {
private final CountDownLatch connLatch;
private final CountDownLatch awaitLatch;
-
+
public ConnMan4(SchemeRegistry schreg,
CountDownLatch connLatch, CountDownLatch awaitLatch) {
super(schreg);
this.connLatch = connLatch;
this.awaitLatch = awaitLatch;
}
-
+
@Override
public ClientConnectionRequest requestConnection(HttpRoute route, Object state) {
// If this is the redirect route, stub the return value
// so-as to pretend the host is waiting on a slot...
if(route.getTargetHost().getHostName().equals("localhost")) {
final Thread currentThread = Thread.currentThread();
-
+
return new ClientConnectionRequest() {
-
+
public void abortRequest() {
currentThread.interrupt();
}
-
+
public ManagedClientConnection getConnection(
long timeout, TimeUnit tunit)
throws InterruptedException,
ConnectionPoolTimeoutException {
connLatch.countDown(); // notify waiter that we're getting a connection
-
+
// zero usually means sleep forever, but CountDownLatch doesn't interpret it that way.
if(timeout == 0)
timeout = Integer.MAX_VALUE;
-
+
if(!awaitLatch.await(timeout, tunit))
throw new ConnectionPoolTimeoutException();
-
+
return new ClientConnAdapterMockup(ConnMan4.this);
}
- };
+ };
} else {
return super.requestConnection(route, state);
}
}
}
-
-
+
+
private static class ConnMan3 extends SingleClientConnManager {
private ManagedClientConnection allocatedConnection;
private ManagedClientConnection releasedConnection;
-
+
public ConnMan3(SchemeRegistry schreg) {
super(schreg);
}
-
+
@Override
public ManagedClientConnection getConnection(HttpRoute route, Object state) {
allocatedConnection = super.getConnection(route, state);
return allocatedConnection;
}
-
+
@Override
public void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) {
releasedConnection = conn;
super.releaseConnection(conn, validDuration, timeUnit);
}
-
-
+
+
}
-
+
static class ConnMan2 implements ClientConnectionManager {
-
+
private ManagedClientConnection allocatedConnection;
private ManagedClientConnection releasedConnection;
-
+
public ConnMan2() {
}
public void closeIdleConnections(long idletime, TimeUnit tunit) {
throw new UnsupportedOperationException("just a mockup");
}
-
+
public void closeExpiredConnections() {
- throw new UnsupportedOperationException("just a mockup");
+ throw new UnsupportedOperationException("just a mockup");
}
public ManagedClientConnection getConnection(HttpRoute route) {
@@ -441,17 +441,17 @@ public class TestDefaultClientRequestDir
long timeout, TimeUnit tunit) {
throw new UnsupportedOperationException("just a mockup");
}
-
+
public ClientConnectionRequest requestConnection(
- final HttpRoute route,
+ final HttpRoute route,
final Object state) {
-
+
return new ClientConnectionRequest() {
-
+
public void abortRequest() {
throw new UnsupportedOperationException("just a mockup");
}
-
+
public ManagedClientConnection getConnection(
long timeout, TimeUnit unit)
throws InterruptedException,
@@ -486,11 +486,11 @@ public class TestDefaultClientRequestDir
throw new UnsupportedOperationException("just a mockup");
}
}
-
+
static class ConMan implements ClientConnectionManager {
private final CountDownLatch connLatch;
private final CountDownLatch awaitLatch;
-
+
public ConMan(CountDownLatch connLatch, CountDownLatch awaitLatch) {
this.connLatch = connLatch;
this.awaitLatch = awaitLatch;
@@ -499,9 +499,9 @@ public class TestDefaultClientRequestDir
public void closeIdleConnections(long idletime, TimeUnit tunit) {
throw new UnsupportedOperationException("just a mockup");
}
-
+
public void closeExpiredConnections() {
- throw new UnsupportedOperationException("just a mockup");
+ throw new UnsupportedOperationException("just a mockup");
}
public ManagedClientConnection getConnection(HttpRoute route) {
@@ -512,32 +512,32 @@ public class TestDefaultClientRequestDir
long timeout, TimeUnit tunit) {
throw new UnsupportedOperationException("just a mockup");
}
-
+
public ClientConnectionRequest requestConnection(
final HttpRoute route,
final Object state) {
-
+
final Thread currentThread = Thread.currentThread();
-
+
return new ClientConnectionRequest() {
-
+
public void abortRequest() {
currentThread.interrupt();
}
-
+
public ManagedClientConnection getConnection(
long timeout, TimeUnit tunit)
throws InterruptedException,
ConnectionPoolTimeoutException {
connLatch.countDown(); // notify waiter that we're getting a connection
-
+
// zero usually means sleep forever, but CountDownLatch doesn't interpret it that way.
if(timeout == 0)
timeout = Integer.MAX_VALUE;
-
+
if(!awaitLatch.await(timeout, tunit))
throw new ConnectionPoolTimeoutException();
-
+
return new ClientConnAdapterMockup(ConMan.this);
}
};
@@ -561,7 +561,7 @@ public class TestDefaultClientRequestDir
throw new UnsupportedOperationException("just a mockup");
}
}
-
+
private static class CustomGet extends HttpGet {
private final CountDownLatch releaseTriggerLatch;
@@ -569,7 +569,7 @@ public class TestDefaultClientRequestDir
super(uri);
this.releaseTriggerLatch = releaseTriggerLatch;
}
-
+
@Override
public void setReleaseTrigger(ConnectionReleaseTrigger releaseTrigger) throws IOException {
try {
@@ -578,21 +578,21 @@ public class TestDefaultClientRequestDir
} catch(InterruptedException ie) {
throw new RuntimeException(ie);
}
-
+
super.setReleaseTrigger(releaseTrigger);
}
-
+
}
private static class SimpleService implements HttpRequestHandler {
-
+
public SimpleService() {
super();
}
public void handle(
- final HttpRequest request,
- final HttpResponse response,
+ final HttpRequest request,
+ final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
response.setStatusCode(HttpStatus.SC_OK);
StringEntity entity = new StringEntity("Whatever");
@@ -605,10 +605,10 @@ public class TestDefaultClientRequestDir
this.localServer.register("*", new SimpleService());
HttpHost target = new HttpHost("localhost", port);
-
- DefaultHttpClient client = new DefaultHttpClient();
+
+ DefaultHttpClient client = new DefaultHttpClient();
client.getParams().setParameter(ClientPNames.DEFAULT_HOST, target);
-
+
String s = "/path";
HttpGet httpget = new HttpGet(s);
@@ -626,10 +626,10 @@ public class TestDefaultClientRequestDir
HttpHost target1 = new HttpHost("whatever", 80);
HttpHost target2 = new HttpHost("localhost", port);
-
- DefaultHttpClient client = new DefaultHttpClient();
+
+ DefaultHttpClient client = new DefaultHttpClient();
client.getParams().setParameter(ClientPNames.DEFAULT_HOST, target1);
-
+
String s = "/path";
HttpGet httpget = new HttpGet(s);
httpget.getParams().setParameter(ClientPNames.DEFAULT_HOST, target2);
@@ -643,21 +643,21 @@ public class TestDefaultClientRequestDir
}
private static class FaultyHttpRequestExecutor extends HttpRequestExecutor {
-
+
private static final String MARKER = "marker";
-
+
private final String failureMsg;
public FaultyHttpRequestExecutor(String failureMsg) {
this.failureMsg = failureMsg;
}
-
+
@Override
public HttpResponse execute(
- final HttpRequest request,
- final HttpClientConnection conn,
+ final HttpRequest request,
+ final HttpClientConnection conn,
final HttpContext context) throws IOException, HttpException {
-
+
Object marker = context.getAttribute(MARKER);
if (marker == null) {
context.setAttribute(MARKER, Boolean.TRUE);
@@ -665,13 +665,13 @@ public class TestDefaultClientRequestDir
}
return super.execute(request, conn, context);
}
-
+
}
-
+
private static class FaultyHttpClient extends DefaultHttpClient {
-
+
private final String failureMsg;
-
+
public FaultyHttpClient() {
this("Oppsie");
}
@@ -684,37 +684,37 @@ public class TestDefaultClientRequestDir
protected HttpRequestExecutor createRequestExecutor() {
return new FaultyHttpRequestExecutor(failureMsg);
}
-
+
}
-
-
+
+
public void testAutoGeneratedHeaders() throws Exception {
int port = this.localServer.getServiceAddress().getPort();
this.localServer.register("*", new SimpleService());
-
- FaultyHttpClient client = new FaultyHttpClient();
-
+
+ FaultyHttpClient client = new FaultyHttpClient();
+
client.addRequestInterceptor(new HttpRequestInterceptor() {
public void process(
- final HttpRequest request,
+ final HttpRequest request,
final HttpContext context) throws HttpException, IOException {
request.addHeader("my-header", "stuff");
}
-
- }) ;
-
+
+ }) ;
+
client.setHttpRequestRetryHandler(new HttpRequestRetryHandler() {
public boolean retryRequest(
- final IOException exception,
- int executionCount,
+ final IOException exception,
+ int executionCount,
final HttpContext context) {
return true;
}
-
+
});
-
+
HttpContext context = new BasicHttpContext();
String s = "http://localhost:" + port;
@@ -728,7 +728,7 @@ public class TestDefaultClientRequestDir
HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
ExecutionContext.HTTP_REQUEST);
-
+
assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
assertTrue(reqWrapper instanceof RequestWrapper);
@@ -736,14 +736,14 @@ public class TestDefaultClientRequestDir
assertNotNull(myheaders);
assertEquals(1, myheaders.length);
}
-
+
public void testNonRepeatableEntity() throws Exception {
int port = this.localServer.getServiceAddress().getPort();
this.localServer.register("*", new SimpleService());
-
+
String failureMsg = "a message showing that this failed";
-
- FaultyHttpClient client = new FaultyHttpClient(failureMsg);
+
+ FaultyHttpClient client = new FaultyHttpClient(failureMsg);
HttpContext context = new BasicHttpContext();
String s = "http://localhost:" + port;
@@ -763,5 +763,5 @@ public class TestDefaultClientRequestDir
assertEquals(failureMsg, nonRepeat.getCause().getMessage());
}
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultConnKeepAliveStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultConnKeepAliveStrategy.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultConnKeepAliveStrategy.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultConnKeepAliveStrategy.java Fri Apr 23 19:19:23 2010
@@ -41,7 +41,7 @@ import org.apache.http.protocol.HttpCont
/**
* Simple tests for {@link DefaultConnectionKeepAliveStrategy}.
- *
+ *
*/
public class TestDefaultConnKeepAliveStrategy extends TestCase {
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRedirectLocation.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRedirectLocation.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRedirectLocation.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRedirectLocation.java Fri Apr 23 19:19:23 2010
@@ -58,22 +58,22 @@ public class TestRedirectLocation extend
public void testBasics() throws Exception {
RedirectLocations locations = new RedirectLocations();
-
+
URI uri1 = new URI("/this");
URI uri2 = new URI("/that");
URI uri3 = new URI("/this-and-that");
-
+
locations.add(uri1);
locations.add(uri2);
locations.add(uri2);
locations.add(uri3);
locations.add(uri3);
-
+
Assert.assertTrue(locations.contains(uri1));
Assert.assertTrue(locations.contains(uri2));
Assert.assertTrue(locations.contains(uri3));
Assert.assertFalse(locations.contains(new URI("/")));
-
+
List<URI> list = locations.getAll();
Assert.assertNotNull(list);
Assert.assertEquals(5, list.size());
@@ -82,7 +82,7 @@ public class TestRedirectLocation extend
Assert.assertEquals(uri2, list.get(2));
Assert.assertEquals(uri3, list.get(3));
Assert.assertEquals(uri3, list.get(4));
-
+
Assert.assertTrue(locations.remove(uri3));
Assert.assertTrue(locations.remove(uri1));
Assert.assertFalse(locations.remove(new URI("/")));
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRequestRetryHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRequestRetryHandler.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRequestRetryHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRequestRetryHandler.java Fri Apr 23 19:19:23 2010
@@ -92,7 +92,7 @@ public class TestRequestRetryHandler ext
}
return false;
}
-
+
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRequestWrapper.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRequestWrapper.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRequestWrapper.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRequestWrapper.java Fri Apr 23 19:19:23 2010
@@ -47,7 +47,7 @@ import org.apache.http.protocol.HttpRequ
/**
* Simple tests for {@link RequestWrapper}.
- *
+ *
*/
public class TestRequestWrapper extends BasicServerTestBase {
@@ -74,16 +74,16 @@ public class TestRequestWrapper extends
localServer.registerDefaultHandlers();
localServer.start();
}
-
+
private static class SimpleService implements HttpRequestHandler {
-
+
public SimpleService() {
super();
}
public void handle(
- final HttpRequest request,
- final HttpResponse response,
+ final HttpRequest request,
+ final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
response.setStatusCode(HttpStatus.SC_OK);
StringEntity entity = new StringEntity("Whatever");
@@ -94,8 +94,8 @@ public class TestRequestWrapper extends
public void testRequestURIRewriting() throws Exception {
int port = this.localServer.getServiceAddress().getPort();
this.localServer.register("*", new SimpleService());
-
- DefaultHttpClient client = new DefaultHttpClient();
+
+ DefaultHttpClient client = new DefaultHttpClient();
HttpContext context = new BasicHttpContext();
String s = "http://localhost:" + port + "/path";
@@ -109,7 +109,7 @@ public class TestRequestWrapper extends
HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
ExecutionContext.HTTP_REQUEST);
-
+
assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
assertTrue(reqWrapper instanceof RequestWrapper);
@@ -119,8 +119,8 @@ public class TestRequestWrapper extends
public void testRequestURIRewritingEmptyPath() throws Exception {
int port = this.localServer.getServiceAddress().getPort();
this.localServer.register("*", new SimpleService());
-
- DefaultHttpClient client = new DefaultHttpClient();
+
+ DefaultHttpClient client = new DefaultHttpClient();
HttpContext context = new BasicHttpContext();
String s = "http://localhost:" + port;
@@ -134,7 +134,7 @@ public class TestRequestWrapper extends
HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
ExecutionContext.HTTP_REQUEST);
-
+
assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
assertTrue(reqWrapper instanceof RequestWrapper);
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestStatefulConnManagement.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestStatefulConnManagement.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestStatefulConnManagement.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestStatefulConnManagement.java Fri Apr 23 19:19:23 2010
@@ -68,16 +68,16 @@ public class TestStatefulConnManagement
public static Test suite() {
return new TestSuite(TestStatefulConnManagement.class);
}
-
+
private static class SimpleService implements HttpRequestHandler {
-
+
public SimpleService() {
super();
}
public void handle(
- final HttpRequest request,
- final HttpResponse response,
+ final HttpRequest request,
+ final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
response.setStatusCode(HttpStatus.SC_OK);
StringEntity entity = new StringEntity("Whatever");
@@ -89,22 +89,22 @@ public class TestStatefulConnManagement
int workerCount = 5;
int requestCount = 5;
-
+
int port = this.localServer.getServiceAddress().getPort();
this.localServer.register("*", new SimpleService());
HttpHost target = new HttpHost("localhost", port);
-
+
HttpParams params = new BasicHttpParams();
ConnManagerParams.setTimeout(params, 10L);
-
+
ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(supportedSchemes);
mgr.setMaxTotalConnections(workerCount);
mgr.setDefaultMaxPerRoute(workerCount);
-
-
- DefaultHttpClient client = new DefaultHttpClient(mgr, params);
-
+
+
+ DefaultHttpClient client = new DefaultHttpClient(mgr, params);
+
HttpContext[] contexts = new HttpContext[workerCount];
HttpWorker[] workers = new HttpWorker[workerCount];
for (int i = 0; i < contexts.length; i++) {
@@ -113,17 +113,17 @@ public class TestStatefulConnManagement
contexts[i] = context;
workers[i] = new HttpWorker(context, requestCount, target, client);
}
-
+
client.setUserTokenHandler(new UserTokenHandler() {
public Object getUserToken(final HttpContext context) {
Integer id = (Integer) context.getAttribute("user");
return id;
}
-
+
});
-
-
+
+
for (int i = 0; i < workers.length; i++) {
workers[i].start();
}
@@ -137,32 +137,32 @@ public class TestStatefulConnManagement
}
assertEquals(requestCount, workers[i].getCount());
}
-
+
for (int i = 0; i < contexts.length; i++) {
HttpContext context = contexts[i];
Integer id = (Integer) context.getAttribute("user");
-
+
for (int r = 0; r < requestCount; r++) {
Integer state = (Integer) context.getAttribute("r" + r);
assertNotNull(state);
assertEquals(id, state);
}
}
-
+
}
-
+
static class HttpWorker extends Thread {
private final HttpContext context;
private final int requestCount;
private final HttpHost target;
private final HttpClient httpclient;
-
+
private volatile Exception exception;
private volatile int count;
-
+
public HttpWorker(
- final HttpContext context,
+ final HttpContext context,
int requestCount,
final HttpHost target,
final HttpClient httpclient) {
@@ -173,7 +173,7 @@ public class TestStatefulConnManagement
this.httpclient = httpclient;
this.count = 0;
}
-
+
public int getCount() {
return this.count;
}
@@ -188,27 +188,27 @@ public class TestStatefulConnManagement
for (int r = 0; r < this.requestCount; r++) {
HttpGet httpget = new HttpGet("/");
HttpResponse response = this.httpclient.execute(
- this.target,
- httpget,
+ this.target,
+ httpget,
this.context);
this.count++;
ManagedClientConnection conn = (ManagedClientConnection) this.context.getAttribute(
ExecutionContext.HTTP_CONNECTION);
-
+
this.context.setAttribute("r" + r, conn.getState());
-
+
HttpEntity entity = response.getEntity();
if (entity != null) {
entity.consumeContent();
}
}
-
+
} catch (Exception ex) {
this.exception = ex;
}
}
-
+
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/ExecReqThread.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/ExecReqThread.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/ExecReqThread.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/ExecReqThread.java Fri Apr 23 19:19:23 2010
@@ -41,7 +41,7 @@ import org.apache.http.util.EntityUtils;
/**
* Executes a request from a new thread.
- *
+ *
*/
public class ExecReqThread extends GetConnThread {
@@ -62,7 +62,7 @@ public class ExecReqThread extends GetCo
* <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) {
@@ -72,7 +72,7 @@ public class ExecReqThread extends GetCo
request_spec = reqspec;
}
-
+
public HttpResponse getResponse() {
return response;
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/GetConnThread.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/GetConnThread.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/GetConnThread.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/GetConnThread.java Fri Apr 23 19:19:23 2010
@@ -51,7 +51,7 @@ public class GetConnThread extends Threa
/**
* Creates a new thread for requesting a connection from the given manager.
- *
+ *
* When this thread is started, it will try to obtain a connection.
* The timeout is in milliseconds.
*/
@@ -59,10 +59,10 @@ public class GetConnThread extends Threa
HttpRoute route, long timeout) {
this(mgr.requestConnection(route, null), route, timeout);
}
-
+
/**
* Creates a new for requesting a connection from the given request object.
- *
+ *
* When this thread is started, it will try to obtain a connection.
* The timeout is in milliseconds.
*/
@@ -87,7 +87,7 @@ public class GetConnThread extends Threa
// terminate
}
-
+
public Throwable getException() {
return exception;
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultResponseParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultResponseParser.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultResponseParser.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultResponseParser.java Fri Apr 23 19:19:23 2010
@@ -64,19 +64,19 @@ public class TestDefaultResponseParser e
}
public void testResponseParsingWithSomeGarbage() throws Exception {
- String s =
- "garbage\r\n" +
- "garbage\r\n" +
- "more garbage\r\n" +
- "HTTP/1.1 200 OK\r\n" +
- "header1: value1\r\n" +
- "header2: value2\r\n" +
- "\r\n";
+ String s =
+ "garbage\r\n" +
+ "garbage\r\n" +
+ "more garbage\r\n" +
+ "HTTP/1.1 200 OK\r\n" +
+ "header1: value1\r\n" +
+ "header2: value2\r\n" +
+ "\r\n";
HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuffer = new SessionInputBufferMockup(s, "US-ASCII", params);
+ SessionInputBuffer inbuffer = new SessionInputBufferMockup(s, "US-ASCII", params);
HttpMessageParser parser = new DefaultResponseParser(
- inbuffer,
+ inbuffer,
BasicLineParser.DEFAULT,
new DefaultHttpResponseFactory(),
params);
@@ -94,20 +94,20 @@ public class TestDefaultResponseParser e
}
public void testResponseParsingWithTooMuchGarbage() throws Exception {
- String s =
- "garbage\r\n" +
- "garbage\r\n" +
- "more garbage\r\n" +
- "HTTP/1.1 200 OK\r\n" +
- "header1: value1\r\n" +
- "header2: value2\r\n" +
- "\r\n";
+ String s =
+ "garbage\r\n" +
+ "garbage\r\n" +
+ "more garbage\r\n" +
+ "HTTP/1.1 200 OK\r\n" +
+ "header1: value1\r\n" +
+ "header2: value2\r\n" +
+ "\r\n";
HttpParams params = new BasicHttpParams();
params.setParameter(ConnConnectionPNames.MAX_STATUS_LINE_GARBAGE, Integer.valueOf(2));
- SessionInputBuffer inbuffer = new SessionInputBufferMockup(s, "US-ASCII", params);
+ SessionInputBuffer inbuffer = new SessionInputBufferMockup(s, "US-ASCII", params);
HttpMessageParser parser = new DefaultResponseParser(
- inbuffer,
+ inbuffer,
BasicLineParser.DEFAULT,
new DefaultHttpResponseFactory(),
params);
@@ -121,9 +121,9 @@ public class TestDefaultResponseParser e
public void testResponseParsingNoResponse() throws Exception {
HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuffer = new SessionInputBufferMockup("", "US-ASCII", params);
+ SessionInputBuffer inbuffer = new SessionInputBufferMockup("", "US-ASCII", params);
HttpMessageParser parser = new DefaultResponseParser(
- inbuffer,
+ inbuffer,
BasicLineParser.DEFAULT,
new DefaultHttpResponseFactory(),
params);
@@ -136,15 +136,15 @@ public class TestDefaultResponseParser e
}
public void testResponseParsingOnlyGarbage() throws Exception {
- String s =
- "garbage\r\n" +
- "garbage\r\n" +
- "more garbage\r\n" +
+ String s =
+ "garbage\r\n" +
+ "garbage\r\n" +
+ "more garbage\r\n" +
"a lot more garbage\r\n";
HttpParams params = new BasicHttpParams();
- SessionInputBuffer inbuffer = new SessionInputBufferMockup(s, "US-ASCII", params);
+ SessionInputBuffer inbuffer = new SessionInputBufferMockup(s, "US-ASCII", params);
HttpMessageParser parser = new DefaultResponseParser(
- inbuffer,
+ inbuffer,
BasicLineParser.DEFAULT,
new DefaultHttpResponseFactory(),
params);
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestLocalServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestLocalServer.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestLocalServer.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestLocalServer.java Fri Apr 23 19:19:23 2010
@@ -121,7 +121,7 @@ public class TestLocalServer extends Ser
HttpGet request = new HttpGet(uri);
HttpClientConnection conn = connectTo(target);
-
+
httpContext.setAttribute(
ExecutionContext.HTTP_CONNECTION, conn);
httpContext.setAttribute(
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestSCMWithServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestSCMWithServer.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestSCMWithServer.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestSCMWithServer.java Fri Apr 23 19:19:23 2010
@@ -59,7 +59,7 @@ public class TestSCMWithServer extends S
public static Test suite() {
return new TestSuite(TestSCMWithServer.class);
}
-
+
/**
* Helper to instantiate a <code>SingleClientConnManager</code>.
*
@@ -73,7 +73,7 @@ public class TestSCMWithServer extends S
schreg = supportedSchemes;
return new SingleClientConnManager(schreg);
}
-
+
/**
* Tests that SCM can still connect to the same host after
* a connection was aborted.
@@ -87,7 +87,7 @@ public class TestSCMWithServer extends S
ManagedClientConnection conn = mgr.getConnection(route, null);
assertTrue(conn instanceof AbstractClientConnAdapter);
((AbstractClientConnAdapter) conn).abortConnection();
-
+
conn = mgr.getConnection(route, null);
assertFalse("connection should have been closed", conn.isOpen());
conn.open(route, httpContext, defaultParams);
@@ -95,7 +95,7 @@ public class TestSCMWithServer extends S
mgr.releaseConnection(conn, -1, null);
mgr.shutdown();
}
-
+
/**
* Tests releasing with time limits.
*/
@@ -116,7 +116,7 @@ public class TestSCMWithServer extends S
// a new context is created for each testcase, no need to reset
HttpResponse response = Helper.execute(
- request, conn, target,
+ request, conn, target,
httpExecutor, httpProcessor, defaultParams, httpContext);
assertEquals("wrong status in first response",
@@ -172,7 +172,7 @@ public class TestSCMWithServer extends S
Thread.sleep(150);
conn = mgr.getConnection(route, null);
assertTrue("connection should have been closed", !conn.isOpen());
-
+
// repeat the communication, no need to prepare the request again
conn.open(route, httpContext, defaultParams);
httpContext.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
@@ -186,7 +186,7 @@ public class TestSCMWithServer extends S
assertEquals("wrong length of fourth response entity",
rsplen, data.length);
// ignore data, but it must be read
-
+
mgr.shutdown();
}
@@ -201,9 +201,9 @@ public class TestSCMWithServer extends S
ManagedClientConnection conn = mgr.getConnection(route, null);
conn.open(route, httpContext, defaultParams);
mgr.releaseConnection(conn, 100, TimeUnit.MILLISECONDS);
-
+
mgr.closeExpiredConnections();
-
+
conn = mgr.getConnection(route, null);
assertTrue(conn.isOpen());
mgr.releaseConnection(conn, 100, TimeUnit.MILLISECONDS);
@@ -212,10 +212,10 @@ public class TestSCMWithServer extends S
mgr.closeExpiredConnections();
conn = mgr.getConnection(route, null);
assertFalse(conn.isOpen());
-
+
mgr.shutdown();
}
-
+
public void testAlreadyLeased() throws Exception {
SingleClientConnManager mgr = createSCCM(null);
@@ -225,7 +225,7 @@ public class TestSCMWithServer extends S
ManagedClientConnection conn = mgr.getConnection(route, null);
mgr.releaseConnection(conn, 100, TimeUnit.MILLISECONDS);
-
+
mgr.getConnection(route, null);
try {
mgr.getConnection(route, null);
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestTSCCMNoServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestTSCCMNoServer.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestTSCCMNoServer.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestTSCCMNoServer.java Fri Apr 23 19:19:23 2010
@@ -69,21 +69,21 @@ public class TestTSCCMNoServer extends T
private static ManagedClientConnection getConnection(
- final ClientConnectionManager mgr,
+ final ClientConnectionManager mgr,
final HttpRoute route,
long timeout,
TimeUnit unit) throws ConnectionPoolTimeoutException, InterruptedException {
ClientConnectionRequest connRequest = mgr.requestConnection(route, null);
return connRequest.getConnection(timeout, unit);
}
-
+
private static ManagedClientConnection getConnection(
- final ClientConnectionManager mgr,
+ final ClientConnectionManager mgr,
final HttpRoute route) throws ConnectionPoolTimeoutException, InterruptedException {
ClientConnectionRequest connRequest = mgr.requestConnection(route, null);
return connRequest.getConnection(0, null);
}
-
+
/**
* Helper to instantiate a <code>ThreadSafeClientConnManager</code>.
*
@@ -147,7 +147,7 @@ public class TestTSCCMNoServer extends T
} // testConstructor
- public void testGetConnection()
+ public void testGetConnection()
throws InterruptedException, ConnectionPoolTimeoutException {
ThreadSafeClientConnManager mgr = createTSCCM(null);
@@ -175,7 +175,7 @@ public class TestTSCCMNoServer extends T
// several other tests here rely on timeout behavior
- public void testMaxConnTotal()
+ public void testMaxConnTotal()
throws InterruptedException, ConnectionPoolTimeoutException {
ThreadSafeClientConnManager mgr = createTSCCM(null);
@@ -199,7 +199,7 @@ public class TestTSCCMNoServer extends T
} catch (ConnectionPoolTimeoutException e) {
// expected
}
-
+
// release one of the connections
mgr.releaseConnection(conn2, -1, null);
conn2 = null;
@@ -224,7 +224,7 @@ public class TestTSCCMNoServer extends T
HttpRoute route2 = new HttpRoute(target2, null, false);
HttpHost target3 = new HttpHost("www.test3.invalid", 80, "http");
HttpRoute route3 = new HttpRoute(target3, null, false);
-
+
ThreadSafeClientConnManager mgr = createTSCCM(null);
mgr.setMaxTotalConnections(100);
mgr.setDefaultMaxPerRoute(1);
@@ -248,7 +248,7 @@ public class TestTSCCMNoServer extends T
} catch (ConnectionPoolTimeoutException e) {
// expected
}
-
+
// route 2, limit 2
conn1 = getConnection(mgr, route2, 10L, TimeUnit.MILLISECONDS);
conn2 = getConnection(mgr, route2, 10L, TimeUnit.MILLISECONDS);
@@ -286,7 +286,7 @@ public class TestTSCCMNoServer extends T
}
mgr.shutdown();
- }
+ }
public void testReleaseConnection() throws Exception {
@@ -359,7 +359,7 @@ public class TestTSCCMNoServer extends T
public void testDeleteClosedConnections()
throws InterruptedException, ConnectionPoolTimeoutException {
-
+
ThreadSafeClientConnManager mgr = createTSCCM(null);
HttpHost target = new HttpHost("www.test.invalid", 80, "http");
@@ -520,14 +520,14 @@ public class TestTSCCMNoServer extends T
mgr.shutdown();
}
-
+
public void testAbortAfterRequestStarts() throws Exception {
ThreadSafeClientConnManager mgr = createTSCCM(null);
mgr.setMaxTotalConnections(1);
HttpHost target = new HttpHost("www.test.invalid", 80, "http");
HttpRoute route = new HttpRoute(target, null, false);
-
+
// get the only connection, then start an extra thread
ManagedClientConnection conn = getConnection(mgr, route, 1L, TimeUnit.MILLISECONDS);
ClientConnectionRequest request = mgr.requestConnection(route, null);
@@ -559,19 +559,19 @@ public class TestTSCCMNoServer extends T
mgr.shutdown();
}
-
+
public void testAbortBeforeRequestStarts() throws Exception {
ThreadSafeClientConnManager mgr = createTSCCM(null);
mgr.setMaxTotalConnections(1);
HttpHost target = new HttpHost("www.test.invalid", 80, "http");
HttpRoute route = new HttpRoute(target, null, false);
-
+
// get the only connection, then start an extra thread
ManagedClientConnection conn = getConnection(mgr, route, 1L, TimeUnit.MILLISECONDS);
ClientConnectionRequest request = mgr.requestConnection(route, null);
request.abortRequest();
-
+
GetConnThread gct = new GetConnThread(request, route, 0L); // no timeout
gct.start();
Thread.sleep(100); // give extra thread time to block