summaryrefslogtreecommitdiffstats
path: root/harmony-tests/src
diff options
context:
space:
mode:
authorNeil Fuller <nfuller@google.com>2014-03-10 09:21:49 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-03-10 09:21:51 +0000
commit883084f7eac26f1fdd79858c8bd2e68600011b0b (patch)
treee34082471e4cf5763ee04fcccf4b4f3091b8ea13 /harmony-tests/src
parente73215161ba2089ebc8ff22bfaf07b1585705915 (diff)
parent3bb69fa0b8fe5119c3f19cd7f5d725118aa506af (diff)
downloadlibcore-883084f7eac26f1fdd79858c8bd2e68600011b0b.zip
libcore-883084f7eac26f1fdd79858c8bd2e68600011b0b.tar.gz
libcore-883084f7eac26f1fdd79858c8bd2e68600011b0b.tar.bz2
Merge "Add 1.7 methods to HttpCookie."
Diffstat (limited to 'harmony-tests/src')
-rw-r--r--harmony-tests/src/test/java/org/apache/harmony/tests/java/net/HttpCookieTest.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/net/HttpCookieTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/net/HttpCookieTest.java
index 172ef8e..faf0f2a 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/net/HttpCookieTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/net/HttpCookieTest.java
@@ -234,6 +234,16 @@ public class HttpCookieTest extends TestCase {
assertFalse(cookie.getSecure());
}
+ public void test_Is_SetHttpOnly() {
+ HttpCookie cookie = new HttpCookie("testName", "value");
+ assertFalse(cookie.isHttpOnly());
+
+ cookie.setHttpOnly(true);
+ assertTrue(cookie.isHttpOnly());
+ cookie.setHttpOnly(false);
+ assertFalse(cookie.isHttpOnly());
+ }
+
/**
* java.net.HttpCookie#getPath(), setPath(String)
* @since 1.6
@@ -795,6 +805,32 @@ public class HttpCookieTest extends TestCase {
}
}
+ public void test_Parse_httpOnly() {
+ // Default is !httpOnly.
+ List<HttpCookie> list = HttpCookie.parse("Set-Cookie: SID=31d4d96e407aad42");
+ HttpCookie cookie = list.get(0);
+ assertFalse(cookie.isHttpOnly());
+
+ // Well formed, simple.
+ list = HttpCookie.parse("Set-Cookie: SID=31d4d96e407aad42; HttpOnly");
+ cookie = list.get(0);
+ assertTrue(cookie.isHttpOnly());
+
+ // Well formed, other attributes present.
+ list = HttpCookie.parse("Set-Cookie: SID=31d4d96e407aad42; Path=/; Secure; HttpOnly");
+ cookie = list.get(0);
+ assertTrue(cookie.isHttpOnly());
+ assertTrue(cookie.getSecure());
+ assertEquals("/", cookie.getPath());
+
+ // Mangled spacing, casing and attributes that have an (ignored) value.
+ list = HttpCookie.parse("Set-Cookie:SID=31d4d96e407aad42;Path=/;secure=false;httponly=false");
+ cookie = list.get(0);
+ assertTrue(cookie.isHttpOnly());
+ assertTrue(cookie.getSecure());
+ assertEquals("/", cookie.getPath());
+ }
+
/**
* java.net.HttpCookie#parse(String) for version conflict cases
* @since 1.6