Code example for HttpCookie

Methods: setComment, setCommentURL, setDiscard, setDomain, setMaxAge, setPath, setPortlist, setSecure, setVersion, toString

0
     * @tests java.net.HttpCookie#toString() 
     *  
     * @since 1.6 
     */ 
    public void test_ToString() { 
        HttpCookie cookie = new HttpCookie("test", "testValue");
        cookie.setComment("ABCd");
        cookie.setCommentURL("\u63DF");
        cookie.setDomain(".B.com");
        cookie.setDiscard(true);
        cookie.setMaxAge(Integer.MAX_VALUE);
        cookie.setPath("temp/22RuTh");
        cookie.setPortlist("80.562Ab");
        cookie.setSecure(true);
        cookie.setVersion(1);
 
        assertEquals(
                "test=\"testValue\";$Path=\"temp/22RuTh\";$Domain=\".b.com\";$Port=\"80.562Ab\"", 
                cookie.toString());
 
        cookie.setPath(null);
        assertEquals(
                "test=\"testValue\";$Domain=\".b.com\";$Port=\"80.562Ab\"", 
                cookie.toString());
        cookie.setComment(null);
        assertEquals(
                "test=\"testValue\";$Domain=\".b.com\";$Port=\"80.562Ab\"", 
                cookie.toString());
        cookie.setPortlist(null);
        assertEquals("test=\"testValue\";$Domain=\".b.com\"", cookie.toString());
        cookie.setDomain(null);
        assertEquals("test=\"testValue\"", cookie.toString());
 
        cookie.setVersion(0);
        cookie.setPortlist("80,8000");
        assertEquals("test=testValue", cookie.toString());
    } 
 
    /** 
     * @tests java.net.HttpCookie#hashCode() 
     *