Package java.net

Examples of java.net.HttpCookie$CookieAttributeAssignor


     * @tests java.net.HttpCookie#getPath(), setPath(String)
     *
     * @since 1.6
     */
    public void test_Get_SetPath() {
        HttpCookie cookie = new HttpCookie("name", "test new value");
        assertNull(cookie.getPath());

        cookie.setPath("{}()  test,; 43!@");
        assertEquals("{}()  test,; 43!@", cookie.getPath());

        cookie.setPath(" test");
        assertEquals(" test", cookie.getPath());

        cookie.setPath("\u63DF\u64DE");
        cookie.setDomain("test");
        assertEquals("\u63DF\u64DE", cookie.getPath());
    }
View Full Code Here


     * @tests java.net.HttpCookie#getMaxAge(), setMaxAge(long)
     *
     * @since 1.6
     */
    public void test_Get_SetMaxAge() {
        HttpCookie cookie = new HttpCookie("name", "test new value");
        assertEquals(-1, cookie.getMaxAge());

        cookie.setMaxAge(Long.MAX_VALUE);
        assertEquals(Long.MAX_VALUE, cookie.getMaxAge());

        cookie.setMaxAge(Long.MIN_VALUE);
        cookie.setDiscard(false);
        assertEquals(Long.MIN_VALUE, cookie.getMaxAge());
    }
View Full Code Here

     * @tests java.net.HttpCookie#getDomain(), setDomain(String)
     *
     * @since 1.6
     */
    public void test_Get_SetDomain() {
        HttpCookie cookie = new HttpCookie("name", "test new value");
        assertNull(cookie.getDomain());

        cookie.setDomain("a.b.d.c.com.");
        assertEquals("a.b.d.c.com.", cookie.getDomain());

        cookie.setDomain("   a.b.d.c.com.  ");
        assertEquals("   a.b.d.c.com.  ", cookie.getDomain());

        cookie.setPath("temp/subTemp");
        cookie.setDomain("xy.foo.bar.de.edu");
        assertEquals("xy.foo.bar.de.edu", cookie.getDomain());
    }
View Full Code Here

     * @tests java.net.HttpCookie#getPortlist(), setPortlist(String)
     *
     * @since 1.6
     */
    public void test_Get_SetPortlist() {
        HttpCookie cookie = new HttpCookie("cookieName", "cookieName value");
        assertNull(cookie.getPortlist());

        cookie.setPortlist("80,23,20");
        assertEquals("80,23,20", cookie.getPortlist());
        cookie.setPortlist("abcdefg1234567");
        cookie.setValue("cookie value again");
        assertEquals("abcdefg1234567", cookie.getPortlist());
    }
View Full Code Here

     * @tests java.net.HttpCookie#getDiscard(), setDiscard(boolean)
     *
     * @since 1.6
     */
    public void test_Get_SetDiscard() {
        HttpCookie cookie = new HttpCookie("cookie'sName",
                "cookie's Test value");
        assertFalse(cookie.getDiscard());

        cookie.setDiscard(true);
        assertTrue(cookie.getDiscard());
        cookie.setDiscard(false);
        cookie.setMaxAge(-1);
        assertFalse(cookie.getDiscard());
    }
View Full Code Here

     * @tests java.net.HttpCookie#getCommentURL(), setCommentURL(String)
     *
     * @since 1.6
     */
    public void test_Get_SetCommentURL() {
        HttpCookie cookie = new HttpCookie("cookie'\"sName",
                "cookie's Test value");
        assertNull(cookie.getCommentURL());

        cookie.setCommentURL("http://www.test.com");
        assertEquals("http://www.test.com", cookie.getCommentURL());

        cookie.setCommentURL("schema://harmony.test.org");
        cookie.setComment("just a comment");
        assertEquals("schema://harmony.test.org", cookie.getCommentURL());
    }
View Full Code Here

     * @tests java.net.HttpCookie#getComment(), setComment(String)
     *
     * @since 1.6
     */
    public void test_Get_SetComment() {
        HttpCookie cookie = new HttpCookie("cookie'\"sName?",
                "cookie's Test??!@# value");
        assertNull(cookie.getComment());

        cookie.setComment("");
        assertEquals("", cookie.getComment());

        cookie.setComment("cookie''s @#$!&*()");
        cookie.setVersion(0);
        assertEquals("cookie''s @#$!&*()", cookie.getComment());
    }
View Full Code Here

     * @tests java.net.HttpCookie#hasExpired()
     *
     * @since 1.6
     */
    public void test_HasExpired() {
        HttpCookie cookie = new HttpCookie("cookie'\"sName123456",
                "cookie's Test?()!@# value");
        assertFalse(cookie.hasExpired());

        cookie.setMaxAge(0);
        assertTrue(cookie.hasExpired());

        cookie.setMaxAge(Long.MAX_VALUE);
        cookie.setVersion(0);
        assertFalse(cookie.hasExpired());

        cookie.setMaxAge(Long.MIN_VALUE);
        cookie.setDiscard(false);
        assertTrue(cookie.hasExpired());

        cookie.setDiscard(true);
        cookie.setMaxAge(-1);
        assertFalse(cookie.hasExpired());
    }
View Full Code Here

     *
     * @since 1.6
     */
    public void test_Equals() {
        Object obj = new Object();
        HttpCookie cookie = new HttpCookie("test", "testValue");
        HttpCookie cookie2 = new HttpCookie("TesT", "TEstValue");

        assertFalse(cookie.equals(obj));
        assertFalse(cookie.equals(null));
        assertTrue(cookie2.equals(cookie));
        assertTrue(cookie.equals(cookie2));
        assertTrue(cookie.equals(cookie));

        cookie.setDomain("  test");
        cookie2.setDomain("test");
        assertFalse(cookie.equals(cookie2));
        cookie.setDomain("TEST");
        assertTrue(cookie.equals(cookie2));

        cookie.setPath("temp\\e");
        assertFalse(cookie.equals(cookie2));
        cookie2.setPath("temp\\E");
        assertFalse(cookie.equals(cookie2));

        cookie.setDiscard(true);
        cookie.setMaxAge(-1234);
        cookie2.setPath("temp\\e");
        assertTrue(cookie.equals(cookie2));
    }
View Full Code Here

     * @tests java.net.HttpCookie#clone()
     *
     * @since 1.6
     */
    public void test_Clone() {
        HttpCookie cookie = new HttpCookie("test", "testValue");
        cookie.setMaxAge(33l);
        cookie.setComment("test comment");
        HttpCookie cloneCookie = (HttpCookie) cookie.clone();
        assertNotSame(cloneCookie, cookie);
        assertEquals("test", cloneCookie.getName());
        assertEquals(33l, cloneCookie.getMaxAge());
        assertEquals("test comment", cloneCookie.getComment());
    }
View Full Code Here

TOP

Related Classes of java.net.HttpCookie$CookieAttributeAssignor

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.