Examples of CookieAttributeHandler


Examples of org.apache.http.cookie.CookieAttributeHandler

        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.cookie.CookieAttributeHandler

        cookie.setSecure(true);
        assertTrue(h.match(cookie, origin2));
    }

    public void testBasicSecureInvalidInput() throws Exception {
        CookieAttributeHandler h = new BasicSecureHandler();
        try {
            h.parse(null, 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 BasicClientCookie("name", "value"), null);
            fail("IllegalArgumentException must have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
    }
View Full Code Here

Examples of org.apache.http.cookie.CookieAttributeHandler

        }
    }

    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.cookie.CookieAttributeHandler

        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) {
            // expected
        }
        try {
            h.parse(cookie, null);
            fail("MalformedCookieException must have been thrown");
        } catch (MalformedCookieException ex) {
            // expected
        }
    }
View Full Code Here

Examples of org.apache.http.cookie.CookieAttributeHandler

            new BasicExpiresHandler(null);
            fail("IllegalArgumentException must have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        CookieAttributeHandler h = new BasicExpiresHandler(new String[] {DateUtils.PATTERN_RFC1123});
        try {
            h.parse(null, null);
            fail("IllegalArgumentException must have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
    }
View Full Code Here

Examples of org.apache.http.cookie.CookieAttributeHandler

        }
       
    }
   
    public void testSimpleRegisterAndGet() throws IOException {
        CookieAttributeHandler h1 = new DummyCookieAttribHandler();
        CookieAttributeHandler h2 = new DummyCookieAttribHandler();
       
        AbstractCookieSpec cookiespec = new DummyCookieSpec();
        cookiespec.registerAttribHandler("this", h1);
        cookiespec.registerAttribHandler("that", h2);
        cookiespec.registerAttribHandler("thistoo", h1);
View Full Code Here

Examples of org.apache.http.cookie.CookieAttributeHandler

        assertNotNull(it.next());
        assertFalse(it.hasNext());
    }

    public void testInvalidHandler() throws IOException {
        CookieAttributeHandler h1 = new DummyCookieAttribHandler();
        CookieAttributeHandler h2 = new DummyCookieAttribHandler();
       
        AbstractCookieSpec cookiespec = new DummyCookieSpec();
        cookiespec.registerAttribHandler("this", h1);
        cookiespec.registerAttribHandler("that", h2);
       
View Full Code Here

Examples of org.apache.http.cookie.CookieAttributeHandler

                NameValuePair attrib = attribs[j];
                String s = attrib.getName().toLowerCase(Locale.ENGLISH);

                cookie.setAttribute(s, attrib.getValue());

                CookieAttributeHandler handler = findAttribHandler(s);
                if (handler != null) {
                    handler.parse(cookie, attrib.getValue());
                }
            }
            cookies.add(cookie);
        }
        return cookies;
View Full Code Here

Examples of org.apache.http.cookie.CookieAttributeHandler

        }
       
    }
   
    public void testSimpleRegisterAndGet() throws IOException {
        CookieAttributeHandler h1 = new DummyCookieAttribHandler();
        CookieAttributeHandler h2 = new DummyCookieAttribHandler();
       
        AbstractCookieSpec cookiespec = new DummyCookieSpec();
        cookiespec.registerAttribHandler("this", h1);
        cookiespec.registerAttribHandler("that", h2);
        cookiespec.registerAttribHandler("thistoo", h1);
View Full Code Here

Examples of org.apache.http.cookie.CookieAttributeHandler

        assertNotNull(it.next());
        assertFalse(it.hasNext());
    }

    public void testInvalidHandler() throws IOException {
        CookieAttributeHandler h1 = new DummyCookieAttribHandler();
        CookieAttributeHandler h2 = new DummyCookieAttribHandler();
       
        AbstractCookieSpec cookiespec = new DummyCookieSpec();
        cookiespec.registerAttribHandler("this", h1);
        cookiespec.registerAttribHandler("that", h2);
       
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.