use of java.net.CookieManager in project robovm by robovm.
the class CookiesTest method testNoCookieHeaderSentIfNoCookiesMatch.
public void testNoCookieHeaderSentIfNoCookiesMatch() throws IOException, URISyntaxException {
CookieManager cookieManager = new CookieManager(null, ACCEPT_ORIGINAL_SERVER);
Map<String, List<String>> cookieHeaders = cookieManager.get(new URI("http://android.com/foo/bar/"), EMPTY_COOKIES_MAP);
assertTrue(cookieHeaders.toString(), cookieHeaders.isEmpty() || (cookieHeaders.size() == 1 && cookieHeaders.get("Cookie").isEmpty()));
}
use of java.net.CookieManager in project robovm by robovm.
the class CookiesTest method testNonMatchingPathsRejected.
public void testNonMatchingPathsRejected() throws Exception {
TestCookieStore cookieStore = new TestCookieStore();
CookieManager cookieManager = new CookieManager(cookieStore, ACCEPT_ORIGINAL_SERVER);
cookieManager.put(new URI("http://android.com/foo/bar"), cookieHeaders("a=android;path=/baz/bar"));
assertEquals("Expected to reject cookies whose path is not a prefix of the request path", Collections.<HttpCookie>emptyList(), // RI6 fails this
cookieStore.cookies);
}
use of java.net.CookieManager in project robovm by robovm.
the class CookiesTest method testMatchingPathsAccepted.
public void testMatchingPathsAccepted() throws Exception {
TestCookieStore cookieStore = new TestCookieStore();
CookieManager cookieManager = new CookieManager(cookieStore, ACCEPT_ORIGINAL_SERVER);
cookieManager.put(new URI("http://android.com/foo/bar/"), cookieHeaders("a=android;path=/foo"));
assertEquals("/foo", cookieStore.getCookie("a").getPath());
}
use of java.net.CookieManager in project robovm by robovm.
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 robovm by robovm.
the class CookiesTest method testResponseWithMultipleCookieHeaderLines.
public void testResponseWithMultipleCookieHeaderLines() throws Exception {
TestCookieStore cookieStore = new TestCookieStore();
CookieManager cookieManager = new CookieManager(cookieStore, ACCEPT_ORIGINAL_SERVER);
cookieManager.put(new URI("http://android.com"), cookieHeaders("a=android", "b=banana"));
List<HttpCookie> cookies = sortedCopy(cookieStore.cookies);
assertEquals(2, cookies.size());
HttpCookie cookieA = cookies.get(0);
assertEquals("a", cookieA.getName());
assertEquals("android", cookieA.getValue());
HttpCookie cookieB = cookies.get(1);
assertEquals("b", cookieB.getName());
assertEquals("banana", cookieB.getValue());
}
Aggregations