use of java.net.CookieStore in project jdk8u_jdk by JetBrains.
the class NullUriCookieTest method checkCookieNullUri.
static void checkCookieNullUri() throws Exception {
//get a cookie store implementation and add a cookie to the store with null URI
CookieStore cookieStore = (new CookieManager()).getCookieStore();
//Check if removeAll() retrurns false on an empty CookieStore
if (cookieStore.removeAll()) {
fail = true;
}
checkFail("removeAll on empty store should return false");
HttpCookie cookie = new HttpCookie("MY_COOKIE", "MY_COOKIE_VALUE");
cookie.setDomain("foo.com");
cookieStore.add(null, cookie);
//Retrieve added cookie
URI uri = new URI("http://foo.com");
List<HttpCookie> addedCookieList = cookieStore.get(uri);
//Verify CookieStore behaves well
if (addedCookieList.size() != 1) {
fail = true;
}
checkFail("Abnormal size of cookie jar");
for (HttpCookie chip : addedCookieList) {
if (!chip.equals(cookie)) {
fail = true;
}
}
checkFail("Cookie not retrieved from Cookie Jar");
boolean ret = cookieStore.remove(null, cookie);
if (!ret) {
fail = true;
}
checkFail("Abnormal removal behaviour from Cookie Jar");
}
use of java.net.CookieStore 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.CookieStore 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.CookieStore 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.CookieStore in project j2objc by google.
the class CookiesTest method testCookieStoreUriDropsQuery.
public void testCookieStoreUriDropsQuery() throws URISyntaxException {
CookieStore cookieStore = new CookieManager().getCookieStore();
cookieStore.add(new URI("http://a.com/a/foo?query=value"), new HttpCookie("a", "android"));
assertEquals(Arrays.asList(new URI("http://a.com")), cookieStore.getURIs());
}
Aggregations