use of java.net.CookieManager in project j2objc by google.
the class CookiesTest method testCookieManagerGet_portChecks.
public void testCookieManagerGet_portChecks() throws Exception {
CookieManager cookieManager = new CookieManager();
cookieManager.put(new URI("http://a.com:443/"), cookieHeaders("a1=android"));
cookieManager.put(new URI("http://a.com:8080/"), cookieHeaders("a2=android"));
cookieManager.put(new URI("http://a.com:8080/"), cookieHeaders("a3=android; Port=8080"));
assertManagerCookiesMatch(cookieManager, "http://a.com/", "a1=android; a2=android");
assertManagerCookiesMatch(cookieManager, "http://a.com:8080/", "a1=android; a2=android; a3=android");
}
use of java.net.CookieManager in project j2objc by google.
the class CookiesTest method testQuotedAttributeValues.
public void testQuotedAttributeValues() 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());
}
use of java.net.CookieManager in project j2objc by google.
the class CookiesTest method testDomainDefaulting.
public void testDomainDefaulting() throws Exception {
TestCookieStore cookieStore = new TestCookieStore();
CookieManager cookieManager = new CookieManager(cookieStore, ACCEPT_ORIGINAL_SERVER);
cookieManager.put(new URI("http://android.com/"), cookieHeaders("a=android"));
assertEquals("android.com", cookieStore.getCookie("a").getDomain());
}
use of java.net.CookieManager in project j2objc by google.
the class CookiesTest method testCookieStoreUriKeepsHost.
public void testCookieStoreUriKeepsHost() throws URISyntaxException {
CookieStore cookieStore = new CookieManager().getCookieStore();
cookieStore.add(new URI("http://b.com/"), new HttpCookie("a", "android"));
assertEquals(Arrays.asList(new URI("http://b.com")), cookieStore.getURIs());
}
use of java.net.CookieManager in project j2objc by google.
the class CookiesTest method testCookieManagerGet_pathChecks.
public void testCookieManagerGet_pathChecks() throws Exception {
CookieManager cookieManager = new CookieManager();
cookieManager.put(new URI("http://a.com/"), cookieHeaders("a1=android"));
cookieManager.put(new URI("http://a.com/path1"), cookieHeaders("a2=android; Path=\"/path1\""));
cookieManager.put(new URI("http://a.com/path2"), cookieHeaders("a3=android; Path=\"/path2\""));
assertManagerCookiesMatch(cookieManager, "http://a.com/notpath", "a1=android");
assertManagerCookiesMatch(cookieManager, "http://a.com/path1", "a1=android; a2=android");
}
Aggregations