Package java.net

Examples of java.net.CookieManager

The implementation conforms to RFC 2965, section 3.3. @version %I%, %E% @author Edward Wang @since 1.6


        super.doStart();
    }

    private CookieManager newCookieManager()
    {
        return new CookieManager(getCookieStore(), CookiePolicy.ACCEPT_ALL);
    }
View Full Code Here


    @Test
    public void testViaCookieManager() throws Exception
    {
        // Setup client
        CookieManager cookieMgr = new CookieManager();
        client.setCookieStore(cookieMgr.getCookieStore());
        HttpCookie cookie = new HttpCookie("hello","world");
        cookie.setPath("/");
        cookie.setMaxAge(100000);
        cookieMgr.getCookieStore().add(server.getWsUri(),cookie);

        // Client connects
        CookieTrackingSocket clientSocket = new CookieTrackingSocket();
        Future<Session> clientConnectFuture = client.connect(clientSocket,server.getWsUri());
View Full Code Here

    private String cookie;
    private String rawCookie;

    public HttpUrlConnector()
    {
        CookieHandler.setDefault(new CookieManager(null,
                CookiePolicy.ACCEPT_ALL));

    }
View Full Code Here

    /**
     * @see http://blogs.sun.com/CoreJavaTechTips/entry/cookie_handling_in_java_se
     */
    public static void enableCookieMgmt() {
        CookieManager manager = new CookieManager();
        manager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
        CookieHandler.setDefault(manager);
    }
View Full Code Here

    /**
     * @see http://blogs.sun.com/CoreJavaTechTips/entry/cookie_handling_in_java_se
     */
    public static void enableCookieMgmt() {
        CookieManager manager = new CookieManager();
        manager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
        CookieHandler.setDefault(manager);
    }
View Full Code Here

    /**
     * @see
     * http://blogs.sun.com/CoreJavaTechTips/entry/cookie_handling_in_java_se
     */
    public static void enableCookieMgmt() {
        CookieManager manager = new CookieManager();
        manager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
        CookieHandler.setDefault(manager);
    }
View Full Code Here

     * @tests {@link java.net.CookieManager#CookieManager()}
     *
     * @since 1.6
     */
    public void test_CookieManager() {
        CookieManager cookieManager = new CookieManager();
        assertNotNull(cookieManager);
        assertNotNull(cookieManager.getCookieStore());
    }
View Full Code Here

            public boolean removeAll() {
                return false;
            }
        }
        CookieStore store = new DummyStore();
        CookieManager cookieManager = new CookieManager(store,
                CookiePolicy.ACCEPT_ALL);
        assertEquals("A dummy store", ((DummyStore) cookieManager
                .getCookieStore()).getName());
        assertSame(store, cookieManager.getCookieStore());
    }
View Full Code Here

     */
    public void test_SetCookiePolicy_LCookiePolicy() throws URISyntaxException,
            IOException {

        // Policy = ACCEPT_NONE
        CookieManager manager = new CookieManager();
        manager.setCookiePolicy(CookiePolicy.ACCEPT_NONE);
        Map<String, List<String>> responseHeaders = new TreeMap<String, List<String>>();       
        URI uri = new URI("http://a.b.c");
        manager.put(uri, responseHeaders);
        Map<String, List<String>> map = manager.get(uri,
                new HashMap<String, List<String>>());

        assertEquals(1, map.size());
        assertTrue(map.get("Cookie").isEmpty());
        Object key = map.keySet().toArray()[0];
        assertNotNull(key);
        assertEquals("Cookie", key);

        // Policy = ACCEPT_ALL
        manager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
        responseHeaders = new TreeMap<String, List<String>>();   
        ArrayList<String> list = new ArrayList<String>();
        list.add("test=null");
        responseHeaders.put("Set-cookie", list);
        manager.put(new URI("http://b.c.d"), responseHeaders);
        map = manager.get(uri, new HashMap<String, List<String>>());
        assertEquals(1, map.size());       
    }
View Full Code Here

     * @tests {@link java.net.CookieManager#getCookieStore()}
     *
     * @since 1.6
     */
    public void test_GetCookieStore() {
        CookieManager cookieManager = new CookieManager();
        CookieStore store = cookieManager.getCookieStore();
        assertNotNull(store);
    }
View Full Code Here

TOP

Related Classes of java.net.CookieManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.