Package org.apache.http.impl.cookie

Examples of org.apache.http.impl.cookie.BasicClientCookie


        h.parse(cookie, dateformat.format(now));
        assertNotNull(cookie.getExpiryDate());
    }
   
    public void testBasicExpiresParseInvalid() throws Exception {
        BasicClientCookie cookie = new BasicClientCookie("name", "value");
        CookieAttributeHandler h = new BasicExpiresHandler(new String[] {DateUtils.PATTERN_RFC1123});
        try {
            h.parse(cookie, "garbage");
            fail("MalformedCookieException must have been thrown");
        } catch (MalformedCookieException ex) {
View Full Code Here


            // expected
        }
    }
   
    public void testPublicSuffixFilter() throws Exception {
        BasicClientCookie cookie = new BasicClientCookie("name", "value");
       
        PublicSuffixFilter h = new PublicSuffixFilter(new RFC2109DomainHandler());
        h.setPublicSuffixes(Arrays.asList(new String[] { "co.uk", "com" }));
       
        cookie.setDomain(".co.uk");
        assertFalse(h.match(cookie, new CookieOrigin("apache.co.uk", 80, "/stuff", false)));
       
        cookie.setDomain("co.uk");
        assertFalse(h.match(cookie, new CookieOrigin("apache.co.uk", 80, "/stuff", false)));
       
        cookie.setDomain(".com");
        assertFalse(h.match(cookie, new CookieOrigin("apache.com", 80, "/stuff", false)));
       
        cookie.setDomain("com");
        assertFalse(h.match(cookie, new CookieOrigin("apache.com", 80, "/stuff", false)));       
       
        cookie.setDomain("localhost");
        assertTrue(h.match(cookie, new CookieOrigin("localhost", 80, "/stuff", false)));       
    }
View Full Code Here

    // ----------------------------------------------------------- Test Methods

    public void testCookieIdentityComparasionByName() {
        CookieIdentityComparator comparator = new CookieIdentityComparator();
        BasicClientCookie c1 = new BasicClientCookie("name", "value1");
        BasicClientCookie c2 = new BasicClientCookie("name", "value2");
        assertTrue(comparator.compare(c1, c2) == 0);
       
        BasicClientCookie c3 = new BasicClientCookie("name1", "value");
        BasicClientCookie c4 = new BasicClientCookie("name2", "value");
        assertFalse(comparator.compare(c3, c4) == 0);
    }
View Full Code Here

        assertFalse(comparator.compare(c3, c4) == 0);
    }

    public void testCookieIdentityComparasionByNameAndDomain() {
        CookieIdentityComparator comparator = new CookieIdentityComparator();
        BasicClientCookie c1 = new BasicClientCookie("name", "value1");
        c1.setDomain("www.domain.com");
        BasicClientCookie c2 = new BasicClientCookie("name", "value2");
        c2.setDomain("www.domain.com");
        assertTrue(comparator.compare(c1, c2) == 0);
       
        BasicClientCookie c3 = new BasicClientCookie("name", "value1");
        c3.setDomain("www.domain.com");
        BasicClientCookie c4 = new BasicClientCookie("name", "value2");
        c4.setDomain("domain.com");
        assertFalse(comparator.compare(c3, c4) == 0);
    }
View Full Code Here

        assertFalse(comparator.compare(c3, c4) == 0);
    }

    public void testCookieIdentityComparasionByNameAndNullDomain() {
        CookieIdentityComparator comparator = new CookieIdentityComparator();
        BasicClientCookie c1 = new BasicClientCookie("name", "value1");
        c1.setDomain(null);
        BasicClientCookie c2 = new BasicClientCookie("name", "value2");
        c2.setDomain(null);
        assertTrue(comparator.compare(c1, c2) == 0);
       
        BasicClientCookie c3 = new BasicClientCookie("name", "value1");
        c3.setDomain("www.domain.com");
        BasicClientCookie c4 = new BasicClientCookie("name", "value2");
        c4.setDomain(null);
        assertFalse(comparator.compare(c3, c4) == 0);
    }
View Full Code Here

        assertFalse(comparator.compare(c3, c4) == 0);
    }

    public void testCookieIdentityComparasionByNameAndLocalHost() {
        CookieIdentityComparator comparator = new CookieIdentityComparator();
        BasicClientCookie c1 = new BasicClientCookie("name", "value1");
        c1.setDomain("localhost");
        BasicClientCookie c2 = new BasicClientCookie("name", "value2");
        c2.setDomain("localhost");
        assertTrue(comparator.compare(c1, c2) == 0);
       
        BasicClientCookie c3 = new BasicClientCookie("name", "value1");
        c3.setDomain("localhost.local");
        BasicClientCookie c4 = new BasicClientCookie("name", "value2");
        c4.setDomain("localhost");
        assertTrue(comparator.compare(c3, c4) == 0);
    }
View Full Code Here

    public static Test suite() {
        return new TestSuite(TestCookiePathComparator.class);
    }

    public void testUnequality1() {
        BasicClientCookie cookie1 = new BasicClientCookie("name1", "value");
        cookie1.setPath("/a/b/");
        BasicClientCookie cookie2 = new BasicClientCookie("name1", "value");
        cookie2.setPath("/a/");
        Comparator<Cookie> comparator = new CookiePathComparator();
        assertTrue(comparator.compare(cookie1, cookie2) < 0);
        assertTrue(comparator.compare(cookie2, cookie1) > 0);
    }
View Full Code Here

        assertTrue(comparator.compare(cookie1, cookie2) < 0);
        assertTrue(comparator.compare(cookie2, cookie1) > 0);
    }

    public void testUnequality2() {
        BasicClientCookie cookie1 = new BasicClientCookie("name1", "value");
        cookie1.setPath("/a/b");
        BasicClientCookie cookie2 = new BasicClientCookie("name1", "value");
        cookie2.setPath("/a");
        Comparator<Cookie> comparator = new CookiePathComparator();
        assertTrue(comparator.compare(cookie1, cookie2) < 0);
        assertTrue(comparator.compare(cookie2, cookie1) > 0);
    }
View Full Code Here

        assertTrue(comparator.compare(cookie1, cookie2) < 0);
        assertTrue(comparator.compare(cookie2, cookie1) > 0);
    }

    public void testEquality1() {
        BasicClientCookie cookie1 = new BasicClientCookie("name1", "value");
        cookie1.setPath("/a");
        BasicClientCookie cookie2 = new BasicClientCookie("name1", "value");
        cookie2.setPath("/a");
        Comparator<Cookie> comparator = new CookiePathComparator();
        assertTrue(comparator.compare(cookie1, cookie2) == 0);
        assertTrue(comparator.compare(cookie2, cookie1) == 0);
    }
View Full Code Here

        assertTrue(comparator.compare(cookie1, cookie2) == 0);
        assertTrue(comparator.compare(cookie2, cookie1) == 0);
    }

    public void testEquality2() {
        BasicClientCookie cookie1 = new BasicClientCookie("name1", "value");
        cookie1.setPath("/a/");
        BasicClientCookie cookie2 = new BasicClientCookie("name1", "value");
        cookie2.setPath("/a");
        Comparator<Cookie> comparator = new CookiePathComparator();
        assertTrue(comparator.compare(cookie1, cookie2) == 0);
        assertTrue(comparator.compare(cookie2, cookie1) == 0);
    }
View Full Code Here

TOP

Related Classes of org.apache.http.impl.cookie.BasicClientCookie

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.