Package org.mockserver.model

Examples of org.mockserver.model.Cookie


        assertTrue(new HttpResponseMatcher(new HttpResponse().withCookies(new Cookie("name", "[a-z]{0,20}lue"))).matches(new HttpResponse().withCookies(new Cookie("name", "value"))));
    }

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


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

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

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

    @Test
    public void doesNotMatchIncorrectCookieValueRegex() {
        assertFalse(new HttpResponseMatcher(new HttpResponse().withCookies(new Cookie("name", "[A-Z]{0,10}"))).matches(new HttpResponse().withCookies(new Cookie("name", "value1"))));
    }
View Full Code Here

                        "}",
                new HttpResponseMatcher(
                        response()
                                .withBody("some_body")
                                .withHeaders(new Header("name", "value"))
                                .withCookies(new Cookie("name", "[A-Z]{0,10}"))
                ).toString()
        );
    }
View Full Code Here

                        "}",
                new HttpResponseMatcher(
                        response()
                                .withBody(json("{ \"key\": \"some_value\" }"))
                                .withHeaders(new Header("name", "value"))
                                .withCookies(new Cookie("name", "[A-Z]{0,10}"))
                ).toString()
        );
    }
View Full Code Here

    }

    @Test
    public void respondWhenPathMatchesAlwaysReturnFirstMatching() {
        // when
        mockServerMatcher.when(new HttpRequest().withPath("somepath").withCookies(new Cookie("name", "value"))).thenRespond(httpResponse[0].withBody("somebody1"));
        mockServerMatcher.when(new HttpRequest().withPath("somepath")).thenRespond(httpResponse[1].withBody("somebody2"));

        // then
        assertEquals(httpResponse[1], mockServerMatcher.handle(new HttpRequest().withPath("somepath")));
        assertEquals(httpResponse[1], mockServerMatcher.handle(new HttpRequest().withPath("somepath")));
View Full Code Here

    }

    @Test
    public void respondWhenPathMatchesReturnFirstMatchingWithRemainingTimes() {
        // when
        mockServerMatcher.when(new HttpRequest().withPath("somepath").withCookies(new Cookie("name", "value")), Times.once()).thenRespond(httpResponse[0].withBody("somebody1"));
        mockServerMatcher.when(new HttpRequest().withPath("somepath")).thenRespond(httpResponse[1].withBody("somebody2"));

        // then
        assertEquals(httpResponse[0], mockServerMatcher.handle(new HttpRequest().withPath("somepath").withCookies(new Cookie("name", "value"))));
        assertEquals(httpResponse[1], mockServerMatcher.handle(new HttpRequest().withPath("somepath").withCookies(new Cookie("name", "value"))));
    }
View Full Code Here

        // - an HttpResponse
        HttpResponse httpResponse = new HttpResponse();
        httpResponse.withStatusCode(HttpStatusCode.OK_200.code());
        httpResponse.withBody("somebody");
        httpResponse.withHeaders(new Header("headerName1", "headerValue1"), new Header("headerName2", "headerValue2"));
        httpResponse.withCookies(new Cookie("cookieName1", "cookieValue1"), new Cookie("cookieName2", "cookieValue2"));
        // - an HttpServletResponse
        MockHttpServletResponse httpServletResponse = new MockHttpServletResponse();

        // when
        new MockServerToHttpServletResponseMapper().mapMockServerResponseToHttpServletResponse(httpResponse, httpServletResponse);
View Full Code Here

        // - an HttpResponse
        HttpResponse httpResponse = new HttpResponse();
        httpResponse.withStatusCode(HttpStatusCode.OK_200.code());
        httpResponse.withBody("somebody");
        httpResponse.withHeaders(new Header("headerName1", "headerValue1"), new Header("headerName2", "headerValue2"));
        httpResponse.withCookies(new Cookie("cookieName1", "cookieValue1"), new Cookie("cookieName2", "cookieValue2"));
        // - an HttpServletResponse
        HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
        when(httpServletResponse.getOutputStream()).thenThrow(new IOException("TEST EXCEPTION"));

        // when
View Full Code Here

        // - an HttpResponse
        HttpResponse httpResponse = new HttpResponse();
        httpResponse.withStatusCode(HttpStatusCode.OK_200.code());
        httpResponse.withBody("somebody");
        httpResponse.withHeaders(new Header("headerName1", "headerValue1"), new Header("headerName2", "headerValue2_1", "headerValue2_2"));
        httpResponse.withCookies(new Cookie("cookieName1", "cookieValue1"), new Cookie("cookieName2", "cookieValue2"));

        // when
        DefaultFullHttpResponse defaultFullHttpResponse = new MockServerToNettyResponseMapper().mapMockServerResponseToNettyResponse(httpResponse);

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