Package org.mockserver.model

Examples of org.mockserver.model.HttpResponse


    private HttpResponse[] httpResponse;

    @Before
    public void prepareTestFixture() {
        httpResponse = new HttpResponse[]{
                new HttpResponse(),
                new HttpResponse()
        };

        mockServerMatcher = new MockServerMatcher();
    }
View Full Code Here


    @Test
    public void shouldConstructAndGetFields() {
        // given
        HttpRequest httpRequest = new HttpRequest();
        HttpResponse httpResponse = new HttpResponse();
        HttpForward httpForward = new HttpForward();
        HttpCallback httpCallback = new HttpCallback();
        Times times = Times.exactly(3);

        // when
View Full Code Here

    @Test(expected = IllegalArgumentException.class)
    public void shouldPreventForwardAfterResponse() {
        // given
        HttpRequest httpRequest = new HttpRequest();
        HttpResponse httpResponse = new HttpResponse();
        HttpForward httpForward = new HttpForward();

        // then
        new Expectation(httpRequest, Times.once()).thenRespond(httpResponse).thenForward(httpForward);
    }
View Full Code Here

    @Test(expected = IllegalArgumentException.class)
    public void shouldPreventResponseAfterForward() {
        // given
        HttpRequest httpRequest = new HttpRequest();
        HttpResponse httpResponse = new HttpResponse();
        HttpForward httpForward = new HttpForward();

        // then
        new Expectation(httpRequest, Times.once()).thenForward(httpForward).thenRespond(httpResponse);
    }
View Full Code Here

    @Test(expected = IllegalArgumentException.class)
    public void shouldPreventResponseAfterCallback() {
        // given
        HttpRequest httpRequest = new HttpRequest();
        HttpCallback httpCallback = new HttpCallback();
        HttpResponse httpResponse = new HttpResponse();

        // then
        new Expectation(httpRequest, Times.once()).thenCallback(httpCallback).thenRespond(httpResponse);
    }
View Full Code Here

    @Test(expected = IllegalArgumentException.class)
    public void shouldPreventCallbackAfterForward() {
        // given
        HttpRequest httpRequest = new HttpRequest();
        HttpResponse httpResponse = new HttpResponse();
        HttpCallback httpCallback = new HttpCallback();

        // then
        new Expectation(httpRequest, Times.once()).thenCallback(httpCallback).thenRespond(httpResponse);
    }
View Full Code Here

                .when(
                        new HttpRequest()
                                .withPath("some_path")
                )
                .thenRespond(
                        new HttpResponse()
                                .withBody("some_response_body")
                );
        mockServerMatcher
                .when(
                        new HttpRequest()
                                .withPath("some_other_path")
                )
                .thenRespond(
                        new HttpResponse()
                                .withBody("some_other_response_body")
                );

        // when
        mockServerMatcher.dumpToLog(null);
View Full Code Here

                .when(
                        new HttpRequest()
                                .withPath("some_path")
                )
                .thenRespond(
                        new HttpResponse()
                                .withBody("some_response_body")
                );
        mockServerMatcher
                .when(
                        new HttpRequest()
                                .withPath("some_other_path")
                )
                .thenRespond(
                        new HttpResponse()
                                .withBody("some_other_response_body")
                );

        // when
        mockServerMatcher.dumpToLog(new HttpRequest().withPath("some_path"));
View Full Code Here

                )
                .callback(
                        callback()
                                .withCallbackClass("org.mockserver.server.TestClasspathTestExpectationCallback")
                );
        TestClasspathTestExpectationCallback.httpResponse = new HttpResponse()
                .withStatusCode(HttpStatusCode.ACCEPTED_202.code())
                .withHeaders(
                        new Header("x-callback", "test_callback_header")
                )
                .withBody("a_callback_response");

        // then
        // - in http
        HttpResponse actual = makeRequest(
                new HttpRequest()
                        .withURL("http://localhost:" + getMockServerPort() + "/" + servletContext + (servletContext.length() > 0 && !servletContext.endsWith("/") ? "/" : "") + "callback")
                        .withMethod("POST")
                        .withHeaders(
                                new Header("X-Test", "test_headers_and_body"),
View Full Code Here

    @Test
    public void shouldMapHttpResponseToHttpServletResponse() throws UnsupportedEncodingException {
        // given
        // - 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

TOP

Related Classes of org.mockserver.model.HttpResponse

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.