use of java.net.CookieManager in project j2objc by google.
the class CookiesTest method testCookieStoreUriDropsUserInfo.
public void testCookieStoreUriDropsUserInfo() throws URISyntaxException {
CookieStore cookieStore = new CookieManager().getCookieStore();
cookieStore.add(new URI("http://jesse:secret@a.com/"), new HttpCookie("a", "android"));
assertEquals(Arrays.asList(new URI("http://a.com")), cookieStore.getURIs());
}
use of java.net.CookieManager in project j2objc by google.
the class CookiesTest method testNonMatchingDomainsRejected.
public void testNonMatchingDomainsRejected() throws Exception {
TestCookieStore cookieStore = new TestCookieStore();
CookieManager cookieManager = new CookieManager(cookieStore, ACCEPT_ORIGINAL_SERVER);
cookieManager.put(new URI("http://android.com/"), cookieHeaders("a=android;domain=google.com"));
assertEquals(Collections.<HttpCookie>emptyList(), cookieStore.cookies);
}
use of java.net.CookieManager in project j2objc by google.
the class CookiesTest method testCookieStoreUriDropsPath.
public void testCookieStoreUriDropsPath() throws URISyntaxException {
CookieStore cookieStore = new CookieManager().getCookieStore();
cookieStore.add(new URI("http://a.com/a/"), new HttpCookie("a", "android"));
assertEquals(Arrays.asList(new URI("http://a.com")), cookieStore.getURIs());
}
use of java.net.CookieManager in project j2objc by google.
the class CookiesTest method testCookieStoreRemoveAll.
public void testCookieStoreRemoveAll() throws URISyntaxException {
CookieStore cookieStore = new CookieManager().getCookieStore();
cookieStore.add(new URI("http://code.google.com/"), new HttpCookie("a", "android"));
assertTrue(cookieStore.removeAll());
assertEquals(Collections.<URI>emptyList(), cookieStore.getURIs());
assertEquals(Collections.<HttpCookie>emptyList(), cookieStore.getCookies());
assertFalse("Expected removeAll() to return false when the call doesn't mutate the store", // RI6 fails this
cookieStore.removeAll());
}
use of java.net.CookieManager in project j2objc by google.
the class CookiesTest method testRfc2965Response.
public void testRfc2965Response() throws Exception {
CookieManager cookieManager = new CookieManager(null, ACCEPT_ORIGINAL_SERVER);
CookieHandler.setDefault(cookieManager);
MockWebServer server = new MockWebServer();
server.play();
server.enqueue(new MockResponse().addHeader("Set-Cookie2: a=android; " + "Comment=this cookie is delicious; " + "CommentURL=http://google.com/; " + "Discard; " + "Domain=" + server.getCookieDomain() + "; " + "Max-Age=60; " + "Path=/path; " + "Port=\"80,443," + server.getPort() + "\"; " + "Secure; " + "Version=1"));
get(server, "/path/foo");
List<HttpCookie> cookies = cookieManager.getCookieStore().getCookies();
assertEquals(1, cookies.size());
HttpCookie cookie = cookies.get(0);
assertEquals("a", cookie.getName());
assertEquals("android", cookie.getValue());
assertEquals("this cookie is delicious", cookie.getComment());
assertEquals("http://google.com/", cookie.getCommentURL());
assertEquals(true, cookie.getDiscard());
assertEquals(server.getCookieDomain(), cookie.getDomain());
assertEquals(60, cookie.getMaxAge());
assertEquals("/path", cookie.getPath());
assertEquals("80,443," + server.getPort(), cookie.getPortlist());
assertEquals(true, cookie.getSecure());
assertEquals(1, cookie.getVersion());
}
Aggregations