Search in sources :

Example 6 with CookieStore

use of java.net.CookieStore in project android-oss by kickstarter.

the class RefTagUtilsTest method testStoredCookieRefTagForProject.

@Test
public void testStoredCookieRefTagForProject() {
    final CookieManager cookieManager = new CookieManager();
    final CookieStore cookieStore = cookieManager.getCookieStore();
    final Project project = ProjectFactory.project();
    final RefTag refTag = RefTag.recommended();
    // set the cookie and retrieve the ref tag
    cookieStore.add(null, new HttpCookie("ref_" + project.id(), refTag.tag() + "%3F" + SystemUtils.secondsSinceEpoch()));
    final RefTag retrievedRefTag = RefTagUtils.storedCookieRefTagForProject(project, cookieManager, sharedPreferences);
    assertNotNull(retrievedRefTag);
    assertEquals(refTag, retrievedRefTag);
}
Also used : CookieStore(java.net.CookieStore) Project(com.kickstarter.models.Project) RefTag(com.kickstarter.libs.RefTag) HttpCookie(java.net.HttpCookie) CookieManager(java.net.CookieManager) Test(org.junit.Test)

Example 7 with CookieStore

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

the class CookiesTest method testCookieStoreRemoveRequiresUri.

public void testCookieStoreRemoveRequiresUri() throws URISyntaxException {
    CookieStore cookieStore = new CookieManager().getCookieStore();
    HttpCookie cookieA = new HttpCookie("a", "android");
    cookieStore.add(new URI("http://android.com/source/"), cookieA);
    assertFalse(// RI6 fails this
    "Expected remove() to take the cookie URI into account.", cookieStore.remove(new URI("http://code.google.com/"), cookieA));
    assertEquals(Arrays.asList(cookieA), cookieStore.getCookies());
}
Also used : CookieStore(java.net.CookieStore) HttpCookie(java.net.HttpCookie) URI(java.net.URI) CookieManager(java.net.CookieManager)

Example 8 with CookieStore

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

the class CookiesTest method testCookieStoreAddAcceptsConflictingUri.

public void testCookieStoreAddAcceptsConflictingUri() throws URISyntaxException {
    CookieStore cookieStore = new CookieManager().getCookieStore();
    HttpCookie cookieA = new HttpCookie("a", "android");
    cookieA.setDomain(".android.com");
    cookieA.setPath("/source/");
    cookieStore.add(new URI("http://google.com/source/"), cookieA);
    assertEquals(Arrays.asList(cookieA), cookieStore.getCookies());
}
Also used : CookieStore(java.net.CookieStore) HttpCookie(java.net.HttpCookie) URI(java.net.URI) CookieManager(java.net.CookieManager)

Example 9 with CookieStore

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

the class CookiesTest method testCookieStoreUriUsesHttpSchemeAlways.

public void testCookieStoreUriUsesHttpSchemeAlways() throws URISyntaxException {
    CookieStore cookieStore = new CookieManager().getCookieStore();
    cookieStore.add(new URI("https://a.com/"), 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 10 with CookieStore

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

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());
}
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