Search in sources :

Example 31 with CookieStore

use of java.net.CookieStore in project robovm by robovm.

the class CookiesTest method testCookieStoreUriDropsFragment.

public void testCookieStoreUriDropsFragment() throws URISyntaxException {
    CookieStore cookieStore = new CookieManager().getCookieStore();
    cookieStore.add(new URI("http://a.com/a/foo#fragment"), new HttpCookie("a", "android"));
    assertEquals(Arrays.asList(new URI("http://a.com")), cookieStore.getURIs());
}
Also used : CookieStore(java.net.CookieStore) URI(java.net.URI) HttpCookie(java.net.HttpCookie) CookieManager(java.net.CookieManager)

Example 32 with CookieStore

use of java.net.CookieStore in project robovm by robovm.

the class CookiesTest method testCookieStoreNullUris.

public void testCookieStoreNullUris() {
    CookieStore cookieStore = new CookieManager().getCookieStore();
    HttpCookie cookieA = new HttpCookie("a", "android");
    cookieA.setDomain(".android.com");
    cookieA.setPath("/source");
    HttpCookie cookieB = new HttpCookie("b", "banana");
    cookieA.setDomain("code.google.com");
    cookieA.setPath("/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());
}
Also used : CookieStore(java.net.CookieStore) HttpCookie(java.net.HttpCookie) CookieManager(java.net.CookieManager)

Example 33 with CookieStore

use of java.net.CookieStore in project robovm by robovm.

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());
}
Also used : CookieStore(java.net.CookieStore) URI(java.net.URI) HttpCookie(java.net.HttpCookie) CookieManager(java.net.CookieManager)

Example 34 with CookieStore

use of java.net.CookieStore in project robovm by robovm.

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());
}
Also used : CookieStore(java.net.CookieStore) URI(java.net.URI) HttpCookie(java.net.HttpCookie) CookieManager(java.net.CookieManager)

Example 35 with CookieStore

use of java.net.CookieStore in project robovm by robovm.

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());
}
Also used : CookieStore(java.net.CookieStore) URI(java.net.URI) HttpCookie(java.net.HttpCookie) CookieManager(java.net.CookieManager)

Aggregations

CookieStore (java.net.CookieStore)37 HttpCookie (java.net.HttpCookie)33 CookieManager (java.net.CookieManager)28 URI (java.net.URI)26 RefTag (com.kickstarter.libs.RefTag)2 Project (com.kickstarter.models.Project)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 Nullable (android.support.annotation.Nullable)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 Serializable (java.io.Serializable)1 URISyntaxException (java.net.URISyntaxException)1 Map (java.util.Map)1 NewCookie (javax.ws.rs.core.NewCookie)1 Message (org.apache.camel.Message)1 RuntimeCamelException (org.apache.camel.RuntimeCamelException)1 HeaderFilterStrategy (org.apache.camel.spi.HeaderFilterStrategy)1 ContentProvider (org.eclipse.jetty.client.api.ContentProvider)1 HttpFields (org.eclipse.jetty.http.HttpFields)1