Fixup odd tab usage

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@617645 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastian Bazley 2008-02-01 21:05:31 +00:00
parent 13d6dc3da4
commit 8c08ae3178
12 changed files with 145 additions and 145 deletions

View File

@ -76,9 +76,9 @@ public static void main(String[] args) throws Exception {
} }
HttpPost httpost = new HttpPost("https://portal.sun.com/amserver/UI/Login?" + HttpPost httpost = new HttpPost("https://portal.sun.com/amserver/UI/Login?" +
"org=self_registered_users&" + "org=self_registered_users&" +
"goto=/portal/dt&" + "goto=/portal/dt&" +
"gotoOnFail=/portal/dt?error=true"); "gotoOnFail=/portal/dt?error=true");
NameValuePair[] nvps = new NameValuePair[] { NameValuePair[] nvps = new NameValuePair[] {
new BasicNameValuePair("IDToken1", "username"), new BasicNameValuePair("IDToken1", "username"),

View File

@ -100,7 +100,7 @@ public static void main(String[] args) throws Exception {
/** /**
* A thread that performs a GET. * A thread that performs a GET.
*/ */
static class GetThread extends Thread { static class GetThread extends Thread {
private HttpClient httpClient; private HttpClient httpClient;

View File

@ -40,13 +40,13 @@
*/ */
public final class CookieOrigin { public final class CookieOrigin {
private final String host; private final String host;
private final int port; private final int port;
private final String path; private final String path;
private final boolean secure; private final boolean secure;
public CookieOrigin(final String host, int port, final String path, boolean secure) { public CookieOrigin(final String host, int port, final String path, boolean secure) {
super(); super();
if (host == null) { if (host == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Host of origin may not be null"); "Host of origin may not be null");
@ -62,31 +62,31 @@ public CookieOrigin(final String host, int port, final String path, boolean secu
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Path of origin may not be null."); "Path of origin may not be null.");
} }
this.host = host.toLowerCase(); this.host = host.toLowerCase();
this.port = port; this.port = port;
if (!path.trim().equals("")) { if (!path.trim().equals("")) {
this.path = path; this.path = path;
} else { } else {
this.path = "/"; this.path = "/";
} }
this.secure = secure; this.secure = secure;
} }
public String getHost() { public String getHost() {
return this.host; return this.host;
} }
public String getPath() { public String getPath() {
return this.path; return this.path;
} }
public int getPort() { public int getPort() {
return this.port; return this.port;
} }
public boolean isSecure() { public boolean isSecure() {
return this.secure; return this.secure;
} }
@Override @Override
public String toString() { public String toString() {

View File

@ -50,7 +50,7 @@
*/ */
public class DefaultHttpRequestRetryHandler implements HttpRequestRetryHandler { public class DefaultHttpRequestRetryHandler implements HttpRequestRetryHandler {
/** the number of times a method will be retried */ /** the number of times a method will be retried */
private int retryCount; private int retryCount;
/** Whether or not methods that have successfully sent their request will be retried */ /** Whether or not methods that have successfully sent their request will be retried */

View File

@ -68,9 +68,9 @@ public final class DateUtils {
public static final String PATTERN_ASCTIME = "EEE MMM d HH:mm:ss yyyy"; public static final String PATTERN_ASCTIME = "EEE MMM d HH:mm:ss yyyy";
private static final String[] DEFAULT_PATTERNS = new String[] { private static final String[] DEFAULT_PATTERNS = new String[] {
PATTERN_ASCTIME, PATTERN_ASCTIME,
PATTERN_RFC1036, PATTERN_RFC1036,
PATTERN_RFC1123 }; PATTERN_RFC1123 };
private static final Date DEFAULT_TWO_DIGIT_YEAR_START; private static final Date DEFAULT_TWO_DIGIT_YEAR_START;
@ -138,7 +138,7 @@ public static Date parseDate(
throw new IllegalArgumentException("dateValue is null"); throw new IllegalArgumentException("dateValue is null");
} }
if (dateFormats == null) { if (dateFormats == null) {
dateFormats = DEFAULT_PATTERNS; dateFormats = DEFAULT_PATTERNS;
} }
if (startDate == null) { if (startDate == null) {
startDate = DEFAULT_TWO_DIGIT_YEAR_START; startDate = DEFAULT_TWO_DIGIT_YEAR_START;
@ -153,8 +153,8 @@ public static Date parseDate(
} }
for (int i = 0; i < dateFormats.length; i++) { for (int i = 0; i < dateFormats.length; i++) {
SimpleDateFormat dateParser = DateFormatHolder.formatFor(dateFormats[i]); SimpleDateFormat dateParser = DateFormatHolder.formatFor(dateFormats[i]);
dateParser.set2DigitYearStart(startDate); dateParser.set2DigitYearStart(startDate);
try { try {
return dateParser.parse(dateValue); return dateParser.parse(dateValue);

View File

@ -91,8 +91,8 @@ public static Test suite() {
private class BasicRedirectService implements HttpRequestHandler { private class BasicRedirectService implements HttpRequestHandler {
private int statuscode = HttpStatus.SC_MOVED_TEMPORARILY; private int statuscode = HttpStatus.SC_MOVED_TEMPORARILY;
private String host = null; private String host = null;
private int port; private int port;
public BasicRedirectService(final String host, int port, int statuscode) { public BasicRedirectService(final String host, int port, int statuscode) {
@ -100,7 +100,7 @@ public BasicRedirectService(final String host, int port, int statuscode) {
this.host = host; this.host = host;
this.port = port; this.port = port;
if (statuscode > 0) { if (statuscode > 0) {
this.statuscode = statuscode; this.statuscode = statuscode;
} }
} }
@ -117,7 +117,7 @@ public void handle(
if (uri.equals("/oldlocation/")) { if (uri.equals("/oldlocation/")) {
response.setStatusLine(ver, this.statuscode); response.setStatusLine(ver, this.statuscode);
response.addHeader(new BasicHeader("Location", response.addHeader(new BasicHeader("Location",
"http://" + this.host + ":" + this.port + "/newlocation/")); "http://" + this.host + ":" + this.port + "/newlocation/"));
response.addHeader(new BasicHeader("Connection", "close")); response.addHeader(new BasicHeader("Connection", "close"));
} else if (uri.equals("/newlocation/")) { } else if (uri.equals("/newlocation/")) {
response.setStatusLine(ver, HttpStatus.SC_OK); response.setStatusLine(ver, HttpStatus.SC_OK);

View File

@ -1,7 +1,7 @@
/* /*
* $HeadURL:$ * $HeadURL$
* $Revision:$ * $Revision$
* $Date:$ * $Date$
* ==================================================================== * ====================================================================
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
@ -78,80 +78,80 @@ public void handle(
} }
public String getRequestedUri() { public String getRequestedUri() {
return requestedUri; return requestedUri;
} }
} }
private void doTest(String uri, boolean relative) throws Exception { private void doTest(String uri, boolean relative) throws Exception {
int port = this.localServer.getServicePort(); int port = this.localServer.getServicePort();
String host = "localhost"; String host = "localhost";
UriListeningService listener = new UriListeningService(); UriListeningService listener = new UriListeningService();
this.localServer.register("*", listener); this.localServer.register("*", listener);
DefaultHttpClient client = new DefaultHttpClient(); DefaultHttpClient client = new DefaultHttpClient();
HttpResponse response; HttpResponse response;
if(!relative) { if(!relative) {
String request = "http://" + host + ":" + port + uri; String request = "http://" + host + ":" + port + uri;
HttpGet httpget = new HttpGet(request); HttpGet httpget = new HttpGet(request);
response = client.execute(httpget); response = client.execute(httpget);
response.getEntity().consumeContent(); response.getEntity().consumeContent();
} else { } else {
HttpHost target = new HttpHost(host, port); HttpHost target = new HttpHost(host, port);
HttpGet httpget = new HttpGet(uri); HttpGet httpget = new HttpGet(uri);
response = client.execute(target, httpget); 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()); assertEquals(uri, listener.getRequestedUri());
} }
public void testEscapedAmpersandInQueryAbsolute() throws Exception { public void testEscapedAmpersandInQueryAbsolute() throws Exception {
doTest("/path/a=b&c=%26d", false); doTest("/path/a=b&c=%26d", false);
} }
public void testEscapedAmpersandInQueryRelative() throws Exception { public void testEscapedAmpersandInQueryRelative() throws Exception {
doTest("/path/a=b&c=%26d", true); doTest("/path/a=b&c=%26d", true);
} }
public void testPlusInPathAbsolute() throws Exception { public void testPlusInPathAbsolute() throws Exception {
doTest("/path+go", false); doTest("/path+go", false);
} }
public void testPlusInPathRelative() throws Exception { public void testPlusInPathRelative() throws Exception {
doTest("/path+go", true); doTest("/path+go", true);
} }
public void testEscapedSpaceInPathAbsolute() throws Exception { public void testEscapedSpaceInPathAbsolute() throws Exception {
doTest("/path%20go?a=b&c=d", false); doTest("/path%20go?a=b&c=d", false);
} }
public void testEscapedSpaceInPathRelative() throws Exception { public void testEscapedSpaceInPathRelative() throws Exception {
doTest("/path%20go?a=b&c=d", true); doTest("/path%20go?a=b&c=d", true);
} }
public void testEscapedAmpersandInPathAbsolute() throws Exception { public void testEscapedAmpersandInPathAbsolute() throws Exception {
doTest("/this%26that?a=b&c=d", false); doTest("/this%26that?a=b&c=d", false);
} }
public void testEscapedAmpersandInPathRelative() throws Exception { public void testEscapedAmpersandInPathRelative() throws Exception {
doTest("/this%26that?a=b&c=d", true); doTest("/this%26that?a=b&c=d", true);
} }
public void testEscapedSpaceInQueryAbsolute() throws Exception { public void testEscapedSpaceInQueryAbsolute() throws Exception {
doTest("/path?a=b&c=d%20e", false); doTest("/path?a=b&c=d%20e", false);
} }
public void testEscapedSpaceInQueryRelative() throws Exception { public void testEscapedSpaceInQueryRelative() throws Exception {
doTest("/path?a=b&c=d%20e", true); doTest("/path?a=b&c=d%20e", true);
} }
public void testPlusInQueryAbsolute() throws Exception { public void testPlusInQueryAbsolute() throws Exception {
doTest("/path?a=b&c=d+e", false); doTest("/path?a=b&c=d+e", false);
} }
public void testPlusInQueryRelative() throws Exception { public void testPlusInQueryRelative() throws Exception {
doTest("/path?a=b&c=d+e", true); doTest("/path?a=b&c=d+e", true);
} }
} }

View File

@ -126,24 +126,24 @@ public void testRegisterUnregister() {
HttpHost host = new HttpHost("www.test.invalid", -1, "http"); HttpHost host = new HttpHost("www.test.invalid", -1, "http");
HttpHost hosts = new HttpHost("www.test.invalid", -1, "https"); HttpHost hosts = new HttpHost("www.test.invalid", -1, "https");
assertNull(schmreg.register(myhttp)); assertNull(schmreg.register(myhttp));
assertNull(schmreg.register(https)); assertNull(schmreg.register(https));
assertSame(myhttp, schmreg.register(http)); assertSame(myhttp, schmreg.register(http));
assertSame(http, schmreg.getScheme("http")); assertSame(http, schmreg.getScheme("http"));
assertSame(http, schmreg.getScheme(host)); assertSame(http, schmreg.getScheme(host));
assertSame(https, schmreg.getScheme("https")); assertSame(https, schmreg.getScheme("https"));
assertSame(https, schmreg.getScheme(hosts)); assertSame(https, schmreg.getScheme(hosts));
schmreg.unregister("http"); schmreg.unregister("http");
schmreg.unregister("https"); schmreg.unregister("https");
assertNull(schmreg.get("http")); // get() does not throw exception assertNull(schmreg.get("http")); // get() does not throw exception
try { try {
schmreg.getScheme("http"); // getScheme() does throw exception schmreg.getScheme("http"); // getScheme() does throw exception
fail("IllegalStateException should have been thrown"); fail("IllegalStateException should have been thrown");
} catch (IllegalStateException ex) { } catch (IllegalStateException ex) {
// expected // expected
} }
} }
@ -160,8 +160,8 @@ public void testIterator() {
("https", SecureSocketFactoryMockup.INSTANCE, 443); ("https", SecureSocketFactoryMockup.INSTANCE, 443);
// ("https", SSLSocketFactory.getSocketFactory(), 443); // ("https", SSLSocketFactory.getSocketFactory(), 443);
schmreg.register(http); schmreg.register(http);
schmreg.register(https); schmreg.register(https);
names = schmreg.getSchemeNames(); names = schmreg.getSchemeNames();
assertNotNull(names); assertNotNull(names);
@ -198,34 +198,34 @@ else if ("https".equals(name))
public void testIllegalRegisterUnregister() { public void testIllegalRegisterUnregister() {
SchemeRegistry schmreg = new SchemeRegistry(); SchemeRegistry schmreg = new SchemeRegistry();
try { try {
schmreg.register(null); schmreg.register(null);
fail("IllegalArgumentException should have been thrown"); fail("IllegalArgumentException should have been thrown");
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
// expected // expected
} }
try { try {
schmreg.unregister(null); schmreg.unregister(null);
fail("IllegalArgumentException should have been thrown"); fail("IllegalArgumentException should have been thrown");
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
// expected // expected
} }
try { try {
schmreg.get(null); schmreg.get(null);
fail("IllegalArgumentException should have been thrown"); fail("IllegalArgumentException should have been thrown");
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
// expected // expected
} }
try { try {
schmreg.getScheme((String)null); schmreg.getScheme((String)null);
fail("IllegalArgumentException should have been thrown"); fail("IllegalArgumentException should have been thrown");
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
// expected // expected
} }
try { try {
schmreg.getScheme((HttpHost)null); schmreg.getScheme((HttpHost)null);
fail("IllegalArgumentException should have been thrown"); fail("IllegalArgumentException should have been thrown");
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
// expected // expected
} }
} }

View File

@ -98,8 +98,8 @@ public void testBasicCredentialsProviderNoCredentials() {
public void testBasicCredentialsProviderDefaultCredentials() { public void testBasicCredentialsProviderDefaultCredentials() {
BasicCredentialsProvider state = new BasicCredentialsProvider(); BasicCredentialsProvider state = new BasicCredentialsProvider();
state.setCredentials(AuthScope.ANY, CREDS1); state.setCredentials(AuthScope.ANY, CREDS1);
state.setCredentials(SCOPE2, CREDS2); state.setCredentials(SCOPE2, CREDS2);
assertEquals(CREDS1, state.getCredentials(BOGUS)); assertEquals(CREDS1, state.getCredentials(BOGUS));
} }

View File

@ -1,7 +1,7 @@
/* /*
* $HeadURL:$ * $HeadURL$
* $Revision:$ * $Revision$
* $Date:$ * $Date$
* ==================================================================== * ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
@ -50,7 +50,7 @@
* *
* @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a> * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
* *
* @version $Revision:$ * @version $Revision$
*/ */
public class TestCookieBestMatchSpec extends TestCase { public class TestCookieBestMatchSpec extends TestCase {
@ -218,8 +218,8 @@ public void testCookieStandardCompliantFormatting() throws Exception {
Header header = headers.get(0); Header header = headers.get(0);
assertEquals("$Version=1; name1=\"value1\"; $Path=\"/\"; $Domain=\".domain.com\"; " + assertEquals("$Version=1; name1=\"value1\"; $Path=\"/\"; $Domain=\".domain.com\"; " +
"name2=\"value2\"; $Path=\"/\"; $Domain=\".domain.com\"", "name2=\"value2\"; $Path=\"/\"; $Domain=\".domain.com\"",
header.getValue()); header.getValue());
} }

View File

@ -65,41 +65,41 @@ public void testBasicDateParse() throws Exception {
calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.MILLISECOND, 0);
Date date1 = calendar.getTime(); Date date1 = calendar.getTime();
String[] formats = new String[] { String[] formats = new String[] {
DateUtils.PATTERN_RFC1123 DateUtils.PATTERN_RFC1123
}; };
Date date2 = DateUtils.parseDate("Fri, 14 Oct 2005 00:00:00 GMT", formats, null); Date date2 = DateUtils.parseDate("Fri, 14 Oct 2005 00:00:00 GMT", formats, null);
assertEquals(date1, date2); assertEquals(date1, date2);
date2 = DateUtils.parseDate("Fri, 14 Oct 2005 00:00:00 GMT", formats); date2 = DateUtils.parseDate("Fri, 14 Oct 2005 00:00:00 GMT", formats);
assertEquals(date1, date2); assertEquals(date1, date2);
date2 = DateUtils.parseDate("Fri, 14 Oct 2005 00:00:00 GMT"); date2 = DateUtils.parseDate("Fri, 14 Oct 2005 00:00:00 GMT");
assertEquals(date1, date2); assertEquals(date1, date2);
} }
public void testInvalidInput() throws Exception { public void testInvalidInput() throws Exception {
try { try {
DateUtils.parseDate(null, null, null); DateUtils.parseDate(null, null, null);
fail("IllegalArgumentException should habe been thrown"); fail("IllegalArgumentException should habe been thrown");
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
// expected // expected
} }
try { try {
DateUtils.parseDate("Fri, 14 Oct 2005 00:00:00 GMT", new String[] {}, null); DateUtils.parseDate("Fri, 14 Oct 2005 00:00:00 GMT", new String[] {}, null);
fail("DateParseException should habe been thrown"); fail("DateParseException should habe been thrown");
} catch (DateParseException ex) { } catch (DateParseException ex) {
// expected // expected
} }
try { try {
DateUtils.formatDate(null); DateUtils.formatDate(null);
fail("IllegalArgumentException should habe been thrown"); fail("IllegalArgumentException should habe been thrown");
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
// expected // expected
} }
try { try {
DateUtils.formatDate(new Date(), null); DateUtils.formatDate(new Date(), null);
fail("IllegalArgumentException should habe been thrown"); fail("IllegalArgumentException should habe been thrown");
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
// expected // expected
} }
} }
@ -110,11 +110,11 @@ public void testTwoDigitYearDateParse() throws Exception {
calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.MILLISECOND, 0);
Date date1 = calendar.getTime(); Date date1 = calendar.getTime();
String[] formats = new String[] { String[] formats = new String[] {
DateUtils.PATTERN_RFC1036 DateUtils.PATTERN_RFC1036
}; };
Date date2 = DateUtils.parseDate("Friday, 14-Oct-05 00:00:00 GMT", formats, null); Date date2 = DateUtils.parseDate("Friday, 14-Oct-05 00:00:00 GMT", formats, null);
assertEquals(date1, date2); assertEquals(date1, date2);
calendar.set(1900, Calendar.JANUARY, 0, 0, 0, 0); calendar.set(1900, Calendar.JANUARY, 0, 0, 0, 0);
calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.MILLISECOND, 0);
@ -124,8 +124,8 @@ public void testTwoDigitYearDateParse() throws Exception {
calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.MILLISECOND, 0);
date1 = calendar.getTime(); date1 = calendar.getTime();
date2 = DateUtils.parseDate("Friday, 14-Oct-05 00:00:00 GMT", formats, startDate); date2 = DateUtils.parseDate("Friday, 14-Oct-05 00:00:00 GMT", formats, startDate);
assertEquals(date1, date2); assertEquals(date1, date2);
} }
public void testParseQuotedDate() throws Exception { public void testParseQuotedDate() throws Exception {
@ -135,11 +135,11 @@ public void testParseQuotedDate() throws Exception {
calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.MILLISECOND, 0);
Date date1 = calendar.getTime(); Date date1 = calendar.getTime();
String[] formats = new String[] { String[] formats = new String[] {
DateUtils.PATTERN_RFC1123 DateUtils.PATTERN_RFC1123
}; };
Date date2 = DateUtils.parseDate("'Fri, 14 Oct 2005 00:00:00 GMT'", formats); Date date2 = DateUtils.parseDate("'Fri, 14 Oct 2005 00:00:00 GMT'", formats);
assertEquals(date1, date2); assertEquals(date1, date2);
} }
public void testBasicDateFormat() throws Exception { public void testBasicDateFormat() throws Exception {