Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.Cookie


    }

    public void testParseAttributeNullPath() throws Exception {
        CookieSpec cookiespec = new RFC2109Spec();
        try {
            Cookie cookie = new Cookie();
            cookiespec.parseAttribute(new NameValuePair("path", null), cookie);
            fail("MalformedCookieException must have been thrown");
        } catch (MalformedCookieException expected) {
        }
    }
View Full Code Here


    }

    public void testParseAttributeBlankPath() throws Exception {
        CookieSpec cookiespec = new RFC2109Spec();
        try {
            Cookie cookie = new Cookie();
            cookiespec.parseAttribute(new NameValuePair("path", "   "), cookie);
            fail("MalformedCookieException must have been thrown");
        } catch (MalformedCookieException expected) {
        }
    }
View Full Code Here

    }

    public void testParseAttributeNullVersion() throws Exception {
        CookieSpec cookiespec = new RFC2109Spec();
        try {
            Cookie cookie = new Cookie();
            cookiespec.parseAttribute(new NameValuePair("version", null), cookie);
            fail("MalformedCookieException must have been thrown");
        } catch (MalformedCookieException expected) {
        }
    }
View Full Code Here

    }

    public void testParseAttributeInvalidVersion() throws Exception {
        CookieSpec cookiespec = new RFC2109Spec();
        try {
            Cookie cookie = new Cookie();
            cookiespec.parseAttribute(new NameValuePair("version", "nonsense"), cookie);
            fail("MalformedCookieException must have been thrown");
        } catch (MalformedCookieException expected) {
        }
    }
View Full Code Here

     * Tests if that invalid second domain level cookie gets
     * rejected in the strict mode, but gets accepted in the
     * browser compatibility mode.
     */
    public void testSecondDomainLevelCookie() throws Exception {
        Cookie cookie = new Cookie(".sourceforge.net", "name", null, "/", null, false);
        cookie.setDomainAttributeSpecified(true);
        cookie.setPathAttributeSpecified(true);

        CookieSpec cookiespec = new RFC2109Spec();
        try {
            cookiespec.validate("sourceforge.net", 80, "/", false, cookie);
            fail("MalformedCookieException should have been thrown");
View Full Code Here

            // Expected
        }
    }   

    public void testSecondDomainLevelCookieMatch() throws Exception {
        Cookie cookie = new Cookie(".sourceforge.net", "name", null, "/", null, false);
        cookie.setDomainAttributeSpecified(true);
        cookie.setPathAttributeSpecified(true);

        CookieSpec cookiespec = new RFC2109Spec();
        assertFalse(cookiespec.match("sourceforge.net", 80, "/", false, cookie));
    }
View Full Code Here

   
    /**
     * Tests if null cookie values are handled correctly.
     */
    public void testNullCookieValueFormatting() {
        Cookie cookie = new Cookie(".whatever.com", "name", null, "/", null, false);
        cookie.setDomainAttributeSpecified(true);
        cookie.setPathAttributeSpecified(true);

        CookieSpec cookiespec = new RFC2109Spec();
        String s = cookiespec.formatCookie(cookie);
        assertEquals("$Version=0; name=; $Domain=.whatever.com; $Path=/", s);

        cookie.setVersion(1);
        s = cookiespec.formatCookie(cookie);
        assertEquals("$Version=\"1\"; name=\"\"; $Domain=\".whatever.com\"; $Path=\"/\"", s);
    }
View Full Code Here

        s = cookiespec.formatCookie(cookie);
        assertEquals("$Version=\"1\"; name=\"\"; $Domain=\".whatever.com\"; $Path=\"/\"", s);
    }

    public void testCookieNullDomainNullPathFormatting() {
        Cookie cookie = new Cookie(null, "name", null, "/", null, false);
        cookie.setDomainAttributeSpecified(true);
        cookie.setPathAttributeSpecified(true);

        CookieSpec cookiespec = new RFC2109Spec();
        String s = cookiespec.formatCookie(cookie);
        assertEquals("$Version=0; name=; $Path=/", s);

        cookie.setDomainAttributeSpecified(false);
        cookie.setPathAttributeSpecified(false);
        s = cookiespec.formatCookie(cookie);
        assertEquals("$Version=0; name=", s);
    }
View Full Code Here

        }
    }

    public void testParseAttributeNullPath() throws Exception {
        CookieSpec cookiespec = new CookieSpecBase();
        Cookie cookie = new Cookie();
        cookiespec.parseAttribute(new NameValuePair("path", null), cookie);
        assertEquals("/", cookie.getPath());
    }
View Full Code Here

        assertEquals("/", cookie.getPath());
    }

    public void testParseAttributeBlankPath() throws Exception {
        CookieSpec cookiespec = new CookieSpecBase();
        Cookie cookie = new Cookie();
        cookiespec.parseAttribute(new NameValuePair("path", "   "), cookie);
        assertEquals("/", cookie.getPath());
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.Cookie

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.