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 [9/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/ httpcli...
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRedirects.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRedirects.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRedirects.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRedirects.java Fri Apr 23 19:19:23 2010
@@ -93,9 +93,9 @@ public class TestRedirects extends Basic
localServer.registerDefaultHandlers();
localServer.start();
}
-
+
private static class BasicRedirectService implements HttpRequestHandler {
-
+
private int statuscode = HttpStatus.SC_MOVED_TEMPORARILY;
private String host = null;
private int port;
@@ -114,14 +114,14 @@ public class TestRedirects extends Basic
}
public void handle(
- final HttpRequest request,
- final HttpResponse response,
+ final HttpRequest request,
+ final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
String uri = request.getRequestLine().getUri();
if (uri.equals("/oldlocation/")) {
response.setStatusLine(ver, this.statuscode);
- response.addHeader(new BasicHeader("Location",
+ response.addHeader(new BasicHeader("Location",
"http://" + this.host + ":" + this.port + "/newlocation/"));
response.addHeader(new BasicHeader("Connection", "close"));
} else if (uri.equals("/newlocation/")) {
@@ -139,10 +139,10 @@ public class TestRedirects extends Basic
public CircularRedirectService() {
super();
}
-
+
public void handle(
- final HttpRequest request,
- final HttpResponse response,
+ final HttpRequest request,
+ final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
String uri = request.getRequestLine().getUri();
@@ -159,14 +159,14 @@ public class TestRedirects extends Basic
}
private static class RelativeRedirectService implements HttpRequestHandler {
-
+
public RelativeRedirectService() {
super();
}
public void handle(
- final HttpRequest request,
- final HttpResponse response,
+ final HttpRequest request,
+ final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
String uri = request.getRequestLine().getUri();
@@ -184,14 +184,14 @@ public class TestRedirects extends Basic
}
private static class RelativeRedirectService2 implements HttpRequestHandler {
-
+
public RelativeRedirectService2() {
super();
}
public void handle(
- final HttpRequest request,
- final HttpResponse response,
+ final HttpRequest request,
+ final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
String uri = request.getRequestLine().getUri();
@@ -210,15 +210,15 @@ public class TestRedirects extends Basic
private static class BogusRedirectService implements HttpRequestHandler {
private String url;
-
+
public BogusRedirectService(String redirectUrl) {
super();
this.url = redirectUrl;
}
public void handle(
- final HttpRequest request,
- final HttpResponse response,
+ final HttpRequest request,
+ final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
String uri = request.getRequestLine().getUri();
@@ -239,10 +239,10 @@ public class TestRedirects extends Basic
InetSocketAddress address = this.localServer.getServiceAddress();
int port = address.getPort();
String host = address.getHostName();
- this.localServer.register("*",
+ this.localServer.register("*",
new BasicRedirectService(host, port, HttpStatus.SC_MULTIPLE_CHOICES));
-
- DefaultHttpClient client = new DefaultHttpClient();
+
+ DefaultHttpClient client = new DefaultHttpClient();
HttpContext context = new BasicHttpContext();
HttpGet httpget = new HttpGet("/oldlocation/");
@@ -255,7 +255,7 @@ public class TestRedirects extends Basic
HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
ExecutionContext.HTTP_REQUEST);
-
+
assertEquals(HttpStatus.SC_MULTIPLE_CHOICES, response.getStatusLine().getStatusCode());
assertEquals("/oldlocation/", reqWrapper.getRequestLine().getUri());
}
@@ -264,10 +264,10 @@ public class TestRedirects extends Basic
InetSocketAddress address = this.localServer.getServiceAddress();
int port = address.getPort();
String host = address.getHostName();
- this.localServer.register("*",
+ this.localServer.register("*",
new BasicRedirectService(host, port, HttpStatus.SC_MOVED_PERMANENTLY));
-
- DefaultHttpClient client = new DefaultHttpClient();
+
+ DefaultHttpClient client = new DefaultHttpClient();
HttpContext context = new BasicHttpContext();
HttpGet httpget = new HttpGet("/oldlocation/");
@@ -293,10 +293,10 @@ public class TestRedirects extends Basic
InetSocketAddress address = this.localServer.getServiceAddress();
int port = address.getPort();
String host = address.getHostName();
- this.localServer.register("*",
+ this.localServer.register("*",
new BasicRedirectService(host, port, HttpStatus.SC_MOVED_TEMPORARILY));
-
- DefaultHttpClient client = new DefaultHttpClient();
+
+ DefaultHttpClient client = new DefaultHttpClient();
HttpContext context = new BasicHttpContext();
HttpGet httpget = new HttpGet("/oldlocation/");
@@ -322,10 +322,10 @@ public class TestRedirects extends Basic
InetSocketAddress address = this.localServer.getServiceAddress();
int port = address.getPort();
String host = address.getHostName();
- this.localServer.register("*",
+ this.localServer.register("*",
new BasicRedirectService(host, port, HttpStatus.SC_SEE_OTHER));
-
- DefaultHttpClient client = new DefaultHttpClient();
+
+ DefaultHttpClient client = new DefaultHttpClient();
HttpContext context = new BasicHttpContext();
HttpGet httpget = new HttpGet("/oldlocation/");
@@ -351,10 +351,10 @@ public class TestRedirects extends Basic
InetSocketAddress address = this.localServer.getServiceAddress();
int port = address.getPort();
String host = address.getHostName();
- this.localServer.register("*",
+ this.localServer.register("*",
new BasicRedirectService(host, port, HttpStatus.SC_NOT_MODIFIED));
-
- DefaultHttpClient client = new DefaultHttpClient();
+
+ DefaultHttpClient client = new DefaultHttpClient();
HttpContext context = new BasicHttpContext();
HttpGet httpget = new HttpGet("/oldlocation/");
@@ -367,7 +367,7 @@ public class TestRedirects extends Basic
HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
ExecutionContext.HTTP_REQUEST);
-
+
assertEquals(HttpStatus.SC_NOT_MODIFIED, response.getStatusLine().getStatusCode());
assertEquals("/oldlocation/", reqWrapper.getRequestLine().getUri());
}
@@ -376,10 +376,10 @@ public class TestRedirects extends Basic
InetSocketAddress address = this.localServer.getServiceAddress();
int port = address.getPort();
String host = address.getHostName();
- this.localServer.register("*",
+ this.localServer.register("*",
new BasicRedirectService(host, port, HttpStatus.SC_USE_PROXY));
-
- DefaultHttpClient client = new DefaultHttpClient();
+
+ DefaultHttpClient client = new DefaultHttpClient();
HttpContext context = new BasicHttpContext();
HttpGet httpget = new HttpGet("/oldlocation/");
@@ -392,7 +392,7 @@ public class TestRedirects extends Basic
HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
ExecutionContext.HTTP_REQUEST);
-
+
assertEquals(HttpStatus.SC_USE_PROXY, response.getStatusLine().getStatusCode());
assertEquals("/oldlocation/", reqWrapper.getRequestLine().getUri());
}
@@ -401,10 +401,10 @@ public class TestRedirects extends Basic
InetSocketAddress address = this.localServer.getServiceAddress();
int port = address.getPort();
String host = address.getHostName();
- this.localServer.register("*",
+ this.localServer.register("*",
new BasicRedirectService(host, port, HttpStatus.SC_TEMPORARY_REDIRECT));
-
- DefaultHttpClient client = new DefaultHttpClient();
+
+ DefaultHttpClient client = new DefaultHttpClient();
HttpContext context = new BasicHttpContext();
HttpGet httpget = new HttpGet("/oldlocation/");
@@ -429,7 +429,7 @@ public class TestRedirects extends Basic
public void testMaxRedirectCheck() throws Exception {
this.localServer.register("*", new CircularRedirectService());
- DefaultHttpClient client = new DefaultHttpClient();
+ DefaultHttpClient client = new DefaultHttpClient();
client.getParams().setBooleanParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, true);
client.getParams().setIntParameter(ClientPNames.MAX_REDIRECTS, 5);
@@ -446,7 +446,7 @@ public class TestRedirects extends Basic
public void testCircularRedirect() throws Exception {
this.localServer.register("*", new CircularRedirectService());
- DefaultHttpClient client = new DefaultHttpClient();
+ DefaultHttpClient client = new DefaultHttpClient();
client.getParams().setBooleanParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, false);
HttpGet httpget = new HttpGet("/circular-oldlocation/");
@@ -465,9 +465,9 @@ public class TestRedirects extends Basic
String host = address.getHostName();
this.localServer.register("*", new BasicRedirectService(host, port));
- DefaultHttpClient client = new DefaultHttpClient();
+ DefaultHttpClient client = new DefaultHttpClient();
HttpContext context = new BasicHttpContext();
-
+
HttpPost httppost = new HttpPost("/oldlocation/");
httppost.setEntity(new StringEntity("stuff"));
@@ -476,7 +476,7 @@ public class TestRedirects extends Basic
if (e != null) {
e.consumeContent();
}
-
+
HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
ExecutionContext.HTTP_REQUEST);
@@ -489,12 +489,12 @@ public class TestRedirects extends Basic
InetSocketAddress address = this.localServer.getServiceAddress();
int port = address.getPort();
String host = address.getHostName();
- this.localServer.register("*", new BasicRedirectService(host, port,
+ this.localServer.register("*", new BasicRedirectService(host, port,
HttpStatus.SC_SEE_OTHER));
- DefaultHttpClient client = new DefaultHttpClient();
+ DefaultHttpClient client = new DefaultHttpClient();
HttpContext context = new BasicHttpContext();
-
+
HttpPost httppost = new HttpPost("/oldlocation/");
httppost.setEntity(new StringEntity("stuff"));
@@ -503,7 +503,7 @@ public class TestRedirects extends Basic
if (e != null) {
e.consumeContent();
}
-
+
HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
ExecutionContext.HTTP_REQUEST);
@@ -518,7 +518,7 @@ public class TestRedirects extends Basic
String host = address.getHostName();
this.localServer.register("*", new RelativeRedirectService());
- DefaultHttpClient client = new DefaultHttpClient();
+ DefaultHttpClient client = new DefaultHttpClient();
HttpContext context = new BasicHttpContext();
client.getParams().setBooleanParameter(
@@ -530,7 +530,7 @@ public class TestRedirects extends Basic
if (e != null) {
e.consumeContent();
}
-
+
HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
ExecutionContext.HTTP_REQUEST);
HttpHost targetHost = (HttpHost) context.getAttribute(
@@ -548,7 +548,7 @@ public class TestRedirects extends Basic
String host = address.getHostName();
this.localServer.register("*", new RelativeRedirectService2());
- DefaultHttpClient client = new DefaultHttpClient();
+ DefaultHttpClient client = new DefaultHttpClient();
HttpContext context = new BasicHttpContext();
client.getParams().setBooleanParameter(
@@ -560,7 +560,7 @@ public class TestRedirects extends Basic
if (e != null) {
e.consumeContent();
}
-
+
HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
ExecutionContext.HTTP_REQUEST);
HttpHost targetHost = (HttpHost) context.getAttribute(
@@ -575,7 +575,7 @@ public class TestRedirects extends Basic
public void testRejectRelativeRedirect() throws Exception {
this.localServer.register("*", new RelativeRedirectService());
- DefaultHttpClient client = new DefaultHttpClient();
+ DefaultHttpClient client = new DefaultHttpClient();
client.getParams().setBooleanParameter(
ClientPNames.REJECT_RELATIVE_REDIRECT, true);
@@ -593,7 +593,7 @@ public class TestRedirects extends Basic
public void testRejectBogusRedirectLocation() throws Exception {
this.localServer.register("*", new BogusRedirectService("xxx://bogus"));
- DefaultHttpClient client = new DefaultHttpClient();
+ DefaultHttpClient client = new DefaultHttpClient();
HttpGet httpget = new HttpGet("/oldlocation/");
@@ -609,10 +609,10 @@ public class TestRedirects extends Basic
InetSocketAddress address = this.localServer.getServiceAddress();
int port = address.getPort();
String host = address.getHostName();
- this.localServer.register("*",
+ this.localServer.register("*",
new BogusRedirectService("http://"+ host +":"+ port +"/newlocation/?p=I have spaces"));
- DefaultHttpClient client = new DefaultHttpClient();
+ DefaultHttpClient client = new DefaultHttpClient();
HttpGet httpget = new HttpGet("/oldlocation/");
@@ -630,30 +630,30 @@ public class TestRedirects extends Basic
int port = address.getPort();
String host = address.getHostName();
- this.localServer.register("*",
+ this.localServer.register("*",
new BasicRedirectService(host, port));
- DefaultHttpClient client = new DefaultHttpClient();
-
+ DefaultHttpClient client = new DefaultHttpClient();
+
CookieStore cookieStore = new BasicCookieStore();
client.setCookieStore(cookieStore);
-
+
BasicClientCookie cookie = new BasicClientCookie("name", "value");
cookie.setDomain(host);
cookie.setPath("/");
-
+
cookieStore.addCookie(cookie);
HttpContext context = new BasicHttpContext();
HttpGet httpget = new HttpGet("/oldlocation/");
-
+
HttpResponse response = client.execute(getServerHttp(), httpget, context);
HttpEntity e = response.getEntity();
if (e != null) {
e.consumeContent();
}
-
+
HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
ExecutionContext.HTTP_REQUEST);
@@ -661,7 +661,7 @@ public class TestRedirects extends Basic
assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());
Header[] headers = reqWrapper.getHeaders(SM.COOKIE);
- assertEquals("There can only be one (cookie)", 1, headers.length);
+ assertEquals("There can only be one (cookie)", 1, headers.length);
}
public void testDefaultHeadersRedirect() throws Exception {
@@ -669,26 +669,26 @@ public class TestRedirects extends Basic
int port = address.getPort();
String host = address.getHostName();
- this.localServer.register("*",
+ this.localServer.register("*",
new BasicRedirectService(host, port));
- DefaultHttpClient client = new DefaultHttpClient();
+ DefaultHttpClient client = new DefaultHttpClient();
HttpContext context = new BasicHttpContext();
List<Header> defaultHeaders = new ArrayList<Header>(1);
defaultHeaders.add(new BasicHeader(HTTP.USER_AGENT, "my-test-client"));
-
+
client.getParams().setParameter(ClientPNames.DEFAULT_HEADERS, defaultHeaders);
-
+
HttpGet httpget = new HttpGet("/oldlocation/");
-
+
HttpResponse response = client.execute(getServerHttp(), httpget, context);
HttpEntity e = response.getEntity();
if (e != null) {
e.consumeContent();
}
-
+
HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
ExecutionContext.HTTP_REQUEST);
@@ -696,7 +696,7 @@ public class TestRedirects extends Basic
assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());
Header header = reqWrapper.getFirstHeader(HTTP.USER_AGENT);
- assertEquals("my-test-client", header.getValue());
+ assertEquals("my-test-client", header.getValue());
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestUriEscapes.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestUriEscapes.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestUriEscapes.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestUriEscapes.java Fri Apr 23 19:19:23 2010
@@ -60,21 +60,21 @@ public class TestUriEscapes extends Basi
public static Test suite() {
return new TestSuite(TestUriEscapes.class);
}
-
+
@Override
protected void setUp() throws Exception {
localServer = new LocalTestServer(null, null);
localServer.registerDefaultHandlers();
localServer.start();
}
-
+
private static class UriListeningService implements HttpRequestHandler {
-
+
private volatile String requestedUri;
public void handle(
- final HttpRequest request,
- final HttpResponse response,
+ final HttpRequest request,
+ final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
this.requestedUri = request.getRequestLine().getUri();
@@ -82,82 +82,82 @@ public class TestUriEscapes extends Basi
StringEntity entity = new StringEntity("Response Body");
response.setEntity(entity);
}
-
+
public String getRequestedUri() {
return requestedUri;
}
}
-
+
private void doTest(String uri, boolean relative) throws Exception {
InetSocketAddress address = this.localServer.getServiceAddress();
int port = address.getPort();
String host = address.getHostName();
UriListeningService listener = new UriListeningService();
this.localServer.register("*", listener);
-
- DefaultHttpClient client = new DefaultHttpClient();
+
+ DefaultHttpClient client = new DefaultHttpClient();
HttpResponse response;
if(!relative) {
String request = "http://" + host + ":" + port + uri;
- HttpGet httpget = new HttpGet(request);
+ HttpGet httpget = new HttpGet(request);
response = client.execute(httpget);
- response.getEntity().consumeContent();
+ response.getEntity().consumeContent();
} else {
HttpHost target = new HttpHost(host, port);
- HttpGet httpget = new HttpGet(uri);
+ HttpGet httpget = new HttpGet(uri);
response = client.execute(target, httpget);
- response.getEntity().consumeContent();
+ response.getEntity().consumeContent();
}
-
- assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
+
+ assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
assertEquals(uri, listener.getRequestedUri());
}
-
+
public void testEscapedAmpersandInQueryAbsolute() throws Exception {
doTest("/path/a=b&c=%26d", false);
}
-
+
public void testEscapedAmpersandInQueryRelative() throws Exception {
doTest("/path/a=b&c=%26d", true);
}
-
+
public void testPlusInPathAbsolute() throws Exception {
doTest("/path+go", false);
}
-
+
public void testPlusInPathRelative() throws Exception {
doTest("/path+go", true);
}
-
+
public void testEscapedSpaceInPathAbsolute() throws Exception {
doTest("/path%20go?a=b&c=d", false);
}
-
+
public void testEscapedSpaceInPathRelative() throws Exception {
doTest("/path%20go?a=b&c=d", true);
}
-
+
public void testEscapedAmpersandInPathAbsolute() throws Exception {
doTest("/this%26that?a=b&c=d", false);
}
-
+
public void testEscapedAmpersandInPathRelative() throws Exception {
doTest("/this%26that?a=b&c=d", true);
}
-
+
public void testEscapedSpaceInQueryAbsolute() throws Exception {
doTest("/path?a=b&c=d%20e", false);
}
-
+
public void testEscapedSpaceInQueryRelative() throws Exception {
doTest("/path?a=b&c=d%20e", true);
}
-
+
public void testPlusInQueryAbsolute() throws Exception {
doTest("/path?a=b&c=d+e", false);
}
-
+
public void testPlusInQueryRelative() throws Exception {
doTest("/path?a=b&c=d+e", true);
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestRfc3492Idn.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestRfc3492Idn.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestRfc3492Idn.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestRfc3492Idn.java Fri Apr 23 19:19:23 2010
@@ -36,7 +36,7 @@ public class TestRfc3492Idn extends Test
public TestRfc3492Idn(String testName) {
super(testName);
}
-
+
public static void main(String args[]) {
String[] testCaseName = { TestRfc3492Idn.class.getName() };
junit.textui.TestRunner.main(testCaseName);
@@ -45,17 +45,17 @@ public class TestRfc3492Idn extends Test
public static Test suite() {
return new TestSuite(TestRfc3492Idn.class);
}
-
+
/**
- * Some of the sample strings from RFC 3492
+ * Some of the sample strings from RFC 3492
*/
public void testDecode() throws Exception {
Rfc3492Idn idn = new Rfc3492Idn();
// (A) Arabic
- assertEquals("\u0644\u064A\u0647\u0645\u0627\u0628\u062A\u0643\u0644" +
+ assertEquals("\u0644\u064A\u0647\u0645\u0627\u0628\u062A\u0643\u0644" +
"\u0645\u0648\u0634\u0639\u0631\u0628\u064A\u061F",
idn.decode("egbpdaj6bu4bxfgehfvwxn"));
-
+
// (B) Chinese (simplified)
assertEquals("\u4ED6\u4EEC\u4E3A\u4EC0\u4E48\u4E0D\u8BF4\u4E2D\u6587",
idn.decode("ihqwcrb4cv8a8dqg056pqjye"));
@@ -66,25 +66,25 @@ public class TestRfc3492Idn extends Test
"\u044F\u0442\u043F\u043E\u0440\u0443\u0441\u0441\u043A"+
"\u0438",
idn.decode("b1abfaaepdrnnbgefbaDotcwatmq2g4l"));
-
+
// (P) Maji<de>Koi<suru>5<byou><mae>
- assertEquals("\u004D\u0061\u006A\u0069\u3067\u004B\u006F\u0069\u3059" +
- "\u308B\u0035\u79D2\u524D",
+ assertEquals("\u004D\u0061\u006A\u0069\u3067\u004B\u006F\u0069\u3059" +
+ "\u308B\u0035\u79D2\u524D",
idn.decode("MajiKoi5-783gue6qz075azm5e"));
}
-
+
public void testToUnicode() throws Exception {
Rfc3492Idn idn = new Rfc3492Idn();
// (A) Arabic
- assertEquals("\u0644\u064A\u0647\u0645\u0627\u0628\u062A\u0643\u0644" +
+ assertEquals("\u0644\u064A\u0647\u0645\u0627\u0628\u062A\u0643\u0644" +
"\u0645\u0648\u0634\u0639\u0631\u0628\u064A\u061F",
idn.toUnicode("xn--egbpdaj6bu4bxfgehfvwxn"));
-
+
// some real-world domains
assertEquals("www.z\u00fcrich.ch",
idn.toUnicode("www.xn--zrich-kva.ch"));
-
+
assertEquals("www.g\u00e4ggelig\u00e4\u00e4l.ch",
idn.toUnicode("www.xn--gggeligl-0zaga.ch"));
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURLEncodedUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURLEncodedUtils.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURLEncodedUtils.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURLEncodedUtils.java Fri Apr 23 19:19:23 2010
@@ -118,15 +118,15 @@ public class TestURLEncodedUtils extends
};
static final int RUSSIAN_HELLO [] = {
- 0x412, 0x441, 0x435, 0x43C, 0x5F, 0x43F, 0x440, 0x438,
- 0x432, 0x435, 0x442
- };
+ 0x412, 0x441, 0x435, 0x43C, 0x5F, 0x43F, 0x440, 0x438,
+ 0x432, 0x435, 0x442
+ };
private static String constructString(int [] unicodeChars) {
StringBuffer buffer = new StringBuffer();
if (unicodeChars != null) {
for (int i = 0; i < unicodeChars.length; i++) {
- buffer.append((char)unicodeChars[i]);
+ buffer.append((char)unicodeChars[i]);
}
}
return buffer.toString();
@@ -210,8 +210,8 @@ public class TestURLEncodedUtils extends
}
private static void assertNameValuePair (
- final NameValuePair parameter,
- final String expectedName,
+ final NameValuePair parameter,
+ final String expectedName,
final String expectedValue) {
assertEquals(parameter.getName(), expectedName);
assertEquals(parameter.getValue(), expectedValue);
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestConnectionAutoRelease.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestConnectionAutoRelease.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestConnectionAutoRelease.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestConnectionAutoRelease.java Fri Apr 23 19:19:23 2010
@@ -82,13 +82,13 @@ public class TestConnectionAutoRelease e
// Zero connections in the pool
assertEquals(0, mgr.getConnectionsInPool());
-
- DefaultHttpClient client = new DefaultHttpClient(mgr);
+
+ DefaultHttpClient client = new DefaultHttpClient(mgr);
// Get some random data
- HttpGet httpget = new HttpGet("/random/20000");
+ HttpGet httpget = new HttpGet("/random/20000");
HttpHost target = getServerHttp();
-
+
HttpResponse response = client.execute(target, httpget);
ClientConnectionRequest connreq = mgr.requestConnection(new HttpRoute(target), null);
@@ -97,23 +97,23 @@ public class TestConnectionAutoRelease e
fail("ConnectionPoolTimeoutException should have been thrown");
} catch (ConnectionPoolTimeoutException expected) {
}
-
+
HttpEntity e = response.getEntity();
assertNotNull(e);
e.consumeContent();
-
+
// Expect one connection in the pool
assertEquals(1, mgr.getConnectionsInPool());
// Make sure one connection is available
connreq = mgr.requestConnection(new HttpRoute(target), null);
ManagedClientConnection conn = connreq.getConnection(250, TimeUnit.MILLISECONDS);
-
+
mgr.releaseConnection(conn, -1, null);
-
+
mgr.shutdown();
}
-
+
public void testReleaseOnEntityWriteTo() throws Exception {
ThreadSafeClientConnManager mgr = createTSCCM(null);
mgr.setDefaultMaxPerRoute(1);
@@ -121,13 +121,13 @@ public class TestConnectionAutoRelease e
// Zero connections in the pool
assertEquals(0, mgr.getConnectionsInPool());
-
- DefaultHttpClient client = new DefaultHttpClient(mgr);
+
+ DefaultHttpClient client = new DefaultHttpClient(mgr);
// Get some random data
- HttpGet httpget = new HttpGet("/random/20000");
+ HttpGet httpget = new HttpGet("/random/20000");
HttpHost target = getServerHttp();
-
+
HttpResponse response = client.execute(target, httpget);
ClientConnectionRequest connreq = mgr.requestConnection(new HttpRoute(target), null);
@@ -136,24 +136,24 @@ public class TestConnectionAutoRelease e
fail("ConnectionPoolTimeoutException should have been thrown");
} catch (ConnectionPoolTimeoutException expected) {
}
-
+
HttpEntity e = response.getEntity();
assertNotNull(e);
- ByteArrayOutputStream outsteam = new ByteArrayOutputStream();
+ ByteArrayOutputStream outsteam = new ByteArrayOutputStream();
e.writeTo(outsteam);
-
+
// Expect one connection in the pool
assertEquals(1, mgr.getConnectionsInPool());
// Make sure one connection is available
connreq = mgr.requestConnection(new HttpRoute(target), null);
ManagedClientConnection conn = connreq.getConnection(250, TimeUnit.MILLISECONDS);
-
+
mgr.releaseConnection(conn, -1, null);
-
+
mgr.shutdown();
}
-
+
public void testReleaseOnAbort() throws Exception {
ThreadSafeClientConnManager mgr = createTSCCM(null);
mgr.setDefaultMaxPerRoute(1);
@@ -161,13 +161,13 @@ public class TestConnectionAutoRelease e
// Zero connections in the pool
assertEquals(0, mgr.getConnectionsInPool());
-
- DefaultHttpClient client = new DefaultHttpClient(mgr);
+
+ DefaultHttpClient client = new DefaultHttpClient(mgr);
// Get some random data
- HttpGet httpget = new HttpGet("/random/20000");
+ HttpGet httpget = new HttpGet("/random/20000");
HttpHost target = getServerHttp();
-
+
HttpResponse response = client.execute(target, httpget);
ClientConnectionRequest connreq = mgr.requestConnection(new HttpRoute(target), null);
@@ -176,30 +176,30 @@ public class TestConnectionAutoRelease e
fail("ConnectionPoolTimeoutException should have been thrown");
} catch (ConnectionPoolTimeoutException expected) {
}
-
+
HttpEntity e = response.getEntity();
assertNotNull(e);
httpget.abort();
-
+
// Expect zero connections in the pool
assertEquals(0, mgr.getConnectionsInPool());
// Make sure one connection is available
connreq = mgr.requestConnection(new HttpRoute(target), null);
ManagedClientConnection conn = connreq.getConnection(250, TimeUnit.MILLISECONDS);
-
+
mgr.releaseConnection(conn, -1, null);
-
+
mgr.shutdown();
}
public void testReleaseOnIOException() throws Exception {
-
+
localServer.register("/dropdead", new HttpRequestHandler() {
public void handle(
- final HttpRequest request,
- final HttpResponse response,
+ final HttpRequest request,
+ final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
BasicHttpEntity entity = new BasicHttpEntity() {
@@ -209,37 +209,37 @@ public class TestConnectionAutoRelease e
byte[] tmp = new byte[5];
outstream.write(tmp);
outstream.flush();
-
- // do something comletely ugly in order to trigger
+
+ // do something comletely ugly in order to trigger
// MalformedChunkCodingException
- DefaultHttpServerConnection conn = (DefaultHttpServerConnection)
+ DefaultHttpServerConnection conn = (DefaultHttpServerConnection)
context.getAttribute(ExecutionContext.HTTP_CONNECTION);
try {
conn.sendResponseHeader(response);
} catch (HttpException ignore) {
}
}
-
+
} ;
entity.setChunked(true);
response.setEntity(entity);
}
-
+
});
-
+
ThreadSafeClientConnManager mgr = createTSCCM(null);
mgr.setDefaultMaxPerRoute(1);
mgr.setMaxTotalConnections(1);
// Zero connections in the pool
assertEquals(0, mgr.getConnectionsInPool());
-
- DefaultHttpClient client = new DefaultHttpClient(mgr);
+
+ DefaultHttpClient client = new DefaultHttpClient(mgr);
// Get some random data
- HttpGet httpget = new HttpGet("/dropdead");
+ HttpGet httpget = new HttpGet("/dropdead");
HttpHost target = getServerHttp();
-
+
HttpResponse response = client.execute(target, httpget);
ClientConnectionRequest connreq = mgr.requestConnection(new HttpRoute(target), null);
@@ -248,7 +248,7 @@ public class TestConnectionAutoRelease e
fail("ConnectionPoolTimeoutException should have been thrown");
} catch (ConnectionPoolTimeoutException expected) {
}
-
+
HttpEntity e = response.getEntity();
assertNotNull(e);
// Read the content
@@ -256,19 +256,19 @@ public class TestConnectionAutoRelease e
EntityUtils.toByteArray(e);
fail("MalformedChunkCodingException should have been thrown");
} catch (MalformedChunkCodingException expected) {
-
+
}
-
+
// Expect zero connections in the pool
assertEquals(0, mgr.getConnectionsInPool());
// Make sure one connection is available
connreq = mgr.requestConnection(new HttpRoute(target), null);
ManagedClientConnection conn = connreq.getConnection(250, TimeUnit.MILLISECONDS);
-
+
mgr.releaseConnection(conn, -1, null);
-
+
mgr.shutdown();
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestConnectionReuse.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestConnectionReuse.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestConnectionReuse.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestConnectionReuse.java Fri Apr 23 19:19:23 2010
@@ -80,7 +80,7 @@ public class TestConnectionReuse extends
}
protected LocalTestServer localServer;
-
+
@Override
protected void tearDown() throws Exception {
if (this.localServer != null) {
@@ -95,54 +95,54 @@ public class TestConnectionReuse extends
httpproc.addInterceptor(new ResponseServer());
httpproc.addInterceptor(new ResponseContent());
httpproc.addInterceptor(new ResponseConnControl());
-
+
this.localServer = new LocalTestServer(httpproc, null);
this.localServer.register("/random/*", new RandomHandler());
this.localServer.start();
InetSocketAddress saddress = this.localServer.getServiceAddress();
-
+
HttpParams params = new BasicHttpParams();
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(params, "UTF-8");
HttpProtocolParams.setUserAgent(params, "TestAgent/1.1");
HttpProtocolParams.setUseExpectContinue(params, false);
HttpConnectionParams.setStaleCheckingEnabled(params, false);
-
+
SchemeRegistry supportedSchemes = new SchemeRegistry();
SchemeSocketFactory sf = PlainSocketFactory.getSocketFactory();
supportedSchemes.register(new Scheme("http", 80, sf));
-
+
ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(supportedSchemes);
mgr.setMaxTotalConnections(5);
mgr.setDefaultMaxPerRoute(5);
- DefaultHttpClient client = new DefaultHttpClient(mgr, params);
+ DefaultHttpClient client = new DefaultHttpClient(mgr, params);
HttpHost target = new HttpHost(saddress.getHostName(), saddress.getPort(), "http");
-
+
WorkerThread[] workers = new WorkerThread[10];
for (int i = 0; i < workers.length; i++) {
workers[i] = new WorkerThread(
- client,
- target,
- new URI("/random/2000"),
+ client,
+ target,
+ new URI("/random/2000"),
10, false);
}
-
+
for (int i = 0; i < workers.length; i++) {
WorkerThread worker = workers[i];
worker.start();
}
for (int i = 0; i < workers.length; i++) {
- WorkerThread worker = workers[i];
+ WorkerThread worker = workers[i];
workers[i].join(10000);
Exception ex = worker.getException();
if (ex != null) {
throw ex;
}
}
-
+
// Expect some connection in the pool
assertTrue(mgr.getConnectionsInPool() > 0);
@@ -152,67 +152,67 @@ public class TestConnectionReuse extends
private static class AlwaysCloseConn implements HttpResponseInterceptor {
public void process(
- final HttpResponse response,
+ final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
response.setHeader(HTTP.CONN_DIRECTIVE, HTTP.CONN_CLOSE);
}
-
+
}
-
+
public void testReuseOfClosedConnections() throws Exception {
BasicHttpProcessor httpproc = new BasicHttpProcessor();
httpproc.addInterceptor(new ResponseDate());
httpproc.addInterceptor(new ResponseServer());
httpproc.addInterceptor(new ResponseContent());
httpproc.addInterceptor(new AlwaysCloseConn());
-
+
this.localServer = new LocalTestServer(httpproc, null);
this.localServer.register("/random/*", new RandomHandler());
this.localServer.start();
InetSocketAddress saddress = this.localServer.getServiceAddress();
-
+
HttpParams params = new BasicHttpParams();
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(params, "UTF-8");
HttpProtocolParams.setUserAgent(params, "TestAgent/1.1");
HttpProtocolParams.setUseExpectContinue(params, false);
HttpConnectionParams.setStaleCheckingEnabled(params, false);
-
+
SchemeRegistry supportedSchemes = new SchemeRegistry();
SchemeSocketFactory sf = PlainSocketFactory.getSocketFactory();
supportedSchemes.register(new Scheme("http", 80, sf));
-
+
ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(supportedSchemes);
mgr.setMaxTotalConnections(5);
mgr.setDefaultMaxPerRoute(5);
- DefaultHttpClient client = new DefaultHttpClient(mgr, params);
+ DefaultHttpClient client = new DefaultHttpClient(mgr, params);
HttpHost target = new HttpHost(saddress.getHostName(), saddress.getPort(), "http");
-
+
WorkerThread[] workers = new WorkerThread[10];
for (int i = 0; i < workers.length; i++) {
workers[i] = new WorkerThread(
- client,
- target,
- new URI("/random/2000"),
+ client,
+ target,
+ new URI("/random/2000"),
10, false);
}
-
+
for (int i = 0; i < workers.length; i++) {
- WorkerThread worker = workers[i];
+ WorkerThread worker = workers[i];
worker.start();
}
for (int i = 0; i < workers.length; i++) {
- WorkerThread worker = workers[i];
+ WorkerThread worker = workers[i];
workers[i].join(10000);
Exception ex = worker.getException();
if (ex != null) {
throw ex;
}
}
-
+
// Expect zero connections in the pool
assertEquals(0, mgr.getConnectionsInPool());
@@ -225,60 +225,60 @@ public class TestConnectionReuse extends
httpproc.addInterceptor(new ResponseServer());
httpproc.addInterceptor(new ResponseContent());
httpproc.addInterceptor(new ResponseConnControl());
-
+
this.localServer = new LocalTestServer(httpproc, null);
this.localServer.register("/random/*", new RandomHandler());
this.localServer.start();
InetSocketAddress saddress = this.localServer.getServiceAddress();
-
+
HttpParams params = new BasicHttpParams();
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(params, "UTF-8");
HttpProtocolParams.setUserAgent(params, "TestAgent/1.1");
HttpProtocolParams.setUseExpectContinue(params, false);
HttpConnectionParams.setStaleCheckingEnabled(params, false);
-
+
SchemeRegistry supportedSchemes = new SchemeRegistry();
SchemeSocketFactory sf = PlainSocketFactory.getSocketFactory();
supportedSchemes.register(new Scheme("http", 80, sf));
-
+
ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(supportedSchemes);
mgr.setMaxTotalConnections(5);
mgr.setDefaultMaxPerRoute(5);
- DefaultHttpClient client = new DefaultHttpClient(mgr, params);
+ DefaultHttpClient client = new DefaultHttpClient(mgr, params);
HttpHost target = new HttpHost(saddress.getHostName(), saddress.getPort(), "http");
-
+
WorkerThread[] workers = new WorkerThread[10];
for (int i = 0; i < workers.length; i++) {
workers[i] = new WorkerThread(
- client,
- target,
- new URI("/random/2000"),
+ client,
+ target,
+ new URI("/random/2000"),
10, true);
}
-
+
for (int i = 0; i < workers.length; i++) {
WorkerThread worker = workers[i];
worker.start();
}
for (int i = 0; i < workers.length; i++) {
- WorkerThread worker = workers[i];
+ WorkerThread worker = workers[i];
workers[i].join(10000);
Exception ex = worker.getException();
if (ex != null) {
throw ex;
}
}
-
+
// Expect zero connections in the pool
assertEquals(0, mgr.getConnectionsInPool());
mgr.shutdown();
}
-
+
public void testKeepAliveHeaderRespected() throws Exception {
BasicHttpProcessor httpproc = new BasicHttpProcessor();
httpproc.addInterceptor(new ResponseDate());
@@ -286,67 +286,67 @@ public class TestConnectionReuse extends
httpproc.addInterceptor(new ResponseContent());
httpproc.addInterceptor(new ResponseConnControl());
httpproc.addInterceptor(new ResponseKeepAlive());
-
+
this.localServer = new LocalTestServer(httpproc, null);
this.localServer.register("/random/*", new RandomHandler());
this.localServer.start();
InetSocketAddress saddress = this.localServer.getServiceAddress();
-
+
HttpParams params = new BasicHttpParams();
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(params, "UTF-8");
HttpProtocolParams.setUserAgent(params, "TestAgent/1.1");
HttpProtocolParams.setUseExpectContinue(params, false);
HttpConnectionParams.setStaleCheckingEnabled(params, false);
-
+
SchemeRegistry supportedSchemes = new SchemeRegistry();
SchemeSocketFactory sf = PlainSocketFactory.getSocketFactory();
supportedSchemes.register(new Scheme("http", 80, sf));
-
+
ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(supportedSchemes);
mgr.setMaxTotalConnections(1);
mgr.setDefaultMaxPerRoute(1);
DefaultHttpClient client = new DefaultHttpClient(mgr, params);
HttpHost target = new HttpHost(saddress.getHostName(), saddress.getPort(), "http");
-
+
HttpResponse response = client.execute(target, new HttpGet("/random/2000"));
if(response.getEntity() != null)
response.getEntity().consumeContent();
-
+
assertEquals(1, mgr.getConnectionsInPool());
assertEquals(1, localServer.getAcceptedConnectionCount());
-
+
response = client.execute(target, new HttpGet("/random/2000"));
if(response.getEntity() != null)
response.getEntity().consumeContent();
-
+
assertEquals(1, mgr.getConnectionsInPool());
assertEquals(1, localServer.getAcceptedConnectionCount());
-
+
// Now sleep for 1.1 seconds and let the timeout do its work
Thread.sleep(1100);
response = client.execute(target, new HttpGet("/random/2000"));
if(response.getEntity() != null)
response.getEntity().consumeContent();
-
+
assertEquals(1, mgr.getConnectionsInPool());
assertEquals(2, localServer.getAcceptedConnectionCount());
-
+
// Do another request just under the 1 second limit & make
// sure we reuse that connection.
Thread.sleep(500);
response = client.execute(target, new HttpGet("/random/2000"));
if(response.getEntity() != null)
response.getEntity().consumeContent();
-
+
assertEquals(1, mgr.getConnectionsInPool());
assertEquals(2, localServer.getAcceptedConnectionCount());
-
+
mgr.shutdown();
- }
+ }
private static class WorkerThread extends Thread {
@@ -357,10 +357,10 @@ public class TestConnectionReuse extends
private final boolean forceClose;
private volatile Exception exception;
-
+
public WorkerThread(
- final HttpClient httpclient,
- final HttpHost target,
+ final HttpClient httpclient,
+ final HttpHost target,
final URI requestURI,
int repetitions,
boolean forceClose) {
@@ -371,14 +371,14 @@ public class TestConnectionReuse extends
this.repetitions = repetitions;
this.forceClose = forceClose;
}
-
+
@Override
public void run() {
try {
for (int i = 0; i < this.repetitions; i++) {
HttpGet httpget = new HttpGet(this.requestURI);
HttpResponse response = this.httpclient.execute(
- this.target,
+ this.target,
httpget);
if (this.forceClose) {
httpget.abort();
@@ -397,9 +397,9 @@ public class TestConnectionReuse extends
public Exception getException() {
return exception;
}
-
+
}
-
+
// A very basic keep-alive header interceptor, to add Keep-Alive: timeout=1
// if there is no Connection: close header.
private static class ResponseKeepAlive implements HttpResponseInterceptor {
@@ -410,8 +410,8 @@ public class TestConnectionReuse extends
if(!connection.getValue().equalsIgnoreCase("Close")) {
response.addHeader(HTTP.CONN_KEEP_ALIVE, "timeout=1");
}
- }
+ }
}
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestScheme.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestScheme.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestScheme.java Fri Apr 23 19:19:23 2010
@@ -62,14 +62,14 @@ public class TestScheme extends TestCase
public void testConstructor() {
Scheme http = new Scheme("http", 80, PlainSocketFactory.getSocketFactory());
- assertEquals("http", http.getName());
- assertEquals(80, http.getDefaultPort());
- assertSame(PlainSocketFactory.getSocketFactory(), http.getSchemeSocketFactory());
- assertFalse(http.isLayered());
+ assertEquals("http", http.getName());
+ assertEquals(80, http.getDefaultPort());
+ assertSame(PlainSocketFactory.getSocketFactory(), http.getSchemeSocketFactory());
+ assertFalse(http.isLayered());
Scheme https = new Scheme("https", 443, SecureSocketFactoryMockup.INSTANCE);
- assertEquals("https", https.getName());
- assertEquals(443, https.getDefaultPort());
- assertSame(SecureSocketFactoryMockup.INSTANCE, https.getSchemeSocketFactory());
+ assertEquals("https", https.getName());
+ assertEquals(443, https.getDefaultPort());
+ assertSame(SecureSocketFactoryMockup.INSTANCE, https.getSchemeSocketFactory());
assertTrue(https.isLayered());
Scheme hTtP = new Scheme("hTtP", 80, PlainSocketFactory.getSocketFactory());
@@ -211,14 +211,14 @@ public class TestScheme extends TestCase
// expected
}
}
-
+
public void testResolvePort() {
Scheme http = new Scheme("http", 80, PlainSocketFactory.getSocketFactory());
assertEquals(8080, http.resolvePort(8080));
assertEquals(80, http.resolvePort(-1));
}
-
+
public void testHashCode() {
Scheme http = new Scheme("http", 80, PlainSocketFactory.getSocketFactory());
Scheme myhttp = new Scheme("http", 80, PlainSocketFactory.getSocketFactory());
@@ -227,7 +227,7 @@ public class TestScheme extends TestCase
assertTrue(http.hashCode() != https.hashCode()); // not guaranteed
assertTrue(http.hashCode() == myhttp.hashCode());
}
-
+
public void testEquals() {
Scheme http = new Scheme("http", 80, PlainSocketFactory.getSocketFactory());
Scheme myhttp = new Scheme("http", 80, PlainSocketFactory.getSocketFactory());
@@ -247,5 +247,5 @@ public class TestScheme extends TestCase
assertEquals("http:80", http.toString());
assertEquals("http:80", http.toString());
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/routing/TestHttpRoute.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/routing/TestHttpRoute.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/routing/TestHttpRoute.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/routing/TestHttpRoute.java Fri Apr 23 19:19:23 2010
@@ -254,7 +254,7 @@ public class TestHttpRoute extends TestC
HttpRoute route = new HttpRoute(TARGET1, null, chain1, false,
TunnelType.TUNNELLED, LayerType.PLAIN);
assertNotNull(route);
-
+
try {
route = new HttpRoute(null, null, chain1, false,
TunnelType.TUNNELLED, LayerType.PLAIN);
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/scheme/TestScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/scheme/TestScheme.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/scheme/TestScheme.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/scheme/TestScheme.java Fri Apr 23 19:19:23 2010
@@ -48,7 +48,7 @@ public class TestScheme extends TestCase
public static Test suite() {
return new TestSuite(TestScheme.class);
}
-
+
public void testPortResolution() {
Scheme http = new Scheme("http", 80, PlainSocketFactory.getSocketFactory());
assertEquals(80, http.resolvePort(0));
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/CertificatesToPlayWith.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/CertificatesToPlayWith.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/CertificatesToPlayWith.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/CertificatesToPlayWith.java Fri Apr 23 19:19:23 2010
@@ -430,7 +430,7 @@ public class CertificatesToPlayWith {
"6bb45a374f0537c5a1aab3150764ce93cf386c84346a6bd01f6732e42075" +
"c7a0e9e78a9e73b934e7d871d0f75673820089e129a1604438edcbbeb4e2" +
"106467da112ce389";
-
+
public final static String RSA_EXPONENT2 =
"00827e76650c946afcd170038d32e1f8386ab00d6be78d830efe382e45d4" +
"7ad4bd04e6231ee22e66740efbf52838134932c9f8c460cdccdec58a1424" +
@@ -470,5 +470,5 @@ public class CertificatesToPlayWith {
"vwuJhNYaa2FJMELIwRN3XES8X8R6JHWbPaRjaAAPhczuEd8SZYy8yiVLmJTgw0gH\n" +
"BSW775NHlkjsscFVgXkNf0PobqJ9\n" +
"-----END CERTIFICATE-----").getBytes();
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestHostnameVerifier.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestHostnameVerifier.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestHostnameVerifier.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestHostnameVerifier.java Fri Apr 23 19:19:23 2010
@@ -204,16 +204,16 @@ public class TestHostnameVerifier extend
CertificateFactory cf = CertificateFactory.getInstance("X.509");
InputStream in = new ByteArrayInputStream(CertificatesToPlayWith.X509_MULTIPLE_SUBJECT_ALT);
X509Certificate x509 = (X509Certificate) cf.generateCertificate(in);
-
+
X509HostnameVerifier verifier = SSLSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER;
-
- assertEquals("CN=localhost, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=CH",
+
+ assertEquals("CN=localhost, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=CH",
x509.getSubjectDN().getName());
-
+
verifier.verify("localhost", x509);
verifier.verify("localhost.localdomain", x509);
verifier.verify("127.0.0.1", x509);
-
+
try {
verifier.verify("local.host", x509);
fail("SSLException should have been thrown");
@@ -226,9 +226,9 @@ public class TestHostnameVerifier extend
} catch (SSLException ex) {
// expected
}
-
+
}
-
+
private void exceptionPlease(X509HostnameVerifier hv, String host,
X509Certificate x509) {
try {
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestSSLSocketFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestSSLSocketFactory.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestSSLSocketFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestSSLSocketFactory.java Fri Apr 23 19:19:23 2010
@@ -82,7 +82,7 @@ public class TestSSLSocketFactory extend
return KeyManagerFactory.getInstance("SunX509");
}
}
-
+
private TrustManagerFactory createTrustManagerFactory() throws NoSuchAlgorithmException {
String algo = TrustManagerFactory.getDefaultAlgorithm();
try {
@@ -94,7 +94,7 @@ public class TestSSLSocketFactory extend
private SSLContext serverSSLContext;
private SSLContext clientSSLContext;
-
+
@Override
protected void setUp() throws Exception {
ClassLoader cl = getClass().getClassLoader();
@@ -110,16 +110,16 @@ public class TestSSLSocketFactory extend
KeyManagerFactory kmfactory = createKeyManagerFactory();
kmfactory.init(keystore, pwd);
KeyManager[] km = kmfactory.getKeyManagers();
-
+
this.serverSSLContext = SSLContext.getInstance("TLS");
this.serverSSLContext.init(km, tm, null);
this.clientSSLContext = SSLContext.getInstance("TLS");
this.clientSSLContext.init(null, tm, null);
-
+
this.localServer = new LocalTestServer(this.serverSSLContext);
this.localServer.registerDefaultHandlers();
-
+
this.localServer.start();
}
@@ -131,11 +131,11 @@ public class TestSSLSocketFactory extend
address.getPort(),
"https");
}
-
+
static class TestX509HostnameVerifier implements X509HostnameVerifier {
private boolean fired = false;
-
+
public boolean verify(String host, SSLSession session) {
return true;
}
@@ -149,22 +149,22 @@ public class TestSSLSocketFactory extend
public void verify(String host, X509Certificate cert) throws SSLException {
}
-
+
public boolean isFired() {
return this.fired;
}
-
+
}
-
+
public void testBasicSSL() throws Exception {
TestX509HostnameVerifier hostVerifier = new TestX509HostnameVerifier();
-
+
SSLSocketFactory socketFactory = new SSLSocketFactory(this.clientSSLContext, hostVerifier);
- Scheme https = new Scheme("https", 443, socketFactory);
+ Scheme https = new Scheme("https", 443, socketFactory);
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.getConnectionManager().getSchemeRegistry().register(https);
-
+
HttpHost target = getServerHttp();
HttpGet httpget = new HttpGet("/random/100");
HttpResponse response = httpclient.execute(target, httpget);
@@ -176,14 +176,14 @@ public class TestSSLSocketFactory extend
// Use default SSL context
SSLContext defaultsslcontext = SSLContext.getInstance("TLS");
defaultsslcontext.init(null, null, null);
-
- SSLSocketFactory socketFactory = new SSLSocketFactory(defaultsslcontext,
+
+ SSLSocketFactory socketFactory = new SSLSocketFactory(defaultsslcontext,
SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
-
- Scheme https = new Scheme("https", 443, socketFactory);
+
+ Scheme https = new Scheme("https", 443, socketFactory);
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.getConnectionManager().getSchemeRegistry().register(https);
-
+
HttpHost target = getServerHttp();
HttpGet httpget = new HttpGet("/random/100");
try {
@@ -197,24 +197,24 @@ public class TestSSLSocketFactory extend
// Use default SSL context
SSLContext defaultsslcontext = SSLContext.getInstance("TLS");
defaultsslcontext.init(null, null, null);
-
+
SSLSocketFactory socketFactory = new SSLSocketFactory(new TrustStrategy() {
-
+
public boolean isTrusted(
final X509Certificate[] chain, final String authType) throws CertificateException {
return chain.length == 1;
}
-
+
}, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
-
- Scheme https = new Scheme("https", 443, socketFactory);
+
+ Scheme https = new Scheme("https", 443, socketFactory);
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.getConnectionManager().getSchemeRegistry().register(https);
-
+
HttpHost target = getServerHttp();
HttpGet httpget = new HttpGet("/random/100");
HttpResponse response = httpclient.execute(target, httpget);
assertEquals(200, response.getStatusLine().getStatusCode());
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/util/TestInetAddressUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/util/TestInetAddressUtils.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/util/TestInetAddressUtils.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/util/TestInetAddressUtils.java Fri Apr 23 19:19:23 2010
@@ -48,7 +48,7 @@ public class TestInetAddressUtils extend
public static Test suite() {
return new TestSuite(TestInetAddressUtils.class);
}
-
+
public void testValidIPv4Address() {
assertTrue(InetAddressUtils.isIPv4Address("127.0.0.1"));
assertTrue(InetAddressUtils.isIPv4Address("192.168.0.0"));
@@ -74,5 +74,5 @@ public class TestInetAddressUtils extend
assertFalse(InetAddressUtils.isIPv6Address("2001:0db8:0000:garb:age0:0000:1428:57ab"));
assertFalse(InetAddressUtils.isIPv6Address("2001:0gb8:0000:0000:0000:0000:1428:57ab"));
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/cookie/TestCookieOrigin.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/cookie/TestCookieOrigin.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/cookie/TestCookieOrigin.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/cookie/TestCookieOrigin.java Fri Apr 23 19:19:23 2010
@@ -64,7 +64,7 @@ public class TestCookieOrigin extends Te
// expected
}
}
-
+
public void testEmptyHost() {
try {
new CookieOrigin(" ", 80, "/", false);
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/cookie/TestCookiePathComparator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/cookie/TestCookiePathComparator.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/cookie/TestCookiePathComparator.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/cookie/TestCookiePathComparator.java Fri Apr 23 19:19:23 2010
@@ -112,6 +112,6 @@ public class TestCookiePathComparator ex
assertTrue(comparator.compare(cookie1, cookie2) == 0);
assertTrue(comparator.compare(cookie2, cookie1) == 0);
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/cookie/TestCookiePolicy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/cookie/TestCookiePolicy.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/cookie/TestCookiePolicy.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/cookie/TestCookiePolicy.java Fri Apr 23 19:19:23 2010
@@ -62,23 +62,23 @@ public class TestCookiePolicy extends Te
private static final String BROWSER_COMPATIBILITY = "BROWSER_COMPATIBILITY";
private static final String NETSCAPE = "NETSCAPE";
private static final String RFC_2109 = "RFC_2109";
-
-
+
+
public void testRegisterUnregisterCookieSpecFactory() {
- CookieSpecRegistry registry = new CookieSpecRegistry();
+ CookieSpecRegistry registry = new CookieSpecRegistry();
List<String> names = registry.getSpecNames();
assertNotNull(names);
assertEquals(0, names.size());
-
- registry.register(BROWSER_COMPATIBILITY,
+
+ registry.register(BROWSER_COMPATIBILITY,
new BrowserCompatSpecFactory());
- registry.register(NETSCAPE,
+ registry.register(NETSCAPE,
new NetscapeDraftSpecFactory());
- registry.register(RFC_2109,
+ registry.register(RFC_2109,
new RFC2109SpecFactory());
- registry.register(RFC_2109,
+ registry.register(RFC_2109,
new RFC2109SpecFactory());
- registry.register(NETSCAPE,
+ registry.register(NETSCAPE,
new NetscapeDraftSpecFactory());
names = registry.getSpecNames();
@@ -89,26 +89,26 @@ public class TestCookiePolicy extends Te
assertTrue(m.contains(NETSCAPE.toLowerCase(Locale.ENGLISH)));
assertTrue(m.contains(RFC_2109.toLowerCase(Locale.ENGLISH)));
- registry.unregister(NETSCAPE);
- registry.unregister(NETSCAPE);
- registry.unregister(RFC_2109);
- registry.unregister(BROWSER_COMPATIBILITY);
- registry.unregister("whatever");
-
+ registry.unregister(NETSCAPE);
+ registry.unregister(NETSCAPE);
+ registry.unregister(RFC_2109);
+ registry.unregister(BROWSER_COMPATIBILITY);
+ registry.unregister("whatever");
+
names = registry.getSpecNames();
assertNotNull(names);
assertEquals(0, names.size());
}
public void testGetNewCookieSpec() {
- CookieSpecRegistry registry = new CookieSpecRegistry();
- registry.register(BROWSER_COMPATIBILITY,
+ CookieSpecRegistry registry = new CookieSpecRegistry();
+ registry.register(BROWSER_COMPATIBILITY,
new BrowserCompatSpecFactory());
- registry.register(NETSCAPE,
+ registry.register(NETSCAPE,
new NetscapeDraftSpecFactory());
- registry.register(RFC_2109,
+ registry.register(RFC_2109,
new RFC2109SpecFactory());
-
+
assertNotNull(registry.getCookieSpec(NETSCAPE));
assertNotNull(registry.getCookieSpec(RFC_2109));
assertNotNull(registry.getCookieSpec(BROWSER_COMPATIBILITY));
@@ -131,7 +131,7 @@ public class TestCookiePolicy extends Te
}
public void testInvalidInput() {
- CookieSpecRegistry registry = new CookieSpecRegistry();
+ CookieSpecRegistry registry = new CookieSpecRegistry();
try {
registry.register(null, null);
fail("IllegalArgumentException should have been thrown");
@@ -157,6 +157,6 @@ public class TestCookiePolicy extends Te
// expected
}
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestBasicScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestBasicScheme.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestBasicScheme.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestBasicScheme.java Fri Apr 23 19:19:23 2010
@@ -82,26 +82,26 @@ public class TestBasicScheme extends Tes
int[] germanChars = { 0xE4, 0x2D, 0xF6, 0x2D, 0xFc };
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < germanChars.length; i++) {
- buffer.append((char)germanChars[i]);
+ buffer.append((char)germanChars[i]);
}
-
+
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("dh", buffer.toString());
Header header = BasicScheme.authenticate(credentials, "ISO-8859-1", false);
assertEquals("Basic ZGg65C32Lfw=", header.getValue());
}
-
+
public void testBasicAuthentication() throws Exception {
- UsernamePasswordCredentials creds =
+ UsernamePasswordCredentials creds =
new UsernamePasswordCredentials("testuser", "testpass");
-
+
Header challenge = new BasicHeader(AUTH.WWW_AUTH, "Basic realm=\"test\"");
-
+
BasicScheme authscheme = new BasicScheme();
authscheme.processChallenge(challenge);
-
+
HttpRequest request = new BasicHttpRequest("GET", "/");
Header authResponse = authscheme.authenticate(creds, request);
-
+
String expected = "Basic " + EncodingUtils.getAsciiString(
Base64.encodeBase64(EncodingUtils.getAsciiBytes("testuser:testpass")));
assertEquals(AUTH.WWW_AUTH_RESP, authResponse.getName());
@@ -112,17 +112,17 @@ public class TestBasicScheme extends Tes
}
public void testBasicProxyAuthentication() throws Exception {
- UsernamePasswordCredentials creds =
+ UsernamePasswordCredentials creds =
new UsernamePasswordCredentials("testuser", "testpass");
-
+
Header challenge = new BasicHeader(AUTH.PROXY_AUTH, "Basic realm=\"test\"");
-
+
BasicScheme authscheme = new BasicScheme();
authscheme.processChallenge(challenge);
-
+
HttpRequest request = new BasicHttpRequest("GET", "/");
Header authResponse = authscheme.authenticate(creds, request);
-
+
String expected = "Basic " + EncodingUtils.getAsciiString(
Base64.encodeBase64(EncodingUtils.getAsciiBytes("testuser:testpass")));
assertEquals(AUTH.PROXY_AUTH_RESP, authResponse.getName());
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestDigestScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestDigestScheme.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestDigestScheme.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestDigestScheme.java Fri Apr 23 19:19:23 2010
@@ -21,7 +21,7 @@
* 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.auth;
@@ -192,7 +192,7 @@ public class TestDigestScheme extends Te
assertEquals("0283edd9ef06a38b378b3b74661391e9", table.get("response"));
}
- /**
+ /**
* Test digest authentication using the MD5-sess algorithm.
*/
public void testDigestAuthenticationMD5Sess() throws Exception {
@@ -211,15 +211,15 @@ public class TestDigestScheme extends Te
+ "qop=\"auth,auth-int\""; // we pass both but expect auth to be used
Header authChallenge = new BasicHeader(AUTH.WWW_AUTH, challenge);
-
+
Credentials cred = new UsernamePasswordCredentials(username, password);
HttpRequest request = new BasicHttpRequest("Simple", "/");
-
+
DigestScheme authscheme = new DigestScheme();
authscheme.processChallenge(authChallenge);
Header authResponse = authscheme.authenticate(cred, request);
String response = authResponse.getValue();
-
+
assertTrue(response.indexOf("nc=00000001") > 0); // test for quotes
assertTrue(response.indexOf("qop=auth") > 0); // test for quotes
@@ -234,10 +234,10 @@ public class TestDigestScheme extends Te
assertEquals("SomeString", table.get("opaque"));
assertEquals("auth", table.get("qop"));
//@TODO: add better check
- assertTrue(null != table.get("response"));
+ assertTrue(null != table.get("response"));
}
- /**
+ /**
* Test digest authentication using the MD5-sess algorithm.
*/
public void testDigestAuthenticationMD5SessNoQop() throws Exception {
@@ -255,7 +255,7 @@ public class TestDigestScheme extends Te
+ "algorithm=MD5-sess";
Header authChallenge = new BasicHeader(AUTH.WWW_AUTH, challenge);
-
+
Credentials cred = new UsernamePasswordCredentials(username, password);
HttpRequest request = new BasicHttpRequest("Simple", "/");
@@ -274,10 +274,10 @@ public class TestDigestScheme extends Te
assertEquals("SomeString", table.get("opaque"));
assertTrue(null == table.get("qop"));
//@TODO: add better check
- assertTrue(null != table.get("response"));
+ assertTrue(null != table.get("response"));
}
- /**
+ /**
* Test digest authentication with invalud qop value
*/
public void testDigestAuthenticationMD5SessInvalidQop() throws Exception {
@@ -294,7 +294,7 @@ public class TestDigestScheme extends Te
+ "qop=\"jakarta\""; // jakarta is an invalid qop value
Header authChallenge = new BasicHeader(AUTH.WWW_AUTH, challenge);
-
+
try {
AuthScheme authscheme = new DigestScheme();
authscheme.processChallenge(authChallenge);
@@ -326,5 +326,5 @@ public class TestDigestScheme extends Te
}
return map;
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestRFC2617Scheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestRFC2617Scheme.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestRFC2617Scheme.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestRFC2617Scheme.java Fri Apr 23 19:19:23 2010
@@ -59,7 +59,7 @@ public class TestRFC2617Scheme extends T
static class TestAuthScheme extends RFC2617Scheme {
public Header authenticate(
- final Credentials credentials,
+ final Credentials credentials,
final HttpRequest request) throws AuthenticationException {
return null;
}
@@ -75,7 +75,7 @@ public class TestRFC2617Scheme extends T
public boolean isConnectionBased() {
return false;
}
-
+
}
public void testProcessChallenge() throws Exception {
@@ -83,9 +83,9 @@ public class TestRFC2617Scheme extends T
Header header = new BasicHeader(
AUTH.WWW_AUTH,
"Test realm=\"realm1\", test, test1 = stuff, test2 = \"stuff, stuff\", test3=\"crap");
-
+
authscheme.processChallenge(header);
-
+
assertEquals("test", authscheme.getSchemeName());
assertEquals("realm1", authscheme.getParameter("realm"));
assertEquals(null, authscheme.getParameter("test"));
@@ -99,9 +99,9 @@ public class TestRFC2617Scheme extends T
CharArrayBuffer buffer = new CharArrayBuffer(32);
buffer.append(" WWW-Authenticate: Test realm=\"realm1\"");
Header header = new BufferedHeader(buffer);
-
+
authscheme.processChallenge(header);
-
+
assertEquals("test", authscheme.getSchemeName());
assertEquals("realm1", authscheme.getParameter("realm"));
}
@@ -116,7 +116,7 @@ public class TestRFC2617Scheme extends T
//expected
}
}
-
+
public void testEmptyHeader() throws Exception {
TestAuthScheme authscheme = new TestAuthScheme();
Header header = new BasicHeader(AUTH.WWW_AUTH, "Test ");
@@ -127,7 +127,7 @@ public class TestRFC2617Scheme extends T
//expected
}
}
-
+
public void testInvalidHeaderValue() throws Exception {
TestAuthScheme authscheme = new TestAuthScheme();
Header header = new BasicHeader("whatever", "whatever");
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestBasicCookieStore.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestBasicCookieStore.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestBasicCookieStore.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestBasicCookieStore.java Fri Apr 23 19:19:23 2010
@@ -73,11 +73,11 @@ public class TestBasicCookieStore extend
assertNotNull(l);
assertEquals(0, l.size());
}
-
+
public void testExpiredCookie() throws Exception {
BasicCookieStore store = new BasicCookieStore();
BasicClientCookie cookie = new BasicClientCookie("name1", "value1");
-
+
Calendar c = Calendar.getInstance();
c.add(Calendar.DAY_OF_YEAR, -10);
cookie.setExpiryDate(c.getTime());
@@ -86,7 +86,7 @@ public class TestBasicCookieStore extend
assertNotNull(l);
assertEquals(0, l.size());
}
-
+
public void testSerialization() throws Exception {
BasicCookieStore orig = new BasicCookieStore();
orig.addCookie(new BasicClientCookie("name1", "value1"));
@@ -109,5 +109,5 @@ public class TestBasicCookieStore extend
assertEquals(expected.get(i).getValue(), clones.get(i).getValue());
}
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestBasicCredentialsProvider.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestBasicCredentialsProvider.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestBasicCredentialsProvider.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestBasicCredentialsProvider.java Fri Apr 23 19:19:23 2010
@@ -32,27 +32,27 @@ import org.apache.http.auth.UsernamePass
import junit.framework.*;
/**
- *
+ *
* Simple tests for {@link BasicCredentialsProvider}.
*
- *
+ *
* @version $Id$
- *
+ *
*/
public class TestBasicCredentialsProvider extends TestCase {
- public final static Credentials CREDS1 =
+ public final static Credentials CREDS1 =
new UsernamePasswordCredentials("user1", "pass1");
- public final static Credentials CREDS2 =
+ public final static Credentials CREDS2 =
new UsernamePasswordCredentials("user2", "pass2");
- public final static AuthScope SCOPE1 =
+ public final static AuthScope SCOPE1 =
new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, "realm1");
- public final static AuthScope SCOPE2 =
+ public final static AuthScope SCOPE2 =
new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, "realm2");
- public final static AuthScope BOGUS =
+ public final static AuthScope BOGUS =
new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, "bogus");
- public final static AuthScope DEFSCOPE =
+ public final static AuthScope DEFSCOPE =
new AuthScope("host", AuthScope.ANY_PORT, "realm");
@@ -97,7 +97,7 @@ public class TestBasicCredentialsProvide
}
// --------------------------------- Test Methods for Selecting Credentials
-
+
public void testDefaultCredentials() throws Exception {
BasicCredentialsProvider state = new BasicCredentialsProvider();
Credentials expected = new UsernamePasswordCredentials("name", "pass");
@@ -105,7 +105,7 @@ public class TestBasicCredentialsProvide
Credentials got = state.getCredentials(DEFSCOPE);
assertEquals(got, expected);
}
-
+
public void testRealmCredentials() throws Exception {
BasicCredentialsProvider state = new BasicCredentialsProvider();
Credentials expected = new UsernamePasswordCredentials("name", "pass");
@@ -113,7 +113,7 @@ public class TestBasicCredentialsProvide
Credentials got = state.getCredentials(DEFSCOPE);
assertEquals(expected, got);
}
-
+
public void testHostCredentials() throws Exception {
BasicCredentialsProvider state = new BasicCredentialsProvider();
Credentials expected = new UsernamePasswordCredentials("name", "pass");
@@ -122,7 +122,7 @@ public class TestBasicCredentialsProvide
Credentials got = state.getCredentials(DEFSCOPE);
assertEquals(expected, got);
}
-
+
public void testWrongHostCredentials() throws Exception {
BasicCredentialsProvider state = new BasicCredentialsProvider();
Credentials expected = new UsernamePasswordCredentials("name", "pass");
@@ -132,7 +132,7 @@ public class TestBasicCredentialsProvide
new AuthScope("host2", AuthScope.ANY_PORT, "realm"));
assertNotSame(expected, got);
}
-
+
public void testWrongRealmCredentials() throws Exception {
BasicCredentialsProvider state = new BasicCredentialsProvider();
Credentials cred = new UsernamePasswordCredentials("name", "pass");
@@ -144,7 +144,7 @@ public class TestBasicCredentialsProvide
}
// ------------------------------- Test Methods for matching Credentials
-
+
public void testScopeMatching() {
AuthScope authscope1 = new AuthScope("somehost", 80, "somerealm", "somescheme");
AuthScope authscope2 = new AuthScope("someotherhost", 80, "somerealm", "somescheme");
@@ -179,16 +179,16 @@ public class TestBasicCredentialsProvide
new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM, "somescheme"));
assertTrue(m2 > m1);
}
-
+
public void testCredentialsMatching() {
Credentials creds1 = new UsernamePasswordCredentials("name1", "pass1");
Credentials creds2 = new UsernamePasswordCredentials("name2", "pass2");
Credentials creds3 = new UsernamePasswordCredentials("name3", "pass3");
-
+
AuthScope scope1 = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM);
AuthScope scope2 = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, "somerealm");
AuthScope scope3 = new AuthScope("somehost", AuthScope.ANY_PORT, AuthScope.ANY_REALM);
-
+
BasicCredentialsProvider state = new BasicCredentialsProvider();
state.setCredentials(scope1, creds1);
state.setCredentials(scope2, creds2);