Code example for CookieManager

Methods: get

0
                cookieHeaders("a=android;path=/foo")); 
        assertEquals("/foo", cookieStore.getCookie("a").getPath());
    } 
 
    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()));
    } 
 
    public void testSendingCookiesFromStore() throws Exception { 
        MockWebServer server = new MockWebServer();
        server.enqueue(new MockResponse());
        server.play();
 
        CookieManager cookieManager = new CookieManager(null, ACCEPT_ORIGINAL_SERVER);
        HttpCookie cookieA = new HttpCookie("a", "android");
        cookieA.setDomain(".local");
        cookieA.setPath("/");