Examples of BasicClientCookie


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

        h.parse(cookie, null);
        assertTrue(cookie.isSecure());
    }

    public void testBasicSecureMatch() throws Exception {
        BasicClientCookie cookie = new BasicClientCookie("name", "value");
        CookieAttributeHandler h = new BasicSecureHandler();

        CookieOrigin origin1 = new CookieOrigin("somehost", 80, "/stuff", false);
        cookie.setSecure(false);
        assertTrue(h.match(cookie, origin1));
        cookie.setSecure(true);
        assertFalse(h.match(cookie, origin1));

        CookieOrigin origin2 = new CookieOrigin("somehost", 80, "/stuff", true);
        cookie.setSecure(false);
        assertTrue(h.match(cookie, origin2));
        cookie.setSecure(true);
        assertTrue(h.match(cookie, origin2));
    }
View Full Code Here

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

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

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

            // expected
        }
    }

    public void testBasicExpiresParse() throws Exception {
        BasicClientCookie cookie = new BasicClientCookie("name", "value");
        CookieAttributeHandler h = new BasicExpiresHandler(new String[] {DateUtils.PATTERN_RFC1123});
       
        DateFormat dateformat = new SimpleDateFormat(DateUtils.PATTERN_RFC1123, Locale.US);
        dateformat.setTimeZone(DateUtils.GMT);
       
        Date now = new Date();
       
        h.parse(cookie, dateformat.format(now));
        assertNotNull(cookie.getExpiryDate());
    }
View Full Code Here

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

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

            // 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

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

        DefaultHttpClient client = new DefaultHttpClient();
       
        CookieStore cookieStore = new BasicCookieStore();
        client.setCookieStore(cookieStore);
       
        BasicClientCookie cookie = new BasicClientCookie("name", "value");
        cookie.setDomain("localhost");
        cookie.setPath("/");
       
        cookieStore.addCookie(cookie);

        HttpContext context = new BasicHttpContext();
        HttpGet httpget = new HttpGet("/oldlocation/");
View Full Code Here

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

    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

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

        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

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

        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

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

        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
Copyright © 2018 www.massapi.com. 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.