Examples of BasicDomainHandler


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

        junit.textui.TestRunner.main(testCaseName);
    }

    public void testBasicDomainParse() throws Exception {
        BasicClientCookie cookie = new BasicClientCookie("name", "value");
        CookieAttributeHandler h = new BasicDomainHandler();
        h.parse(cookie, "www.somedomain.com");
        assertEquals("www.somedomain.com", cookie.getDomain());
    }
View Full Code Here

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

        assertEquals("www.somedomain.com", cookie.getDomain());
    }

    public void testBasicDomainParseInvalid() throws Exception {
        BasicClientCookie cookie = new BasicClientCookie("name", "value");
        CookieAttributeHandler h = new BasicDomainHandler();
        try {
            h.parse(cookie, "");
            fail("MalformedCookieException should have been thrown");
        } catch (MalformedCookieException ex) {
            // expected
        }
        try {
            h.parse(cookie, null);
            fail("MalformedCookieException should have been thrown");
        } catch (MalformedCookieException ex) {
            // expected
        }
    }
View Full Code Here

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

    }

    public void testBasicDomainValidate1() throws Exception {
        BasicClientCookie cookie = new BasicClientCookie("name", "value");
        CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false);
        CookieAttributeHandler h = new BasicDomainHandler();
       
        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

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

    }

    public void testBasicDomainValidate2() throws Exception {
        BasicClientCookie cookie = new BasicClientCookie("name", "value");
        CookieOrigin origin = new CookieOrigin("somehost", 80, "/", false);
        CookieAttributeHandler h = new BasicDomainHandler();
       
        cookie.setDomain("somehost");
        h.validate(cookie, origin);

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

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

    }

    public void testBasicDomainValidate3() throws Exception {
        BasicClientCookie cookie = new BasicClientCookie("name", "value");
        CookieOrigin origin = new CookieOrigin("somedomain.com", 80, "/", false);
        CookieAttributeHandler h = new BasicDomainHandler();
       
        cookie.setDomain(".somedomain.com");
        h.validate(cookie, origin);
    }
View Full Code Here

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

    }

    public void testBasicDomainValidate4() throws Exception {
        BasicClientCookie cookie = new BasicClientCookie("name", "value");
        CookieOrigin origin = new CookieOrigin("somedomain.com", 80, "/", false);
        CookieAttributeHandler h = new BasicDomainHandler();
       
        cookie.setDomain(null);
        try {
            h.validate(cookie, origin);
            fail("MalformedCookieException should have been thrown");
        } catch (MalformedCookieException ex) {
            // expected
        }
    }
View Full Code Here

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

    }
   
    public void testBasicDomainMatch1() throws Exception {
        BasicClientCookie cookie = new BasicClientCookie("name", "value");
        CookieOrigin origin = new CookieOrigin("somedomain.com", 80, "/", false);
        CookieAttributeHandler h = new BasicDomainHandler();

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

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

    }

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

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

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

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

        cookie.setDomain(null);
        assertFalse(h.match(cookie, origin));
    }

    public void testBasicDomainInvalidInput() throws Exception {
        CookieAttributeHandler h = new BasicDomainHandler();
        try {
            h.parse(null, null);
            fail("IllegalArgumentException must have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
            h.validate(null, null);
            fail("IllegalArgumentException must have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
            h.validate(new BasicClientCookie("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 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.BasicDomainHandler

        junit.textui.TestRunner.main(testCaseName);
    }

    public void testBasicDomainParse() throws Exception {
        BasicClientCookie cookie = new BasicClientCookie("name", "value");
        CookieAttributeHandler h = new BasicDomainHandler();
        h.parse(cookie, "www.somedomain.com");
        assertEquals("www.somedomain.com", cookie.getDomain());
    }
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.