use of java.net.CookieStore in project robovm by robovm.
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 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.CookieStore in project j2objc by google.
the class CookiesTest method testCookieStoreAddAcceptsConflictingUri.
public void testCookieStoreAddAcceptsConflictingUri() throws URISyntaxException {
CookieStore cookieStore = new CookieManager().getCookieStore();
HttpCookie cookieA = createCookie("a", "android", ".android.com", "/source/");
cookieStore.add(new URI("http://google.com/source/"), cookieA);
assertEquals(Arrays.asList(cookieA), cookieStore.getCookies());
}
use of java.net.CookieStore in project j2objc by google.
the class CookiesTest method testCookieStoreUriDropsPort.
public void testCookieStoreUriDropsPort() throws URISyntaxException {
CookieStore cookieStore = new CookieManager().getCookieStore();
cookieStore.add(new URI("http://a.com:443/"), 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 testCookieStoreNullUris.
public void testCookieStoreNullUris() {
CookieStore cookieStore = new CookieManager().getCookieStore();
HttpCookie cookieA = createCookie("a", "android", ".android.com", "/source");
HttpCookie cookieB = createCookie("b", "banana", "code.google.com", "/p/android");
try {
cookieStore.add(null, cookieA);
} catch (NullPointerException expected) {
// the RI crashes even though the cookie does get added to the store; sigh
expected.printStackTrace();
}
assertEquals(Arrays.asList(cookieA), cookieStore.getCookies());
try {
cookieStore.add(null, cookieB);
} catch (NullPointerException expected) {
}
assertEquals(Arrays.asList(cookieA, cookieB), cookieStore.getCookies());
try {
cookieStore.get(null);
fail();
} catch (NullPointerException expected) {
}
assertEquals(Collections.<URI>emptyList(), cookieStore.getURIs());
assertTrue(cookieStore.remove(null, cookieA));
assertEquals(Arrays.asList(cookieB), cookieStore.getCookies());
assertTrue(cookieStore.removeAll());
assertEquals(Collections.<URI>emptyList(), cookieStore.getURIs());
assertEquals(Collections.<HttpCookie>emptyList(), cookieStore.getCookies());
}
Aggregations