Package org.apache.http.cookie

Examples of org.apache.http.cookie.Cookie


            // expected
        }
    }

    public void testRFC2109DomainValidate2() throws Exception {
        Cookie cookie = new Cookie("name", "value");
        CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false);
        CookieAttributeHandler h = new RFC2109DomainHandler();
       
        cookie.setDomain(".somedomain.com");
        h.validate(cookie, origin);

        cookie.setDomain(".otherdomain.com");
        try {
            h.validate(cookie, origin);
            fail("MalformedCookieException should have been thrown");
        } catch (MalformedCookieException ex) {
            // expected
        }
        cookie.setDomain("www.otherdomain.com");
        try {
            h.validate(cookie, origin);
            fail("MalformedCookieException should have been thrown");
        } catch (MalformedCookieException ex) {
            // expected
View Full Code Here


            // expected
        }
    }

    public void testRFC2109DomainValidate3() throws Exception {
        Cookie cookie = new Cookie("name", "value");
        CookieOrigin origin = new CookieOrigin("www.a.com", 80, "/", false);
        CookieAttributeHandler h = new RFC2109DomainHandler();
       
        cookie.setDomain(".a.com");
        h.validate(cookie, origin);

        cookie.setDomain(".com");
        try {
            h.validate(cookie, origin);
            fail("MalformedCookieException should have been thrown");
        } catch (MalformedCookieException ex) {
            // expected
View Full Code Here

            // expected
        }
    }

    public void testRFC2109DomainValidate4() throws Exception {
        Cookie cookie = new Cookie("name", "value");
        CookieOrigin origin = new CookieOrigin("www.a.b.c", 80, "/", false);
        CookieAttributeHandler h = new RFC2109DomainHandler();
       
        cookie.setDomain(".a.b.c");
        h.validate(cookie, origin);

        cookie.setDomain(".b.c");
        try {
            h.validate(cookie, origin);
            fail("MalformedCookieException should have been thrown");
        } catch (MalformedCookieException ex) {
            // expected
        }
        cookie.setDomain(".a.a.b.c");
        try {
            h.validate(cookie, origin);
            fail("MalformedCookieException should have been thrown");
        } catch (MalformedCookieException ex) {
            // expected
View Full Code Here

            // expected
        }
    }
   
    public void testRFC2109DomainMatch1() throws Exception {
        Cookie cookie = new Cookie("name", "value");
        CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false);
        CookieAttributeHandler h = new RFC2109DomainHandler();

        cookie.setDomain(null);
        assertFalse(h.match(cookie, origin));
       
        cookie.setDomain(".somedomain.com");
        assertTrue(h.match(cookie, origin));
    }
View Full Code Here

        cookie.setDomain(".somedomain.com");
        assertTrue(h.match(cookie, origin));
    }

    public void testRFC2109DomainMatch2() throws Exception {
        Cookie cookie = new Cookie("name", "value");
        CookieOrigin origin = new CookieOrigin("www.whatever.somedomain.com", 80, "/", false);
        CookieAttributeHandler h = new RFC2109DomainHandler();

        cookie.setDomain(".somedomain.com");
        assertTrue(h.match(cookie, origin));
    }
View Full Code Here

        cookie.setDomain(".somedomain.com");
        assertTrue(h.match(cookie, origin));
    }

    public void testRFC2109DomainMatch3() throws Exception {
        Cookie cookie = new Cookie("name", "value");
        CookieOrigin origin = new CookieOrigin("somedomain.com", 80, "/", false);
        CookieAttributeHandler h = new RFC2109DomainHandler();

        cookie.setDomain("somedomain.com");
        assertTrue(h.match(cookie, origin));
    }
View Full Code Here

        cookie.setDomain("somedomain.com");
        assertTrue(h.match(cookie, origin));
    }

    public void testRFC2109DomainMatch4() throws Exception {
        Cookie cookie = new Cookie("name", "value");
        CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false);
        CookieAttributeHandler h = new RFC2109DomainHandler();

        cookie.setDomain("somedomain.com");
        assertFalse(h.match(cookie, origin));
    }
View Full Code Here

            fail("IllegalArgumentException must have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
            h.validate(new Cookie("name", "value"), null);
            fail("IllegalArgumentException must have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
            h.match(null, null);
            fail("IllegalArgumentException must have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
            h.match(new Cookie("name", "value"), null);
            fail("IllegalArgumentException must have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
    }
View Full Code Here

            // expected
        }
    }
    public void testRFC2109VersionParse() throws Exception {
        Cookie cookie = new Cookie("name", "value");
        CookieAttributeHandler h = new RFC2109VersionHandler();
        h.parse(cookie, "12");
        assertEquals(12, cookie.getVersion());
    }
View Full Code Here

        h.parse(cookie, "12");
        assertEquals(12, cookie.getVersion());
    }

    public void testRFC2109VersionParseInvalid() throws Exception {
        Cookie cookie = new Cookie("name", "value");
        CookieAttributeHandler h = new RFC2109VersionHandler();
        try {
            h.parse(cookie, "garbage");
            fail("MalformedCookieException must have been thrown");
        } catch (MalformedCookieException ex) {
View Full Code Here

TOP

Related Classes of org.apache.http.cookie.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.