Code example for CookieStore

Methods: add, getURIs

0
     * @tests java.net.CookieStore#getURIs() 
     *  
     * @since 1.6 
     */ 
    public void test_getURIs() throws URISyntaxException { 
        List<URI> list = cookieStore.getURIs();
        assertTrue(list.isEmpty());
        assertTrue(list instanceof ArrayList);
 
        URI uri1 = new URI("http://geturis1.test.com");
        HttpCookie cookie1 = new HttpCookie("cookie_name1", "cookie_value1");
        cookieStore.add(uri1, cookie1);
        list = cookieStore.getURIs();
        assertEquals("geturis1.test.com", list.get(0).getHost());
 
        HttpCookie cookie2 = new HttpCookie("cookie_name2", "cookie_value2");
        cookieStore.add(uri1, cookie2);
        list = cookieStore.getURIs();
        assertEquals(1, list.size());
 
        URI uri2 = new URI("http://geturis2.test.com");
        cookieStore.add(uri2, cookie2);
        list = cookieStore.getURIs();
        assertEquals(2, list.size());
        assertTrue(list.contains(uri1));
        assertTrue(list.contains(uri2));
    }