Examples of BasicClientCookie


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 testBasicMaxAgeParse() throws Exception {
        BasicClientCookie cookie = new BasicClientCookie("name", "value");
        CookieAttributeHandler h = new BasicMaxAgeHandler();
        h.parse(cookie, "2000");
        assertNotNull(cookie.getExpiryDate());
    }
View Full Code Here

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

        h.parse(cookie, "2000");
        assertNotNull(cookie.getExpiryDate());
    }

    public void testBasicMaxAgeParseInvalid() throws Exception {
        BasicClientCookie cookie = new BasicClientCookie("name", "value");
        CookieAttributeHandler h = new BasicMaxAgeHandler();
        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 testBasicCommentParse() throws Exception {
        BasicClientCookie cookie = new BasicClientCookie("name", "value");
        CookieAttributeHandler h = new BasicCommentHandler();
        h.parse(cookie, "whatever");
        assertEquals("whatever", cookie.getComment());
        h.parse(cookie, null);
        assertEquals(null, cookie.getComment());
    }
View Full Code Here

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

            // expected
        }
    }
   
    public void testBasicSecureParse() throws Exception {
        BasicClientCookie cookie = new BasicClientCookie("name", "value");
        CookieAttributeHandler h = new BasicSecureHandler();
        h.parse(cookie, "whatever");
        assertTrue(cookie.isSecure());
        h.parse(cookie, null);
        assertTrue(cookie.isSecure());
    }
View Full Code Here

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

        //Create test config via servlet
        executor.execute(rb.buildGetRequest("/mdc", "createTestConfig", "true"));
        TimeUnit.SECONDS.sleep(1);

        //Pass custom cookie
        BasicClientCookie cookie = new BasicClientCookie("mdc-test-cookie", "foo-test-cookie");
        cookie.setPath("/");
        cookie.setDomain("localhost");
        httpClient.getCookieStore().addCookie(cookie);

        //Execute request
        RequestExecutor result = executor.execute(
                rb.buildGetRequest("/mdc", "mdc-test-param", "foo-test-param", "ignored-param", "ignored-value")
View Full Code Here

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

  public void addCookie(String key, String val, String host, String path) {
    Cookie c = new Cookie(key, val, host, path);
    //设置Cookie
    String name = c.name();
    String value = c.value();
    BasicClientCookie clientCookie = new BasicClientCookie(name, value);
    clientCookie.setPath(c.path());
    clientCookie.setDomain(c.domain());
    httpClient.getCookieStore().addCookie(clientCookie);
  }
View Full Code Here

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

    @Test
    public void testNoMatchingCookies() throws Exception {
        HttpRequest request = new BasicHttpRequest("GET", "/");

        this.cookieStore.clear();
        BasicClientCookie cookie3 = new BasicClientCookie("name3", "value3");
        cookie3.setDomain("www.somedomain.com");
        cookie3.setPath("/");
        this.cookieStore.addCookie(cookie3);

        HttpRoute route = new HttpRoute(this.target, null, false);

        HttpRoutedConnection conn = Mockito.mock(HttpRoutedConnection.class);
View Full Code Here

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

        Assert.assertEquals(0, headers2.length);
    }

    // Helper method
    private BasicClientCookie makeCookie(String name, String value, String domain, String path) {
        BasicClientCookie cookie = new BasicClientCookie(name, value);
        cookie.setDomain(domain);
        cookie.setPath(path);
        return cookie;
    }
View Full Code Here

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

    @Test
    public void testAddSpecVersionHeader() throws Exception {
        HttpRequest request = new BasicHttpRequest("GET", "/");

        this.cookieStore.clear();
        BasicClientCookie cookie1 = new BasicClientCookie("name1", "value1");
        cookie1.setVersion(0);
        cookie1.setDomain("localhost.local");
        cookie1.setPath("/");
        this.cookieStore.addCookie(cookie1);
        BasicClientCookie cookie2 = new BasicClientCookie("name2", "value2");
        cookie2.setVersion(0);
        cookie2.setDomain("localhost.local");
        cookie2.setPath("/");
        this.cookieStore.addCookie(cookie2);

        HttpRoute route = new HttpRoute(this.target, null, false);

        HttpRoutedConnection conn = Mockito.mock(HttpRoutedConnection.class);
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.