Package org.mockserver.model

Examples of org.mockserver.model.Cookie


        assertThat(httpResponse.getHeaders(), containsInAnyOrder(
                new Header("header_name", "header_value"),
                new Header("Set-Cookie", "cookie_name=cookie_value")
        ));
        assertEquals(httpResponse.getCookies(), Arrays.asList(
                new Cookie("cookie_name", "cookie_value")
        ));
        assertEquals(httpResponse.getBodyAsString(), "some_other_body");
    }
View Full Code Here


        // when
        HttpResponse httpResponse = new ApacheHttpClientToMockServerResponseMapper().mapApacheHttpClientResponseToMockServerResponse(httpClientResponse, false);

        // then
        assertEquals(httpResponse.getCookies(), Arrays.asList(
                new Cookie("valid_name", "valid_value", "")
        ));
    }
View Full Code Here

                    try {
                        for (HttpCookie httpCookie : HttpCookie.parse(cookieHeader)) {
                            if (mappedCookies.containsKey(httpCookie.getName())) {
                                mappedCookies.get(httpCookie.getName()).addValue(httpCookie.getValue());
                            } else {
                                mappedCookies.put(httpCookie.getName(), new Cookie(httpCookie.getName(), httpCookie.getValue()));
                            }
                        }
                    } catch (IllegalArgumentException iae) {
                        logger.warn("Exception while parsing cookie header [" + cookieHeader + "]", iae);
                    }
View Full Code Here

public class CookieDTOTest {

    @Test
    public void shouldReturnValueSetInConstructor() {
        // when
        CookieDTO cookie = new CookieDTO(new Cookie("first", "first_one", "first_two"));

        // then
        assertThat(cookie.getValues(), containsInAnyOrder("first_one", "first_two"));
        assertThat(cookie.buildObject().getValues(), containsInAnyOrder("first_one", "first_two"));
    }
View Full Code Here

    @Test
    public void shouldReturnValueSetInConstructor() {
        // given
        BodyDTO body = BodyDTO.createDTO(exact("body"));
        List<CookieDTO> cookies = Arrays.asList(new CookieDTO(new Cookie("name", "value")));
        List<HeaderDTO> headers = Arrays.asList(new HeaderDTO(new Header("name", "value")));
        String method = "METHOD";
        String path = "path";
        List<ParameterDTO> queryStringParameters = Arrays.asList(new ParameterDTO(new Parameter("name", "value")));
        String url = "url";
        HttpRequest httpRequest = new HttpRequest()
                .withBody("body")
                .withCookies(new Cookie("name", "value"))
                .withHeaders(new Header("name", "value"))
                .withMethod(method)
                .withPath(path)
                .withQueryStringParameter(new Parameter("name", "value"))
                .withURL(url);
View Full Code Here

    @Test
    public void shouldBuildObject() {
        // given
        String body = "body";
        Cookie cookie = new Cookie("name", "value");
        Header header = new Header("name", "value");
        String method = "METHOD";
        String path = "path";
        Parameter parameter = new Parameter("name", "value");
        String url = "url";
View Full Code Here

    @Test
    public void shouldReturnValueSetInConstructor() {
        // given
        BodyDTO body = BodyDTO.createDTO(exact("body"));
        List<CookieDTO> cookies = Arrays.asList(new CookieDTO(new Cookie("name", "value")));
        List<HeaderDTO> headers = Arrays.asList(new HeaderDTO(new Header("name", "value")));
        Integer statusCode = 200;
        HttpResponse httpRequest = new HttpResponse()
                .withBody("body")
                .withCookies(new Cookie("name", "value"))
                .withHeaders(new Header("name", "value"))
                .withStatusCode(statusCode);

        // when
        HttpResponseDTO httpRequestDTO = new HttpResponseDTO(httpRequest);
View Full Code Here

    @Test
    public void shouldBuildObject() {
        // given
        String body = "body";
        Cookie cookie = new Cookie("name", "value");
        Header header = new Header("name", "value");
        Integer statusCode = 200;
        HttpResponse httpRequest = new HttpResponse()
                .withBody(body)
                .withCookies(cookie)
View Full Code Here

        assertFalse(new HttpResponseMatcher(new HttpResponse().withHeaders(new Header("name", "[0-9]{0,100}"))).matches(new HttpResponse().withHeaders(new Header("name", "value1"))));
    }

    @Test
    public void matchesMatchingCookies() {
        assertTrue(new HttpResponseMatcher(new HttpResponse().withCookies(new Cookie("name", "value"))).matches(new HttpResponse().withCookies(new Cookie("name", "value"))));
    }
View Full Code Here

        assertTrue(new HttpResponseMatcher(new HttpResponse().withCookies(new Cookie("name", "value"))).matches(new HttpResponse().withCookies(new Cookie("name", "value"))));
    }

    @Test
    public void matchesMatchingCookiesWithRegex() {
        assertTrue(new HttpResponseMatcher(new HttpResponse().withCookies(new Cookie("name", "[a-z]{0,20}lue"))).matches(new HttpResponse().withCookies(new Cookie("name", "value"))));
    }
View Full Code Here

TOP

Related Classes of org.mockserver.model.Cookie

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.