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 [11/12] - in /httpcomponents/httpclient/trunk:
httpclient-benchmark/src/main/java/org/apache/http/client/benchmark/
httpclient-contrib/src/main/java/org/apache/http/contrib/auth/
httpclient/src/main/java/org/apache/http/auth/ httpcl...
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestTSCCMWithServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestTSCCMWithServer.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestTSCCMWithServer.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestTSCCMWithServer.java Fri Apr 23 19:19:23 2010
@@ -163,21 +163,21 @@ public class TestTSCCMWithServer extends
}
private static ManagedClientConnection getConnection(
- final ClientConnectionManager mgr,
+ final ClientConnectionManager mgr,
final HttpRoute route,
long timeout,
TimeUnit unit) throws ConnectionPoolTimeoutException, InterruptedException {
ClientConnectionRequest connRequest = mgr.requestConnection(route, null);
return connRequest.getConnection(timeout, unit);
}
-
+
private static ManagedClientConnection getConnection(
- final ClientConnectionManager mgr,
+ final ClientConnectionManager mgr,
final HttpRoute route) throws ConnectionPoolTimeoutException, InterruptedException {
ClientConnectionRequest connRequest = mgr.requestConnection(route, null);
return connRequest.getConnection(0, null);
}
-
+
/**
* Tests releasing and re-using a connection after a response is read.
*/
@@ -199,7 +199,7 @@ public class TestTSCCMWithServer extends
// a new context is created for each testcase, no need to reset
HttpResponse response = Helper.execute(
- request, conn, target,
+ request, conn, target,
httpExecutor, httpProcessor, defaultParams, httpContext);
assertEquals("wrong status in first response",
@@ -284,7 +284,7 @@ public class TestTSCCMWithServer extends
// a new context is created for each testcase, no need to reset
HttpResponse response = Helper.execute(
- request, conn, target,
+ request, conn, target,
httpExecutor, httpProcessor, defaultParams, httpContext);
assertEquals("wrong status in first response",
@@ -349,7 +349,7 @@ public class TestTSCCMWithServer extends
Thread.sleep(150);
conn = getConnection(mgr, route);
assertTrue("connection should have been closed", !conn.isOpen());
-
+
// repeat the communication, no need to prepare the request again
conn.open(route, httpContext, defaultParams);
httpContext.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
@@ -363,7 +363,7 @@ public class TestTSCCMWithServer extends
assertEquals("wrong length of fourth response entity",
rsplen, data.length);
// ignore data, but it must be read
-
+
mgr.shutdown();
}
@@ -388,13 +388,13 @@ public class TestTSCCMWithServer extends
assertEquals("connectionsInPool(host)", 1, mgr.getConnectionsInPool(route));
mgr.closeExpiredConnections();
-
+
// Time has not expired yet.
assertEquals("connectionsInPool", 1, mgr.getConnectionsInPool());
assertEquals("connectionsInPool(host)", 1, mgr.getConnectionsInPool(route));
-
+
Thread.sleep(150);
-
+
mgr.closeExpiredConnections();
// Time expired now, connections are destroyed.
@@ -403,7 +403,7 @@ public class TestTSCCMWithServer extends
mgr.shutdown();
}
-
+
/**
* Tests releasing connection from #abort method called from the
@@ -427,7 +427,7 @@ public class TestTSCCMWithServer extends
// a new context is created for each testcase, no need to reset
HttpResponse response = Helper.execute(
- request, conn, target,
+ request, conn, target,
httpExecutor, httpProcessor, defaultParams, httpContext);
assertEquals("wrong status in first response",
@@ -446,7 +446,7 @@ public class TestTSCCMWithServer extends
// abort the connection
assertTrue(conn instanceof AbstractClientConnAdapter);
((AbstractClientConnAdapter) conn).abortConnection();
-
+
// the connection is expected to be released back to the manager
conn = getConnection(mgr, route, 5L, TimeUnit.SECONDS);
assertFalse("connection should have been closed", conn.isOpen());
@@ -475,7 +475,7 @@ public class TestTSCCMWithServer extends
conn.open(route, httpContext, defaultParams);
// a new context is created for each testcase, no need to reset
- HttpResponse response = Helper.execute(request, conn, target,
+ HttpResponse response = Helper.execute(request, conn, target,
httpExecutor, httpProcessor, defaultParams, httpContext);
EntityUtils.toByteArray(response.getEntity());
@@ -491,7 +491,7 @@ public class TestTSCCMWithServer extends
// we got from the manager, directly as well as in the request
// and in the context. The manager will be GCed only if the
// connection wrapper is truly detached.
- WeakReference<ThreadSafeClientConnManager> wref =
+ WeakReference<ThreadSafeClientConnManager> wref =
new WeakReference<ThreadSafeClientConnManager>(mgr);
mgr = null;
@@ -503,9 +503,9 @@ public class TestTSCCMWithServer extends
assertNull("TSCCM not garbage collected", wref.get());
}
-
+
public void testAbortDuringConnecting() throws Exception {
- final CountDownLatch connectLatch = new CountDownLatch(1);
+ final CountDownLatch connectLatch = new CountDownLatch(1);
final StallingSocketFactory stallingSocketFactory = new StallingSocketFactory(
connectLatch, WaitPolicy.BEFORE_CONNECT, PlainSocketFactory.getSocketFactory());
Scheme scheme = new Scheme("http", 80, stallingSocketFactory);
@@ -520,7 +520,7 @@ public class TestTSCCMWithServer extends
final ManagedClientConnection conn = getConnection(mgr, route);
assertTrue(conn instanceof AbstractClientConnAdapter);
-
+
final AtomicReference<Throwable> throwRef = new AtomicReference<Throwable>();
Thread abortingThread = new Thread(new Runnable() {
public void run() {
@@ -534,7 +534,7 @@ public class TestTSCCMWithServer extends
}
});
abortingThread.start();
-
+
try {
conn.open(route, httpContext, defaultParams);
fail("expected SocketException");
@@ -543,10 +543,10 @@ public class TestTSCCMWithServer extends
abortingThread.join(5000);
if(throwRef.get() != null)
throw new RuntimeException(throwRef.get());
-
+
assertFalse(conn.isOpen());
assertEquals(0, localServer.getAcceptedConnectionCount());
-
+
// the connection is expected to be released back to the manager
ManagedClientConnection conn2 = getConnection(mgr, route, 5L, TimeUnit.SECONDS);
assertFalse("connection should have been closed", conn2.isOpen());
@@ -554,9 +554,9 @@ public class TestTSCCMWithServer extends
mgr.releaseConnection(conn2, -1, null);
mgr.shutdown();
}
-
+
public void testAbortBeforeSocketCreate() throws Exception {
- final CountDownLatch connectLatch = new CountDownLatch(1);
+ final CountDownLatch connectLatch = new CountDownLatch(1);
final StallingSocketFactory stallingSocketFactory = new StallingSocketFactory(
connectLatch, WaitPolicy.BEFORE_CREATE, PlainSocketFactory.getSocketFactory());
Scheme scheme = new Scheme("http", 80, stallingSocketFactory);
@@ -571,7 +571,7 @@ public class TestTSCCMWithServer extends
final ManagedClientConnection conn = getConnection(mgr, route);
assertTrue(conn instanceof AbstractClientConnAdapter);
-
+
final AtomicReference<Throwable> throwRef = new AtomicReference<Throwable>();
Thread abortingThread = new Thread(new Runnable() {
public void run() {
@@ -585,7 +585,7 @@ public class TestTSCCMWithServer extends
}
});
abortingThread.start();
-
+
try {
conn.open(route, httpContext, defaultParams);
fail("expected exception");
@@ -596,10 +596,10 @@ public class TestTSCCMWithServer extends
abortingThread.join(5000);
if(throwRef.get() != null)
throw new RuntimeException(throwRef.get());
-
+
assertFalse(conn.isOpen());
assertEquals(0, localServer.getAcceptedConnectionCount());
-
+
// the connection is expected to be released back to the manager
ManagedClientConnection conn2 = getConnection(mgr, route, 5L, TimeUnit.SECONDS);
assertFalse("connection should have been closed", conn2.isOpen());
@@ -607,9 +607,9 @@ public class TestTSCCMWithServer extends
mgr.releaseConnection(conn2, -1, null);
mgr.shutdown();
}
-
+
public void testAbortAfterSocketConnect() throws Exception {
- final CountDownLatch connectLatch = new CountDownLatch(1);
+ final CountDownLatch connectLatch = new CountDownLatch(1);
final StallingSocketFactory stallingSocketFactory = new StallingSocketFactory(
connectLatch, WaitPolicy.AFTER_CONNECT, PlainSocketFactory.getSocketFactory());
Scheme scheme = new Scheme("http", 80, stallingSocketFactory);
@@ -624,7 +624,7 @@ public class TestTSCCMWithServer extends
final ManagedClientConnection conn = getConnection(mgr, route);
assertTrue(conn instanceof AbstractClientConnAdapter);
-
+
final AtomicReference<Throwable> throwRef = new AtomicReference<Throwable>();
Thread abortingThread = new Thread(new Runnable() {
public void run() {
@@ -638,7 +638,7 @@ public class TestTSCCMWithServer extends
}
});
abortingThread.start();
-
+
try {
conn.open(route, httpContext, defaultParams);
fail("expected SocketException");
@@ -647,7 +647,7 @@ public class TestTSCCMWithServer extends
abortingThread.join(5000);
if(throwRef.get() != null)
throw new RuntimeException(throwRef.get());
-
+
assertFalse(conn.isOpen());
// Give the server a bit of time to accept the connection, but
// ensure that it can accept it.
@@ -657,7 +657,7 @@ public class TestTSCCMWithServer extends
Thread.sleep(100);
}
assertEquals(1, localServer.getAcceptedConnectionCount());
-
+
// the connection is expected to be released back to the manager
ManagedClientConnection conn2 = getConnection(mgr, route, 5L, TimeUnit.SECONDS);
assertFalse("connection should have been closed", conn2.isOpen());
@@ -665,11 +665,11 @@ public class TestTSCCMWithServer extends
mgr.releaseConnection(conn2, -1, null);
mgr.shutdown();
}
-
+
public void testAbortAfterOperatorOpen() throws Exception {
final CountDownLatch connectLatch = new CountDownLatch(1);
final AtomicReference<StallingOperator> operatorRef = new AtomicReference<StallingOperator>();
-
+
ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(supportedSchemes) {
@Override
protected ClientConnectionOperator createConnectionOperator(
@@ -686,7 +686,7 @@ public class TestTSCCMWithServer extends
final ManagedClientConnection conn = getConnection(mgr, route);
assertTrue(conn instanceof AbstractClientConnAdapter);
-
+
final AtomicReference<Throwable> throwRef = new AtomicReference<Throwable>();
Thread abortingThread = new Thread(new Runnable() {
public void run() {
@@ -700,7 +700,7 @@ public class TestTSCCMWithServer extends
}
});
abortingThread.start();
-
+
try {
conn.open(route, httpContext, defaultParams);
fail("expected exception");
@@ -711,7 +711,7 @@ public class TestTSCCMWithServer extends
abortingThread.join(5000);
if(throwRef.get() != null)
throw new RuntimeException(throwRef.get());
-
+
assertFalse(conn.isOpen());
// Give the server a bit of time to accept the connection, but
// ensure that it can accept it.
@@ -721,7 +721,7 @@ public class TestTSCCMWithServer extends
Thread.sleep(100);
}
assertEquals(1, localServer.getAcceptedConnectionCount());
-
+
// the connection is expected to be released back to the manager
ManagedClientConnection conn2 = getConnection(mgr, route, 5L, TimeUnit.SECONDS);
assertFalse("connection should have been closed", conn2.isOpen());
@@ -729,12 +729,12 @@ public class TestTSCCMWithServer extends
mgr.releaseConnection(conn2, -1, null);
mgr.shutdown();
}
-
+
private static class LatchSupport {
private final CountDownLatch continueLatch;
private final CountDownLatch waitLatch = new CountDownLatch(1);
protected final WaitPolicy waitPolicy;
-
+
LatchSupport(CountDownLatch continueLatch, WaitPolicy waitPolicy) {
this.continueLatch = continueLatch;
this.waitPolicy = waitPolicy;
@@ -744,7 +744,7 @@ public class TestTSCCMWithServer extends
if(!waitLatch.await(1, TimeUnit.SECONDS))
throw new RuntimeException("waited too long");
}
-
+
void latch() {
waitLatch.countDown();
try {
@@ -755,7 +755,7 @@ public class TestTSCCMWithServer extends
}
}
}
-
+
private static class StallingOperator extends LatchSupport implements ClientConnectionOperator {
private final ClientConnectionOperator delegate;
@@ -783,14 +783,14 @@ public class TestTSCCMWithServer extends
delegate.updateSecureConnection(conn, target, context, params);
}
}
-
+
private static class StallingSocketFactory extends LatchSupport implements SchemeSocketFactory {
-
+
private final SchemeSocketFactory delegate;
public StallingSocketFactory(
final CountDownLatch continueLatch,
- final WaitPolicy waitPolicy,
+ final WaitPolicy waitPolicy,
final SchemeSocketFactory delegate) {
super(continueLatch, waitPolicy);
this.delegate = delegate;
@@ -798,24 +798,24 @@ public class TestTSCCMWithServer extends
public Socket connectSocket(
final Socket sock,
- final InetSocketAddress remoteAddress,
- final InetSocketAddress localAddress,
+ final InetSocketAddress remoteAddress,
+ final InetSocketAddress localAddress,
final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
if(waitPolicy == WaitPolicy.BEFORE_CONNECT)
latch();
-
+
Socket socket = delegate.connectSocket(sock, remoteAddress, localAddress, params);
-
+
if(waitPolicy == WaitPolicy.AFTER_CONNECT)
latch();
-
+
return socket;
}
public Socket createSocket(final HttpParams params) throws IOException {
if(waitPolicy == WaitPolicy.BEFORE_CREATE)
latch();
-
+
return delegate.createSocket(params);
}
@@ -825,6 +825,6 @@ public class TestTSCCMWithServer extends
}
private enum WaitPolicy { BEFORE_CREATE, BEFORE_CONNECT, AFTER_CONNECT, AFTER_OPEN }
-
+
} // class TestTSCCMWithServer
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/AwaitThread.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/AwaitThread.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/AwaitThread.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/AwaitThread.java Fri Apr 23 19:19:23 2010
@@ -75,7 +75,7 @@ public class AwaitThread extends Thread
// terminate
}
-
+
public Throwable getException() {
return exception;
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestConnPoolByRoute.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestConnPoolByRoute.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestConnPoolByRoute.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestConnPoolByRoute.java Fri Apr 23 19:19:23 2010
@@ -61,15 +61,15 @@ public class TestConnPoolByRoute extends
ClientConnectionOperator operator = new DefaultClientConnectionOperator(
supportedSchemes);
-
- ConnPerRouteBean connPerRoute = new ConnPerRouteBean(3);
+
+ ConnPerRouteBean connPerRoute = new ConnPerRouteBean(3);
ConnPoolByRoute connPool = new ConnPoolByRoute(operator, connPerRoute, 20);
try {
// Allocate max possible entries
PoolEntryRequest r1 = connPool.requestPoolEntry(route, null);
BasicPoolEntry e1 = r1.getPoolEntry(10, TimeUnit.SECONDS);
assertNotNull(e1);
-
+
PoolEntryRequest r2 = connPool.requestPoolEntry(route, null);
BasicPoolEntry e2 = r2.getPoolEntry(10, TimeUnit.SECONDS);
assertNotNull(e2);
@@ -93,7 +93,7 @@ public class TestConnPoolByRoute extends
PoolEntryRequest r5 = connPool.requestPoolEntry(route, null);
BasicPoolEntry e5 = r5.getPoolEntry(10, TimeUnit.SECONDS);
assertNotNull(e5);
-
+
} finally {
connPool.shutdown();
}
@@ -105,8 +105,8 @@ public class TestConnPoolByRoute extends
ClientConnectionOperator operator = new DefaultClientConnectionOperator(
supportedSchemes);
-
- ConnPerRouteBean connPerRoute = new ConnPerRouteBean(3);
+
+ ConnPerRouteBean connPerRoute = new ConnPerRouteBean(3);
ConnPoolByRoute connPool = new ConnPoolByRoute(operator, connPerRoute, 20);
try {
// Allocate max possible entries
@@ -142,7 +142,7 @@ public class TestConnPoolByRoute extends
assertNotNull(e4.getState());
assertNotNull(e5.getState());
assertNotNull(e6.getState());
-
+
// Check whether we got the same objects
assertTrue(e4 == e2);
assertTrue(e5 == e3);
@@ -160,7 +160,7 @@ public class TestConnPoolByRoute extends
// Make sure we got a closed connection and a stateless entry back
assertFalse(e7.getConnection().isOpen());
assertNull(e7.getState());
-
+
} finally {
connPool.shutdown();
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestSpuriousWakeup.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestSpuriousWakeup.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestSpuriousWakeup.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestSpuriousWakeup.java Fri Apr 23 19:19:23 2010
@@ -86,7 +86,7 @@ public class TestSpuriousWakeup extends
public XConnPoolByRoute(
- final ClientConnectionOperator operator,
+ final ClientConnectionOperator operator,
final ConnPerRoute connPerRoute,
int maxTotalConnections) {
super(operator, connPerRoute, maxTotalConnections);
@@ -137,7 +137,7 @@ public class TestSpuriousWakeup extends
try {
mgr.setMaxTotalConnections(1);
mgr.setDefaultMaxPerRoute(1);
-
+
// take out the only connection
ClientConnectionRequest connRequest = mgr.requestConnection(ROUTE, null);
ManagedClientConnection conn = connRequest.getConnection(0, null);
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestAbstractCookieSpec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestAbstractCookieSpec.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestAbstractCookieSpec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestAbstractCookieSpec.java Fri Apr 23 19:19:23 2010
@@ -73,7 +73,7 @@ public class TestAbstractCookieSpec exte
public void validate(Cookie cookie, CookieOrigin origin) throws MalformedCookieException {
}
-
+
public int getVersion() {
return 0;
}
@@ -81,9 +81,9 @@ public class TestAbstractCookieSpec exte
public Header getVersionHeader() {
return null;
}
-
+
}
-
+
private static class DummyCookieAttribHandler implements CookieAttributeHandler {
public boolean match(Cookie cookie, CookieOrigin origin) {
@@ -95,13 +95,13 @@ public class TestAbstractCookieSpec exte
public void validate(Cookie cookie, CookieOrigin origin) throws MalformedCookieException {
}
-
+
}
-
+
public void testSimpleRegisterAndGet() {
CookieAttributeHandler h1 = new DummyCookieAttribHandler();
CookieAttributeHandler h2 = new DummyCookieAttribHandler();
-
+
AbstractCookieSpec cookiespec = new DummyCookieSpec();
cookiespec.registerAttribHandler("this", h1);
cookiespec.registerAttribHandler("that", h2);
@@ -112,7 +112,7 @@ public class TestAbstractCookieSpec exte
assertTrue(h2 == cookiespec.getAttribHandler("that"));
assertTrue(h1 == cookiespec.getAttribHandler("thistoo"));
assertTrue(h2 == cookiespec.getAttribHandler("thattoo"));
-
+
Iterator<CookieAttributeHandler> it = cookiespec.getAttribHandlers().iterator();
assertNotNull(it.next());
assertNotNull(it.next());
@@ -124,11 +124,11 @@ public class TestAbstractCookieSpec exte
public void testInvalidHandler() {
CookieAttributeHandler h1 = new DummyCookieAttribHandler();
CookieAttributeHandler h2 = new DummyCookieAttribHandler();
-
+
AbstractCookieSpec cookiespec = new DummyCookieSpec();
cookiespec.registerAttribHandler("this", h1);
cookiespec.registerAttribHandler("that", h2);
-
+
assertNull(cookiespec.findAttribHandler("whatever"));
try {
cookiespec.getAttribHandler("whatever");
@@ -153,5 +153,5 @@ public class TestAbstractCookieSpec exte
// expected
}
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicClientCookie.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicClientCookie.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicClientCookie.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicClientCookie.java Fri Apr 23 19:19:23 2010
@@ -65,7 +65,7 @@ public class TestBasicClientCookie exten
//expected
}
}
-
+
public void testCloning() throws Exception {
BasicClientCookie orig = new BasicClientCookie("name", "value");
orig.setDomain("domain");
@@ -78,7 +78,7 @@ public class TestBasicClientCookie exten
assertEquals(orig.getPath(), clone.getPath());
assertEquals(orig.getAttribute("attrib"), clone.getAttribute("attrib"));
}
-
+
public void testSerialization() throws Exception {
BasicClientCookie orig = new BasicClientCookie("name", "value");
orig.setDomain("domain");
@@ -98,5 +98,5 @@ public class TestBasicClientCookie exten
assertEquals(orig.getPath(), clone.getPath());
assertEquals(orig.getAttribute("attrib"), clone.getAttribute("attrib"));
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicClientCookie2.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicClientCookie2.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicClientCookie2.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicClientCookie2.java Fri Apr 23 19:19:23 2010
@@ -65,7 +65,7 @@ public class TestBasicClientCookie2 exte
//expected
}
}
-
+
public void testCloning() throws Exception {
BasicClientCookie2 orig = new BasicClientCookie2("name", "value");
orig.setDomain("domain");
@@ -82,7 +82,7 @@ public class TestBasicClientCookie2 exte
assertEquals(orig.getPorts()[0], clone.getPorts()[0]);
assertEquals(orig.getPorts()[1], clone.getPorts()[1]);
}
-
+
public void testSerialization() throws Exception {
BasicClientCookie2 orig = new BasicClientCookie2("name", "value");
orig.setDomain("domain");
@@ -111,5 +111,5 @@ public class TestBasicClientCookie2 exte
assertEquals(expected[i], clones[i]);
}
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicCookieAttribHandlers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicCookieAttribHandlers.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicCookieAttribHandlers.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicCookieAttribHandlers.java Fri Apr 23 19:19:23 2010
@@ -68,14 +68,14 @@ public class TestBasicCookieAttribHandle
}
public void testBasicDomainParse() throws Exception {
- BasicClientCookie cookie = new BasicClientCookie("name", "value");
+ BasicClientCookie cookie = new BasicClientCookie("name", "value");
CookieAttributeHandler h = new BasicDomainHandler();
h.parse(cookie, "www.somedomain.com");
assertEquals("www.somedomain.com", cookie.getDomain());
}
public void testBasicDomainParseInvalid() throws Exception {
- BasicClientCookie cookie = new BasicClientCookie("name", "value");
+ BasicClientCookie cookie = new BasicClientCookie("name", "value");
CookieAttributeHandler h = new BasicDomainHandler();
try {
h.parse(cookie, "");
@@ -92,10 +92,10 @@ public class TestBasicCookieAttribHandle
}
public void testBasicDomainValidate1() throws Exception {
- BasicClientCookie cookie = new BasicClientCookie("name", "value");
- CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false);
+ BasicClientCookie cookie = new BasicClientCookie("name", "value");
+ CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false);
CookieAttributeHandler h = new BasicDomainHandler();
-
+
cookie.setDomain(".somedomain.com");
h.validate(cookie, origin);
@@ -116,10 +116,10 @@ public class TestBasicCookieAttribHandle
}
public void testBasicDomainValidate2() throws Exception {
- BasicClientCookie cookie = new BasicClientCookie("name", "value");
- CookieOrigin origin = new CookieOrigin("somehost", 80, "/", false);
+ BasicClientCookie cookie = new BasicClientCookie("name", "value");
+ CookieOrigin origin = new CookieOrigin("somehost", 80, "/", false);
CookieAttributeHandler h = new BasicDomainHandler();
-
+
cookie.setDomain("somehost");
h.validate(cookie, origin);
@@ -133,19 +133,19 @@ public class TestBasicCookieAttribHandle
}
public void testBasicDomainValidate3() throws Exception {
- BasicClientCookie cookie = new BasicClientCookie("name", "value");
- CookieOrigin origin = new CookieOrigin("somedomain.com", 80, "/", false);
+ BasicClientCookie cookie = new BasicClientCookie("name", "value");
+ CookieOrigin origin = new CookieOrigin("somedomain.com", 80, "/", false);
CookieAttributeHandler h = new BasicDomainHandler();
-
+
cookie.setDomain(".somedomain.com");
h.validate(cookie, origin);
}
public void testBasicDomainValidate4() throws Exception {
- BasicClientCookie cookie = new BasicClientCookie("name", "value");
- CookieOrigin origin = new CookieOrigin("somedomain.com", 80, "/", false);
+ BasicClientCookie cookie = new BasicClientCookie("name", "value");
+ CookieOrigin origin = new CookieOrigin("somedomain.com", 80, "/", false);
CookieAttributeHandler h = new BasicDomainHandler();
-
+
cookie.setDomain(null);
try {
h.validate(cookie, origin);
@@ -154,27 +154,27 @@ public class TestBasicCookieAttribHandle
// expected
}
}
-
+
public void testBasicDomainMatch1() throws Exception {
- BasicClientCookie cookie = new BasicClientCookie("name", "value");
- CookieOrigin origin = new CookieOrigin("somedomain.com", 80, "/", false);
+ BasicClientCookie cookie = new BasicClientCookie("name", "value");
+ CookieOrigin origin = new CookieOrigin("somedomain.com", 80, "/", false);
CookieAttributeHandler h = new BasicDomainHandler();
cookie.setDomain("somedomain.com");
assertTrue(h.match(cookie, origin));
-
+
cookie.setDomain(".somedomain.com");
assertTrue(h.match(cookie, origin));
}
public void testBasicDomainMatch2() throws Exception {
- BasicClientCookie cookie = new BasicClientCookie("name", "value");
- CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false);
+ BasicClientCookie cookie = new BasicClientCookie("name", "value");
+ CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false);
CookieAttributeHandler h = new BasicDomainHandler();
cookie.setDomain("somedomain.com");
assertTrue(h.match(cookie, origin));
-
+
cookie.setDomain(".somedomain.com");
assertTrue(h.match(cookie, origin));
@@ -217,7 +217,7 @@ public class TestBasicCookieAttribHandle
}
public void testBasicPathParse() throws Exception {
- BasicClientCookie cookie = new BasicClientCookie("name", "value");
+ BasicClientCookie cookie = new BasicClientCookie("name", "value");
CookieAttributeHandler h = new BasicPathHandler();
h.parse(cookie, "stuff");
assertEquals("stuff", cookie.getPath());
@@ -229,31 +229,31 @@ public class TestBasicCookieAttribHandle
public void testBasicPathMatch1() throws Exception {
BasicClientCookie cookie = new BasicClientCookie("name", "value");
- CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff", false);
+ CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff", false);
CookieAttributeHandler h = new BasicPathHandler();
cookie.setPath("/stuff");
assertTrue(h.match(cookie, origin));
}
-
+
public void testBasicPathMatch2() throws Exception {
BasicClientCookie cookie = new BasicClientCookie("name", "value");
- CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff/", false);
+ CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff/", false);
CookieAttributeHandler h = new BasicPathHandler();
cookie.setPath("/stuff");
assertTrue(h.match(cookie, origin));
}
-
+
public void testBasicPathMatch3() throws Exception {
BasicClientCookie cookie = new BasicClientCookie("name", "value");
- CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff/more-stuff", false);
+ CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff/more-stuff", false);
CookieAttributeHandler h = new BasicPathHandler();
cookie.setPath("/stuff");
assertTrue(h.match(cookie, origin));
}
-
+
public void testBasicPathMatch4() throws Exception {
BasicClientCookie cookie = new BasicClientCookie("name", "value");
- CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuffed", false);
+ CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuffed", false);
CookieAttributeHandler h = new BasicPathHandler();
cookie.setPath("/stuff");
assertFalse(h.match(cookie, origin));
@@ -261,7 +261,7 @@ public class TestBasicCookieAttribHandle
public void testBasicPathMatch5() throws Exception {
BasicClientCookie cookie = new BasicClientCookie("name", "value");
- CookieOrigin origin = new CookieOrigin("somehost", 80, "/otherstuff", false);
+ CookieOrigin origin = new CookieOrigin("somehost", 80, "/otherstuff", false);
CookieAttributeHandler h = new BasicPathHandler();
cookie.setPath("/stuff");
assertFalse(h.match(cookie, origin));
@@ -269,7 +269,7 @@ public class TestBasicCookieAttribHandle
public void testBasicPathMatch6() throws Exception {
BasicClientCookie cookie = new BasicClientCookie("name", "value");
- CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff", false);
+ CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff", false);
CookieAttributeHandler h = new BasicPathHandler();
cookie.setPath("/stuff/");
assertTrue(h.match(cookie, origin));
@@ -277,14 +277,14 @@ public class TestBasicCookieAttribHandle
public void testBasicPathMatch7() throws Exception {
BasicClientCookie cookie = new BasicClientCookie("name", "value");
- CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff", false);
+ CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff", false);
CookieAttributeHandler h = new BasicPathHandler();
assertTrue(h.match(cookie, origin));
}
public void testBasicPathValidate() throws Exception {
BasicClientCookie cookie = new BasicClientCookie("name", "value");
- CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff", false);
+ CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff", false);
CookieAttributeHandler h = new BasicPathHandler();
cookie.setPath("/stuff");
h.validate(cookie, origin);
@@ -320,14 +320,14 @@ public class TestBasicCookieAttribHandle
}
public void testBasicMaxAgeParse() throws Exception {
- BasicClientCookie cookie = new BasicClientCookie("name", "value");
+ BasicClientCookie cookie = new BasicClientCookie("name", "value");
CookieAttributeHandler h = new BasicMaxAgeHandler();
h.parse(cookie, "2000");
assertNotNull(cookie.getExpiryDate());
}
public void testBasicMaxAgeParseInvalid() throws Exception {
- BasicClientCookie cookie = new BasicClientCookie("name", "value");
+ BasicClientCookie cookie = new BasicClientCookie("name", "value");
CookieAttributeHandler h = new BasicMaxAgeHandler();
try {
h.parse(cookie, "garbage");
@@ -354,7 +354,7 @@ public class TestBasicCookieAttribHandle
}
public void testBasicCommentParse() throws Exception {
- BasicClientCookie cookie = new BasicClientCookie("name", "value");
+ BasicClientCookie cookie = new BasicClientCookie("name", "value");
CookieAttributeHandler h = new BasicCommentHandler();
h.parse(cookie, "whatever");
assertEquals("whatever", cookie.getComment());
@@ -371,9 +371,9 @@ public class TestBasicCookieAttribHandle
// expected
}
}
-
+
public void testBasicSecureParse() throws Exception {
- BasicClientCookie cookie = new BasicClientCookie("name", "value");
+ BasicClientCookie cookie = new BasicClientCookie("name", "value");
CookieAttributeHandler h = new BasicSecureHandler();
h.parse(cookie, "whatever");
assertTrue(cookie.isSecure());
@@ -385,13 +385,13 @@ public class TestBasicCookieAttribHandle
BasicClientCookie cookie = new BasicClientCookie("name", "value");
CookieAttributeHandler h = new BasicSecureHandler();
- CookieOrigin origin1 = new CookieOrigin("somehost", 80, "/stuff", false);
+ CookieOrigin origin1 = new CookieOrigin("somehost", 80, "/stuff", false);
cookie.setSecure(false);
assertTrue(h.match(cookie, origin1));
cookie.setSecure(true);
assertFalse(h.match(cookie, origin1));
- CookieOrigin origin2 = new CookieOrigin("somehost", 80, "/stuff", true);
+ CookieOrigin origin2 = new CookieOrigin("somehost", 80, "/stuff", true);
cookie.setSecure(false);
assertTrue(h.match(cookie, origin2));
cookie.setSecure(true);
@@ -421,20 +421,20 @@ public class TestBasicCookieAttribHandle
}
public void testBasicExpiresParse() throws Exception {
- BasicClientCookie cookie = new BasicClientCookie("name", "value");
+ BasicClientCookie cookie = new BasicClientCookie("name", "value");
CookieAttributeHandler h = new BasicExpiresHandler(new String[] {DateUtils.PATTERN_RFC1123});
-
+
DateFormat dateformat = new SimpleDateFormat(DateUtils.PATTERN_RFC1123, Locale.US);
dateformat.setTimeZone(DateUtils.GMT);
-
+
Date now = new Date();
-
+
h.parse(cookie, dateformat.format(now));
assertNotNull(cookie.getExpiryDate());
}
-
+
public void testBasicExpiresParseInvalid() throws Exception {
- BasicClientCookie cookie = new BasicClientCookie("name", "value");
+ BasicClientCookie cookie = new BasicClientCookie("name", "value");
CookieAttributeHandler h = new BasicExpiresHandler(new String[] {DateUtils.PATTERN_RFC1123});
try {
h.parse(cookie, "garbage");
@@ -465,27 +465,27 @@ public class TestBasicCookieAttribHandle
// expected
}
}
-
+
public void testPublicSuffixFilter() throws Exception {
BasicClientCookie cookie = new BasicClientCookie("name", "value");
-
+
PublicSuffixFilter h = new PublicSuffixFilter(new RFC2109DomainHandler());
h.setPublicSuffixes(Arrays.asList(new String[] { "co.uk", "com" }));
-
+
cookie.setDomain(".co.uk");
assertFalse(h.match(cookie, new CookieOrigin("apache.co.uk", 80, "/stuff", false)));
-
+
cookie.setDomain("co.uk");
assertFalse(h.match(cookie, new CookieOrigin("apache.co.uk", 80, "/stuff", false)));
-
+
cookie.setDomain(".com");
assertFalse(h.match(cookie, new CookieOrigin("apache.com", 80, "/stuff", false)));
-
+
cookie.setDomain("com");
- assertFalse(h.match(cookie, new CookieOrigin("apache.com", 80, "/stuff", false)));
-
+ assertFalse(h.match(cookie, new CookieOrigin("apache.com", 80, "/stuff", false)));
+
cookie.setDomain("localhost");
- assertTrue(h.match(cookie, new CookieOrigin("localhost", 80, "/stuff", false)));
+ assertTrue(h.match(cookie, new CookieOrigin("localhost", 80, "/stuff", false)));
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestBrowserCompatSpec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestBrowserCompatSpec.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestBrowserCompatSpec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestBrowserCompatSpec.java Fri Apr 23 19:19:23 2010
@@ -67,12 +67,12 @@ public class TestBrowserCompatSpec exten
new BrowserCompatSpec(null);
new BrowserCompatSpec(new String[] { DateUtils.PATTERN_RFC1036 });
}
-
+
/**
* Tests whether domain attribute check is case-insensitive.
*/
public void testDomainCaseInsensitivity() throws Exception {
- Header header = new BasicHeader("Set-Cookie",
+ Header header = new BasicHeader("Set-Cookie",
"name=value; path=/; domain=.whatever.com");
CookieSpec cookiespec = new BrowserCompatSpec();
@@ -85,7 +85,7 @@ public class TestBrowserCompatSpec exten
assertEquals(1, cookies.size());
assertEquals(".whatever.com", cookies.get(0).getDomain());
}
-
+
/**
* Test basic parse (with various spacings
*/
@@ -220,7 +220,7 @@ public class TestBrowserCompatSpec exten
public void testParseSimple() throws Exception {
Header header = new BasicHeader("Set-Cookie","cookie-name=cookie-value");
-
+
CookieSpec cookiespec = new BrowserCompatSpec();
CookieOrigin origin = new CookieOrigin("127.0.0.1", 80, "/path/path", false);
List<Cookie> cookies = cookiespec.parse(header, origin);
@@ -239,10 +239,10 @@ public class TestBrowserCompatSpec exten
assertTrue("Secure",!cookies.get(0).isSecure());
assertEquals("Version",0,cookies.get(0).getVersion());
}
-
+
public void testParseSimple2() throws Exception {
Header header = new BasicHeader("Set-Cookie", "cookie-name=cookie-value");
-
+
CookieSpec cookiespec = new BrowserCompatSpec();
CookieOrigin origin = new CookieOrigin("127.0.0.1", 80, "/path", false);
List<Cookie> cookies = cookiespec.parse(header, origin);
@@ -261,7 +261,7 @@ public class TestBrowserCompatSpec exten
assertTrue("Secure", !cookies.get(0).isSecure());
assertEquals("Version", 0, cookies.get(0).getVersion());
}
-
+
public void testParseNoName() throws Exception {
Header header = new BasicHeader("Set-Cookie","=stuff; path=/");
@@ -277,7 +277,7 @@ public class TestBrowserCompatSpec exten
// expected
}
}
-
+
public void testParseNoValue() throws Exception {
Header header = new BasicHeader("Set-Cookie","cookie-name=");
@@ -437,7 +437,7 @@ public class TestBrowserCompatSpec exten
public void testParseWithAll() throws Exception {
Header header = new BasicHeader("Set-Cookie",
- "cookie-name=cookie-value;Version=1;Path=/commons;Domain=.apache.org;" +
+ "cookie-name=cookie-value;Version=1;Path=/commons;Domain=.apache.org;" +
"Comment=This is a comment.;secure;Expires=Thu, 01-Jan-1970 00:00:10 GMT");
CookieSpec cookiespec = new BrowserCompatSpec();
@@ -523,7 +523,7 @@ public class TestBrowserCompatSpec exten
// expected
}
}
-
+
public void testParseWithPathMismatch2() throws Exception {
Header header = new BasicHeader("Set-Cookie",
"cookie-name=cookie-value; path=/foobar");
@@ -606,7 +606,7 @@ public class TestBrowserCompatSpec exten
} catch (MalformedCookieException expected) {
}
}
-
+
/**
* Tests several date formats.
@@ -697,7 +697,7 @@ public class TestBrowserCompatSpec exten
CookieOrigin origin = new CookieOrigin("www.sourceforge.net", 80, "/", false);
assertTrue(cookiespec.match(cookie, origin));
}
-
+
public void testInvalidSecondDomainLevelCookieMatch1() throws Exception {
BasicClientCookie cookie = new BasicClientCookie("name", null);
cookie.setDomain(".sourceforge.net");
@@ -746,7 +746,7 @@ public class TestBrowserCompatSpec exten
CookieOrigin origin = new CookieOrigin("host", 80, "/", false);
assertTrue(cookiespec.match(cookie, origin));
}
-
+
public void testCookieMatch1() throws Exception {
CookieSpec cookiespec = new BrowserCompatSpec();
BasicClientCookie cookie = new BasicClientCookie("name", "value");
@@ -755,7 +755,7 @@ public class TestBrowserCompatSpec exten
CookieOrigin origin = new CookieOrigin("host", 80, "/", false);
assertTrue(cookiespec.match(cookie, origin));
}
-
+
public void testCookieMatch2() throws Exception {
CookieSpec cookiespec = new BrowserCompatSpec();
BasicClientCookie cookie = new BasicClientCookie("name", "value");
@@ -764,7 +764,7 @@ public class TestBrowserCompatSpec exten
CookieOrigin origin = new CookieOrigin(".whatever.com", 80, "/", false);
assertTrue(cookiespec.match(cookie, origin));
}
-
+
public void testCookieMatch3() throws Exception {
CookieSpec cookiespec = new BrowserCompatSpec();
BasicClientCookie cookie = new BasicClientCookie("name", "value");
@@ -773,7 +773,7 @@ public class TestBrowserCompatSpec exten
CookieOrigin origin = new CookieOrigin(".really.whatever.com", 80, "/", false);
assertTrue(cookiespec.match(cookie, origin));
}
-
+
public void testCookieMatch4() throws Exception {
CookieSpec cookiespec = new BrowserCompatSpec();
BasicClientCookie cookie = new BasicClientCookie("name", "value");
@@ -782,7 +782,7 @@ public class TestBrowserCompatSpec exten
CookieOrigin origin = new CookieOrigin("host", 80, "/foobar", false);
assertTrue(cookiespec.match(cookie, origin));
}
-
+
public void testCookieMismatch1() throws Exception {
CookieSpec cookiespec = new BrowserCompatSpec();
BasicClientCookie cookie = new BasicClientCookie("name", "value");
@@ -791,7 +791,7 @@ public class TestBrowserCompatSpec exten
CookieOrigin origin = new CookieOrigin("host2", 80, "/", false);
assertFalse(cookiespec.match(cookie, origin));
}
-
+
public void testCookieMismatch2() throws Exception {
CookieSpec cookiespec = new BrowserCompatSpec();
BasicClientCookie cookie = new BasicClientCookie("name", "value");
@@ -800,7 +800,7 @@ public class TestBrowserCompatSpec exten
CookieOrigin origin = new CookieOrigin(".bbbbbbbb.com", 80, "/", false);
assertFalse(cookiespec.match(cookie, origin));
}
-
+
public void testCookieMismatch3() throws Exception {
CookieSpec cookiespec = new BrowserCompatSpec();
BasicClientCookie cookie = new BasicClientCookie("name", "value");
@@ -809,7 +809,7 @@ public class TestBrowserCompatSpec exten
CookieOrigin origin = new CookieOrigin("host", 80, "/foo", false);
assertFalse(cookiespec.match(cookie, origin));
}
-
+
public void testCookieMismatch4() throws Exception {
CookieSpec cookiespec = new BrowserCompatSpec();
BasicClientCookie cookie = new BasicClientCookie("name", "value");
@@ -818,7 +818,7 @@ public class TestBrowserCompatSpec exten
CookieOrigin origin = new CookieOrigin("host", 80, "/foobar/", false);
assertTrue(cookiespec.match(cookie, origin));
}
-
+
public void testCookieMatch5() throws Exception {
CookieSpec cookiespec = new BrowserCompatSpec();
BasicClientCookie cookie = new BasicClientCookie("name", "value");
@@ -827,7 +827,7 @@ public class TestBrowserCompatSpec exten
CookieOrigin origin = new CookieOrigin("host", 80, "/foobar/", false);
assertFalse(cookiespec.match(cookie, origin));
}
-
+
public void testCookieMismatch6() throws Exception {
CookieSpec cookiespec = new BrowserCompatSpec();
BasicClientCookie cookie = new BasicClientCookie("name", "value");
@@ -837,16 +837,16 @@ public class TestBrowserCompatSpec exten
CookieOrigin origin = new CookieOrigin("host", 80, "/foobar", false);
assertFalse(cookiespec.match(cookie, origin));
}
-
+
public void testInvalidMatchDomain() throws Exception {
- BasicClientCookie cookie = new BasicClientCookie("name", null);
+ BasicClientCookie cookie = new BasicClientCookie("name", null);
cookie.setDomain("beta.gamma.com");
cookie.setAttribute(ClientCookie.DOMAIN_ATTR, cookie.getDomain());
cookie.setPath("/");
cookie.setAttribute(ClientCookie.PATH_ATTR, cookie.getPath());
CookieSpec cookiespec = new BrowserCompatSpec();
- CookieOrigin origin = new CookieOrigin("alpha.beta.gamma.com", 80, "/", false);
+ CookieOrigin origin = new CookieOrigin("alpha.beta.gamma.com", 80, "/", false);
cookiespec.validate(cookie, origin);
assertTrue(cookiespec.match(cookie, origin));
}
@@ -855,17 +855,17 @@ public class TestBrowserCompatSpec exten
* Tests generic cookie formatting.
*/
public void testGenericCookieFormatting() throws Exception {
- Header header = new BasicHeader("Set-Cookie",
+ Header header = new BasicHeader("Set-Cookie",
"name=value; path=/; domain=.mydomain.com");
CookieSpec cookiespec = new BrowserCompatSpec();
- CookieOrigin origin = new CookieOrigin("myhost.mydomain.com", 80, "/", false);
+ CookieOrigin origin = new CookieOrigin("myhost.mydomain.com", 80, "/", false);
List<Cookie> cookies = cookiespec.parse(header, origin);
cookiespec.validate(cookies.get(0), origin);
List<Header> headers = cookiespec.formatCookies(cookies);
assertNotNull(headers);
assertEquals(1, headers.size());
assertEquals("name=value", headers.get(0).getValue());
- }
+ }
/**
* Tests if null cookie values are handled correctly.
@@ -890,21 +890,21 @@ public class TestBrowserCompatSpec exten
* Tests generic cookie formatting.
*/
public void testFormatSeveralCookies() throws Exception {
- Header header = new BasicHeader("Set-Cookie",
+ Header header = new BasicHeader("Set-Cookie",
"name1=value1; path=/; domain=.mydomain.com, name2 = value2 ; path=/; domain=.mydomain.com");
CookieSpec cookiespec = new BrowserCompatSpec();
- CookieOrigin origin = new CookieOrigin("myhost.mydomain.com", 80, "/", false);
+ CookieOrigin origin = new CookieOrigin("myhost.mydomain.com", 80, "/", false);
List<Cookie> cookies = cookiespec.parse(header, origin);
List<Header> headers = cookiespec.formatCookies(cookies);
assertNotNull(headers);
assertEquals(1, headers.size());
assertEquals("name1=value1; name2=value2", headers.get(0).getValue());
- }
+ }
public void testKeepCloverHappy() throws Exception {
- new MalformedCookieException();
- new MalformedCookieException("whatever");
- new MalformedCookieException("whatever", null);
+ new MalformedCookieException();
+ new MalformedCookieException("whatever");
+ new MalformedCookieException("whatever", null);
}
public void testInvalidInput() throws Exception {
@@ -959,5 +959,5 @@ public class TestBrowserCompatSpec exten
// expected
}
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieBestMatchSpec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieBestMatchSpec.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieBestMatchSpec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieBestMatchSpec.java Fri Apr 23 19:19:23 2010
@@ -46,7 +46,7 @@ import org.apache.http.message.BasicHead
/**
* Test cases for 'best match' cookie policy
*
- *
+ *
*/
public class TestCookieBestMatchSpec extends TestCase {
@@ -80,12 +80,12 @@ public class TestCookieBestMatchSpec ext
CookieSpec cookiespec = new BestMatchSpec();
CookieOrigin origin = new CookieOrigin("myhost.mydomain.com", 80, "/", false);
- Header header = new BasicHeader("Set-Cookie",
+ Header header = new BasicHeader("Set-Cookie",
"name=value; path=/; domain=.mydomain.com; expires=Thu, 01-Jan-2070 00:00:10 GMT; comment=no_comment");
List<Cookie> cookies = cookiespec.parse(header, origin);
cookiespec.validate(cookies.get(0), origin);
-
- header = new BasicHeader("Set-Cookie",
+
+ header = new BasicHeader("Set-Cookie",
"name=value; path=/; domain=.mydomain.com; expires=Thu, 01-Jan-2070 00:00:10 GMT; version=1");
try {
cookies = cookiespec.parse(header, origin);
@@ -189,10 +189,10 @@ public class TestCookieBestMatchSpec ext
assertFalse(cookiespec.match(cookie, origin));
cookie.setDomain(".b.domain.com");
-
+
assertTrue(cookiespec.match(cookie, origin));
}
-
+
public void testCookieBrowserCompatFormatting() throws Exception {
CookieSpec cookiespec = new BestMatchSpec();
@@ -210,18 +210,18 @@ public class TestCookieBestMatchSpec ext
cookie2.setAttribute(ClientCookie.DOMAIN_ATTR, cookie2.getDomain());
cookie2.setPath("/");
cookie2.setAttribute(ClientCookie.PATH_ATTR, cookie2.getPath());
-
+
List<Cookie> cookies = new ArrayList<Cookie>();
cookies.add(cookie1);
cookies.add(cookie2);
-
+
List<Header> headers = cookiespec.formatCookies(cookies);
assertNotNull(headers);
assertEquals(1, headers.size());
-
+
Header header = headers.get(0);
assertEquals("name1=value1; name2=value2", header.getValue());
-
+
}
public void testCookieStandardCompliantFormatting() throws Exception {
@@ -242,20 +242,20 @@ public class TestCookieBestMatchSpec ext
cookie2.setAttribute(ClientCookie.DOMAIN_ATTR, cookie2.getDomain());
cookie2.setPath("/");
cookie2.setAttribute(ClientCookie.PATH_ATTR, cookie2.getPath());
-
+
List<Cookie> cookies = new ArrayList<Cookie>();
cookies.add(cookie1);
cookies.add(cookie2);
-
+
List<Header> headers = cookiespec.formatCookies(cookies);
assertNotNull(headers);
assertEquals(1, headers.size());
-
+
Header header = headers.get(0);
assertEquals("$Version=1; name1=\"value1\"; $Path=\"/\"; $Domain=\".domain.com\"; " +
- "name2=\"value2\"; $Path=\"/\"; $Domain=\".domain.com\"",
+ "name2=\"value2\"; $Path=\"/\"; $Domain=\".domain.com\"",
header.getValue());
-
+
}
public void testInvalidInput() throws Exception {
@@ -286,6 +286,6 @@ public class TestCookieBestMatchSpec ext
// expected
}
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieNetscapeDraft.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieNetscapeDraft.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieNetscapeDraft.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieNetscapeDraft.java Fri Apr 23 19:19:23 2010
@@ -127,7 +127,7 @@ public class TestCookieNetscapeDraft ext
public void testParseWithWrongNetscapeDomain2() throws Exception {
Header header = new BasicHeader("Set-Cookie","cookie-name=cookie-value; domain=.y.z");
-
+
CookieSpec cookiespec = new NetscapeDraftSpec();
try {
CookieOrigin origin = new CookieOrigin("x.y.z", 80, "/", false);
@@ -155,13 +155,13 @@ public class TestCookieNetscapeDraft ext
assertEquals(1, headers.size());
assertEquals("name=value", headers.get(0).getValue());
}
-
+
/**
* Tests Netscape specific expire attribute parsing.
*/
public void testNetscapeCookieExpireAttribute() throws Exception {
CookieSpec cookiespec = new NetscapeDraftSpec();
- Header header = new BasicHeader("Set-Cookie",
+ Header header = new BasicHeader("Set-Cookie",
"name=value; path=/; domain=.mydomain.com; expires=Thu, 01-Jan-2070 00:00:10 GMT; comment=no_comment");
CookieOrigin origin = new CookieOrigin("myhost.mydomain.com", 80, "/", false);
List<Cookie> cookies = cookiespec.parse(header, origin);
@@ -181,7 +181,7 @@ public class TestCookieNetscapeDraft ext
*/
public void testNetscapeCookieExpireAttributeTwoDigitYear() throws Exception {
CookieSpec cookiespec = new NetscapeDraftSpec();
- Header header = new BasicHeader("Set-Cookie",
+ Header header = new BasicHeader("Set-Cookie",
"name=value; path=/; domain=.mydomain.com; expires=Thursday, 01-Jan-70 00:00:10 GMT; comment=no_comment");
CookieOrigin origin = new CookieOrigin("myhost.mydomain.com", 80, "/", false);
List<Cookie> cookies = cookiespec.parse(header, origin);
@@ -202,7 +202,7 @@ public class TestCookieNetscapeDraft ext
public void testNetscapeCookieInvalidExpireAttribute() throws Exception {
CookieSpec cookiespec = new NetscapeDraftSpec();
CookieOrigin origin = new CookieOrigin("myhost.mydomain.com", 80, "/", false);
- Header header = new BasicHeader("Set-Cookie",
+ Header header = new BasicHeader("Set-Cookie",
"name=value; path=/; domain=.mydomain.com; expires=Thu 01-Jan-2070 00:00:10 GMT; comment=no_comment");
try {
List<Cookie> cookies = cookiespec.parse(header, origin);
@@ -218,7 +218,7 @@ public class TestCookieNetscapeDraft ext
*/
public void testNetscapeCookieExpireAttributeNoTimeZone() throws Exception {
CookieSpec cookiespec = new NetscapeDraftSpec();
- Header header = new BasicHeader("Set-Cookie",
+ Header header = new BasicHeader("Set-Cookie",
"name=value; expires=Thu, 01-Jan-2006 00:00:00 ");
CookieOrigin origin = new CookieOrigin("myhost.mydomain.com", 80, "/", false);
try {
@@ -228,7 +228,7 @@ public class TestCookieNetscapeDraft ext
// expected
}
}
-
+
/**
* Tests if cookie values with embedded comma are handled correctly.
*/
@@ -242,7 +242,7 @@ public class TestCookieNetscapeDraft ext
assertEquals("a", cookies.get(0).getName());
assertEquals("b,c", cookies.get(0).getValue());
}
-
+
public void testFormatCookies() throws Exception {
BasicClientCookie c1 = new BasicClientCookie("name1", "value1");
c1.setDomain(".whatever.com");
@@ -252,7 +252,7 @@ public class TestCookieNetscapeDraft ext
Cookie c2 = new BasicClientCookie("name2", "value2");
Cookie c3 = new BasicClientCookie("name3", null);
-
+
CookieSpec cookiespec = new NetscapeDraftSpec();
List<Cookie> cookies = new ArrayList<Cookie>();
cookies.add(c1);
@@ -262,7 +262,7 @@ public class TestCookieNetscapeDraft ext
assertNotNull(headers);
assertEquals(1, headers.size());
assertEquals("name1=value1; name2=value2; name3", headers.get(0).getValue());
- }
+ }
public void testInvalidInput() throws Exception {
CookieSpec cookiespec = new NetscapeDraftSpec();
@@ -292,6 +292,6 @@ public class TestCookieNetscapeDraft ext
// expected
}
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieRFC2109Spec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieRFC2109Spec.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieRFC2109Spec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieRFC2109Spec.java Fri Apr 23 19:19:23 2010
@@ -46,7 +46,7 @@ import org.apache.http.message.BasicHead
/**
* Test cases for RFC2109 cookie spec
*
- *
+ *
*/
public class TestCookieRFC2109Spec extends TestCase {
@@ -68,7 +68,7 @@ public class TestCookieRFC2109Spec exten
new RFC2109Spec(null, false);
new RFC2109Spec(new String[] { DateUtils.PATTERN_RFC1036 }, false);
}
-
+
public void testParseVersion() throws Exception {
Header header = new BasicHeader("Set-Cookie","cookie-name=cookie-value; version=1");
@@ -85,7 +85,7 @@ public class TestCookieRFC2109Spec exten
}
/**
- * Test domain equals host
+ * Test domain equals host
*/
public void testCookiesomainEqualsHost() throws Exception {
Header header = new BasicHeader("Set-Cookie",
@@ -163,7 +163,7 @@ public class TestCookieRFC2109Spec exten
}
/**
- * Tests if that invalid second domain level cookie gets
+ * Tests if that invalid second domain level cookie gets
* rejected in the strict mode, but gets accepted in the
* browser compatibility mode.
*/
@@ -182,7 +182,7 @@ public class TestCookieRFC2109Spec exten
} catch (MalformedCookieException e) {
// Expected
}
- }
+ }
public void testSecondDomainLevelCookieMatch() throws Exception {
BasicClientCookie cookie = new BasicClientCookie("name", null);
@@ -195,7 +195,7 @@ public class TestCookieRFC2109Spec exten
CookieOrigin origin = new CookieOrigin("sourceforge.net", 80, "/", false);
assertFalse(cookiespec.match(cookie, origin));
}
-
+
public void testParseWithWrongPath() throws Exception {
Header header = new BasicHeader("Set-Cookie",
"cookie-name=cookie-value; domain=127.0.0.1; path=/not/just/root");
@@ -251,11 +251,11 @@ public class TestCookieRFC2109Spec exten
/**
* Tests if default cookie validator rejects cookies originating from a host without domain
- * where domain attribute does not match the host of origin
+ * where domain attribute does not match the host of origin
*/
- public void testInvalidDomainWithSimpleHostName() throws Exception {
+ public void testInvalidDomainWithSimpleHostName() throws Exception {
CookieSpec cookiespec = new RFC2109Spec();
- Header header = new BasicHeader("Set-Cookie",
+ Header header = new BasicHeader("Set-Cookie",
"name=\"value\"; version=\"1\"; path=\"/\"; domain=\".mydomain.com\"");
CookieOrigin origin1 = new CookieOrigin("host", 80, "/", false);
List<Cookie> cookies = cookiespec.parse(header, origin1);
@@ -266,7 +266,7 @@ public class TestCookieRFC2109Spec exten
catch(MalformedCookieException expected) {
}
CookieOrigin origin2 = new CookieOrigin("host2", 80, "/", false);
- header = new BasicHeader("Set-Cookie",
+ header = new BasicHeader("Set-Cookie",
"name=\"value\"; version=\"1\"; path=\"/\"; domain=\"host1\"");
cookies = cookiespec.parse(header, origin2);
try {
@@ -298,7 +298,7 @@ public class TestCookieRFC2109Spec exten
*/
public void testRFC2109CookieFormatting() throws Exception {
CookieSpec cookiespec = new RFC2109Spec(null, false);
- Header header = new BasicHeader("Set-Cookie",
+ Header header = new BasicHeader("Set-Cookie",
"name=\"value\"; version=1; path=\"/\"; domain=\".mydomain.com\"");
CookieOrigin origin = new CookieOrigin("myhost.mydomain.com", 80, "/", false);
List<Cookie> cookies = cookiespec.parse(header, origin);
@@ -306,24 +306,24 @@ public class TestCookieRFC2109Spec exten
List<Header> headers = cookiespec.formatCookies(cookies);
assertNotNull(headers);
assertEquals(1, headers.size());
- assertEquals("$Version=1; name=\"value\"; $Path=\"/\"; $Domain=\".mydomain.com\"",
+ assertEquals("$Version=1; name=\"value\"; $Path=\"/\"; $Domain=\".mydomain.com\"",
headers.get(0).getValue());
- header = new BasicHeader( "Set-Cookie",
+ header = new BasicHeader( "Set-Cookie",
"name=value; path=/; domain=.mydomain.com");
cookies = cookiespec.parse(header, origin);
cookiespec.validate(cookies.get(0), origin);
headers = cookiespec.formatCookies(cookies);
assertNotNull(headers);
assertEquals(1, headers.size());
- assertEquals("$Version=0; name=value; $Path=/; $Domain=.mydomain.com",
+ assertEquals("$Version=0; name=value; $Path=/; $Domain=.mydomain.com",
headers.get(0).getValue());
}
public void testRFC2109CookiesFormatting() throws Exception {
CookieSpec cookiespec = new RFC2109Spec(null, true);
- Header header = new BasicHeader("Set-Cookie",
- "name1=value1; path=/; domain=.mydomain.com, " +
+ Header header = new BasicHeader("Set-Cookie",
+ "name1=value1; path=/; domain=.mydomain.com, " +
"name2=\"value2\"; version=\"1\"; path=\"/\"; domain=\".mydomain.com\"");
CookieOrigin origin = new CookieOrigin("myhost.mydomain.com", 80, "/", false);
List<Cookie> cookies = cookiespec.parse(header, origin);
@@ -335,13 +335,13 @@ public class TestCookieRFC2109Spec exten
List<Header> headers = cookiespec.formatCookies(cookies);
assertNotNull(headers);
assertEquals(1, headers.size());
- assertEquals(
- "$Version=0; name1=value1; $Path=/; $Domain=.mydomain.com; " +
+ assertEquals(
+ "$Version=0; name1=value1; $Path=/; $Domain=.mydomain.com; " +
"name2=value2; $Path=/; $Domain=.mydomain.com",
headers.get(0).getValue());
- header = new BasicHeader("Set-Cookie",
- "name1=value1; version=1; path=/; domain=.mydomain.com, " +
+ header = new BasicHeader("Set-Cookie",
+ "name1=value1; version=1; path=/; domain=.mydomain.com, " +
"name2=\"value2\"; version=\"1\"; path=\"/\"; domain=\".mydomain.com\"");
cookies = cookiespec.parse(header, origin);
for (int i = 0; i < cookies.size(); i++) {
@@ -350,12 +350,12 @@ public class TestCookieRFC2109Spec exten
assertNotNull(cookies);
assertEquals(2, cookies.size());
headers = cookiespec.formatCookies(cookies);
- assertEquals(
- "$Version=1; name1=\"value1\"; $Path=\"/\"; $Domain=\".mydomain.com\"; " +
+ assertEquals(
+ "$Version=1; name1=\"value1\"; $Path=\"/\"; $Domain=\".mydomain.com\"; " +
"name2=\"value2\"; $Path=\"/\"; $Domain=\".mydomain.com\"",
headers.get(0).getValue());
}
-
+
/**
* Tests if null cookie values are handled correctly.
*/
@@ -372,7 +372,7 @@ public class TestCookieRFC2109Spec exten
List<Header> headers = cookiespec.formatCookies(cookies);
assertNotNull(headers);
assertEquals(1, headers.size());
- assertEquals("$Version=0; name=; $Path=/; $Domain=.whatever.com",
+ assertEquals("$Version=0; name=; $Path=/; $Domain=.whatever.com",
headers.get(0).getValue());
cookie.setVersion(1);
@@ -381,12 +381,12 @@ public class TestCookieRFC2109Spec exten
headers = cookiespec.formatCookies(cookies);
assertNotNull(headers);
assertEquals(1, headers.size());
- assertEquals("$Version=1; name=; $Path=\"/\"; $Domain=\".whatever.com\"",
+ assertEquals("$Version=1; name=; $Path=\"/\"; $Domain=\".whatever.com\"",
headers.get(0).getValue());
}
public void testCookieNullDomainNullPathFormatting() {
- BasicClientCookie cookie = new BasicClientCookie("name", null);
+ BasicClientCookie cookie = new BasicClientCookie("name", null);
cookie.setPath("/");
cookie.setAttribute(ClientCookie.PATH_ATTR, cookie.getPath());
@@ -471,5 +471,5 @@ public class TestCookieRFC2109Spec exten
// expected
}
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieRFC2965Spec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieRFC2965Spec.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieRFC2965Spec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieRFC2965Spec.java Fri Apr 23 19:19:23 2010
@@ -114,7 +114,7 @@ public class TestCookieRFC2965Spec exten
assertEquals("/", cookie.getPath());
assertTrue(cookie.containsAttribute(ClientCookie.PATH_ATTR));
}
-
+
/**
* Test parsing cookie <tt>"Domain"</tt> attribute.
*/
@@ -308,7 +308,7 @@ public class TestCookieRFC2965Spec exten
// expected
}
}
-
+
public void testParseNegativeVersion() throws Exception {
CookieSpec cookiespec = new RFC2965Spec();
CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
@@ -790,7 +790,7 @@ public class TestCookieRFC2965Spec exten
cookie.setDomain(".domain.com");
cookie.setPath("/");
cookie.setPorts(null);
-
+
CookieSpec cookiespec = new RFC2965Spec();
CookieOrigin origin1 = new CookieOrigin("www.domain.com", 8080 /* request port */, "/", false);
assertTrue(cookiespec.match(cookie, origin1));
@@ -871,7 +871,7 @@ public class TestCookieRFC2965Spec exten
cookie1.setAttribute(ClientCookie.DOMAIN_ATTR, ".domain.com");
cookie1.setAttribute(ClientCookie.PATH_ATTR, "/");
cookie1.setAttribute(ClientCookie.PORT_ATTR, "80,8080");
-
+
List<Cookie> cookies = new ArrayList<Cookie>();
cookies.add(cookie1);
List<Header> headers = cookiespec.formatCookies(cookies);
@@ -880,7 +880,7 @@ public class TestCookieRFC2965Spec exten
assertEquals("$Version=1; name1=\"value\"; $Path=\"/\"; $Domain=\".domain.com\"; $Port=\"80,8080\"",
headers.get(0).getValue());
-
+
BasicClientCookie2 cookie2 = new BasicClientCookie2("name2", "value");
cookie2.setDomain(".domain.com");
cookie2.setPath("/a/");
@@ -889,7 +889,7 @@ public class TestCookieRFC2965Spec exten
// domain, path specified but port unspecified
cookie2.setAttribute(ClientCookie.DOMAIN_ATTR, ".domain.com");
cookie2.setAttribute(ClientCookie.PATH_ATTR, "/a/");
-
+
cookies = new ArrayList<Cookie>();
cookies.add(cookie2);
headers = cookiespec.formatCookies(cookies);
@@ -943,7 +943,7 @@ public class TestCookieRFC2965Spec exten
cookie1.setAttribute(ClientCookie.DOMAIN_ATTR, ".domain.com");
cookie1.setAttribute(ClientCookie.PATH_ATTR, "/");
cookie1.setAttribute(ClientCookie.PORT_ATTR, "80,8080");
-
+
BasicClientCookie2 cookie2 = new BasicClientCookie2("name2", "");
cookie2.setDomain(".domain.com");
cookie2.setPath("/");
@@ -952,16 +952,16 @@ public class TestCookieRFC2965Spec exten
// value null, domain, path specified
cookie2.setAttribute(ClientCookie.DOMAIN_ATTR, ".domain.com");
cookie2.setAttribute(ClientCookie.PATH_ATTR, "/");
-
+
List<Cookie> cookies = new ArrayList<Cookie>();
cookies.add(cookie1);
cookies.add(cookie2);
List<Header> headers = cookiespec.formatCookies(cookies);
assertNotNull(headers);
assertEquals(1, headers.size());
-
+
assertEquals("$Version=1; name1=\"value1\"; $Path=\"/\"; $Domain=\".domain.com\"; $Port=\"80,8080\"; " +
- "name2=\"\"; $Path=\"/\"; $Domain=\".domain.com\"",
+ "name2=\"\"; $Path=\"/\"; $Domain=\".domain.com\"",
headers.get(0).getValue());
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestDateUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestDateUtils.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestDateUtils.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestDateUtils.java Fri Apr 23 19:19:23 2010
@@ -58,8 +58,8 @@ public class TestDateUtils extends TestC
calendar.setTimeZone(DateUtils.GMT);
calendar.set(2005, Calendar.OCTOBER, 14, 0, 0, 0);
calendar.set(Calendar.MILLISECOND, 0);
- Date date1 = calendar.getTime();
-
+ Date date1 = calendar.getTime();
+
String[] formats = new String[] {
DateUtils.PATTERN_RFC1123
};
@@ -97,14 +97,14 @@ public class TestDateUtils extends TestC
// expected
}
}
-
+
public void testTwoDigitYearDateParse() throws Exception {
Calendar calendar = Calendar.getInstance();
calendar.setTimeZone(DateUtils.GMT);
calendar.set(2005, Calendar.OCTOBER, 14, 0, 0, 0);
calendar.set(Calendar.MILLISECOND, 0);
- Date date1 = calendar.getTime();
-
+ Date date1 = calendar.getTime();
+
String[] formats = new String[] {
DateUtils.PATTERN_RFC1036
};
@@ -113,12 +113,12 @@ public class TestDateUtils extends TestC
calendar.set(1900, Calendar.JANUARY, 0, 0, 0, 0);
calendar.set(Calendar.MILLISECOND, 0);
- Date startDate = calendar.getTime();
+ Date startDate = calendar.getTime();
calendar.set(1905, Calendar.OCTOBER, 14, 0, 0, 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);
assertEquals(date1, date2);
}
@@ -128,8 +128,8 @@ public class TestDateUtils extends TestC
calendar.setTimeZone(DateUtils.GMT);
calendar.set(2005, Calendar.OCTOBER, 14, 0, 0, 0);
calendar.set(Calendar.MILLISECOND, 0);
- Date date1 = calendar.getTime();
-
+ Date date1 = calendar.getTime();
+
String[] formats = new String[] {
DateUtils.PATTERN_RFC1123
};
@@ -142,8 +142,8 @@ public class TestDateUtils extends TestC
calendar.setTimeZone(DateUtils.GMT);
calendar.set(2005, Calendar.OCTOBER, 14, 0, 0, 0);
calendar.set(Calendar.MILLISECOND, 0);
- Date date = calendar.getTime();
-
+ Date date = calendar.getTime();
+
assertEquals("Fri, 14 Oct 2005 00:00:00 GMT", DateUtils.formatDate(date));
assertEquals("Fri, 14 Oct 2005 00:00:00 GMT", DateUtils.formatDate(date, DateUtils.PATTERN_RFC1123));
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestNetscapeCookieAttribHandlers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestNetscapeCookieAttribHandlers.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestNetscapeCookieAttribHandlers.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestNetscapeCookieAttribHandlers.java Fri Apr 23 19:19:23 2010
@@ -52,10 +52,10 @@ public class TestNetscapeCookieAttribHan
}
public void testNetscapeDomainValidate1() throws Exception {
- BasicClientCookie cookie = new BasicClientCookie("name", "value");
- CookieOrigin origin = new CookieOrigin("somehost", 80, "/", false);
+ BasicClientCookie cookie = new BasicClientCookie("name", "value");
+ CookieOrigin origin = new CookieOrigin("somehost", 80, "/", false);
CookieAttributeHandler h = new NetscapeDomainHandler();
-
+
cookie.setDomain("somehost");
h.validate(cookie, origin);
@@ -69,10 +69,10 @@ public class TestNetscapeCookieAttribHan
}
public void testNetscapeDomainValidate2() throws Exception {
- BasicClientCookie cookie = new BasicClientCookie("name", "value");
- CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false);
+ BasicClientCookie cookie = new BasicClientCookie("name", "value");
+ CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false);
CookieAttributeHandler h = new NetscapeDomainHandler();
-
+
cookie.setDomain(".somedomain.com");
h.validate(cookie, origin);
@@ -93,10 +93,10 @@ public class TestNetscapeCookieAttribHan
}
public void testNetscapeDomainValidate3() throws Exception {
- BasicClientCookie cookie = new BasicClientCookie("name", "value");
- CookieOrigin origin = new CookieOrigin("www.a.com", 80, "/", false);
+ BasicClientCookie cookie = new BasicClientCookie("name", "value");
+ CookieOrigin origin = new CookieOrigin("www.a.com", 80, "/", false);
CookieAttributeHandler h = new NetscapeDomainHandler();
-
+
cookie.setDomain(".a.com");
h.validate(cookie, origin);
@@ -110,10 +110,10 @@ public class TestNetscapeCookieAttribHan
}
public void testNetscapeDomainValidate4() throws Exception {
- BasicClientCookie cookie = new BasicClientCookie("name", "value");
- CookieOrigin origin = new CookieOrigin("www.a.b.c", 80, "/", false);
+ BasicClientCookie cookie = new BasicClientCookie("name", "value");
+ CookieOrigin origin = new CookieOrigin("www.a.b.c", 80, "/", false);
CookieAttributeHandler h = new NetscapeDomainHandler();
-
+
cookie.setDomain(".a.b.c");
h.validate(cookie, origin);
@@ -125,22 +125,22 @@ public class TestNetscapeCookieAttribHan
// expected
}
}
-
+
public void testNetscapeDomainMatch1() throws Exception {
- BasicClientCookie cookie = new BasicClientCookie("name", "value");
- CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false);
+ BasicClientCookie cookie = new BasicClientCookie("name", "value");
+ CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false);
CookieAttributeHandler h = new NetscapeDomainHandler();
cookie.setDomain(null);
assertFalse(h.match(cookie, origin));
-
+
cookie.setDomain(".somedomain.com");
assertTrue(h.match(cookie, origin));
}
public void testNetscapeDomainMatch2() throws Exception {
- BasicClientCookie cookie = new BasicClientCookie("name", "value");
- CookieOrigin origin = new CookieOrigin("www.whatever.somedomain.com", 80, "/", false);
+ BasicClientCookie cookie = new BasicClientCookie("name", "value");
+ CookieOrigin origin = new CookieOrigin("www.whatever.somedomain.com", 80, "/", false);
CookieAttributeHandler h = new NetscapeDomainHandler();
cookie.setDomain(".somedomain.com");
@@ -162,5 +162,5 @@ public class TestNetscapeCookieAttribHan
// expected
}
}
-
+
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestNetscapeDraftHeaderParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestNetscapeDraftHeaderParser.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestNetscapeDraftHeaderParser.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestNetscapeDraftHeaderParser.java Fri Apr 23 19:19:23 2010
@@ -57,13 +57,13 @@ public class TestNetscapeDraftHeaderPars
public void testNetscapeCookieParsing() throws Exception {
NetscapeDraftHeaderParser parser = NetscapeDraftHeaderParser.DEFAULT;
-
- String s =
+
+ String s =
"name = value; test; test1 = stuff,with,commas ; test2 = \"stuff; stuff\"; test3=\"stuff";
CharArrayBuffer buffer = new CharArrayBuffer(16);
buffer.append(s);
ParserCursor cursor = new ParserCursor(0, s.length());
-
+
HeaderElement he = parser.parseHeader(buffer, cursor);
assertEquals("name", he.getName());
assertEquals("value", he.getValue());
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestPublicSuffixListParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestPublicSuffixListParser.java?rev=937479&r1=937478&r2=937479&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestPublicSuffixListParser.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestPublicSuffixListParser.java Fri Apr 23 19:19:23 2010
@@ -44,7 +44,7 @@ import org.apache.http.cookie.CookieOrig
public class TestPublicSuffixListParser extends TestCase {
private static final String LIST_FILE = "/suffixlist.txt";
private PublicSuffixFilter filter;
-
+
public TestPublicSuffixListParser(String testName) {
super(testName);
try {
@@ -54,7 +54,7 @@ public class TestPublicSuffixListParser
parser.parse(r);
} catch (IOException e) {
throw new RuntimeException(e.getMessage(), e);
- }
+ }
}
public static Test suite() {
@@ -64,50 +64,50 @@ public class TestPublicSuffixListParser
public static void main(String args[]) {
String[] testCaseName = { TestPublicSuffixListParser.class.getName() };
junit.textui.TestRunner.main(testCaseName);
- }
-
+ }
+
public void testParse() throws Exception {
BasicClientCookie cookie = new BasicClientCookie("name", "value");
-
+
cookie.setDomain(".jp");
assertFalse(filter.match(cookie, new CookieOrigin("apache.jp", 80, "/stuff", false)));
-
+
cookie.setDomain(".ac.jp");
assertFalse(filter.match(cookie, new CookieOrigin("apache.ac.jp", 80, "/stuff", false)));
-
+
cookie.setDomain(".any.tokyo.jp");
assertFalse(filter.match(cookie, new CookieOrigin("apache.any.tokyo.jp", 80, "/stuff", false)));
-
+
// exception
cookie.setDomain(".metro.tokyo.jp");
assertTrue(filter.match(cookie, new CookieOrigin("apache.metro.tokyo.jp", 80, "/stuff", false)));
}
-
+
public void testUnicode() throws Exception {
BasicClientCookie cookie = new BasicClientCookie("name", "value");
-
+
cookie.setDomain(".h\u00E5.no"); // \u00E5 is <aring>
assertFalse(filter.match(cookie, new CookieOrigin("apache.h\u00E5.no", 80, "/stuff", false)));
-
+
cookie.setDomain(".xn--h-2fa.no");
assertFalse(filter.match(cookie, new CookieOrigin("apache.xn--h-2fa.no", 80, "/stuff", false)));
-
+
cookie.setDomain(".h\u00E5.no");
assertFalse(filter.match(cookie, new CookieOrigin("apache.xn--h-2fa.no", 80, "/stuff", false)));
-
+
cookie.setDomain(".xn--h-2fa.no");
assertFalse(filter.match(cookie, new CookieOrigin("apache.h\u00E5.no", 80, "/stuff", false)));
}
-
+
public void testWhitespace() throws Exception {
BasicClientCookie cookie = new BasicClientCookie("name", "value");
cookie.setDomain(".xx");
assertFalse(filter.match(cookie, new CookieOrigin("apache.xx", 80, "/stuff", false)));
-
+
// yy appears after whitespace
cookie.setDomain(".yy");
assertTrue(filter.match(cookie, new CookieOrigin("apache.yy", 80, "/stuff", false)));
-
+
// zz is commented
cookie.setDomain(".zz");
assertTrue(filter.match(cookie, new CookieOrigin("apache.zz", 80, "/stuff", false)));