Package org.mockserver.model

Examples of org.mockserver.model.HttpResponse


        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


        // additional mock objects
        mockHttpServletRequest = new MockHttpServletRequest();
        mockHttpServletResponse = new MockHttpServletResponse();
        httpRequest = new HttpRequest().withPath("some_path");
        httpResponse = new HttpResponse();

        // mappers
        when(mockHttpServletToMockServerRequestMapper.mapHttpServletRequestToMockServerRequest(any(MockHttpServletRequest.class))).thenReturn(httpRequest);
        httpRequestArgumentCaptor = ArgumentCaptor.forClass(HttpRequest.class);
        when(mockApacheHttpClient.sendRequest(httpRequestArgumentCaptor.capture(), eq(false))).thenReturn(httpResponse);
View Full Code Here

    @Test
    public void shouldApplyFiltersBeforeAndAfterRequest() throws Exception {
        // given
        // - add first filter
        ProxyResponseFilter filter = mock(ProxyResponseFilter.class);
        when(filter.onResponse(any(HttpRequest.class), any(HttpResponse.class))).thenReturn(new HttpResponse());
        proxyServlet.withFilter(httpRequest, filter);
        // - add first filter with other request
        HttpRequest someOtherRequest = new HttpRequest().withPath("some_other_path");
        proxyServlet.withFilter(someOtherRequest, filter);
        // - add second filter
View Full Code Here

    }

    @Test
    public void shouldClearAllExpectations() {
        // given
        HttpResponse httpResponse = new HttpResponse().withBody("somebody");
        mockServerMatcher.when(new HttpRequest().withPath("somepath"), Times.unlimited()).thenRespond(httpResponse);
        mockServerMatcher.when(new HttpRequest().withPath("somepath"), Times.unlimited()).thenRespond(httpResponse);

        // when
        mockServerMatcher.clear(new HttpRequest().withPath("somepath"));
View Full Code Here

    }

    @Test
    public void shouldResetAllExpectationsWhenHttpRequestNull() {
        // given
        HttpResponse httpResponse = new HttpResponse().withBody("somebody");
        mockServerMatcher.when(new HttpRequest().withPath("somepath"), Times.unlimited()).thenRespond(httpResponse);
        mockServerMatcher.when(new HttpRequest().withPath("somepath"), Times.unlimited()).thenRespond(httpResponse);

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

    }

    @Test
    public void shouldResetAllExpectations() {
        // given
        HttpResponse httpResponse = new HttpResponse().withBody("somebody");
        mockServerMatcher.when(new HttpRequest().withPath("somepath"), Times.unlimited()).thenRespond(httpResponse);
        mockServerMatcher.when(new HttpRequest().withPath("somepath"), Times.unlimited()).thenRespond(httpResponse);

        // when
        mockServerMatcher.reset();
View Full Code Here

    }

    @Test
    public void shouldClearMatchingExpectationsByPathOnly() {
        // given
        HttpResponse httpResponse = new HttpResponse().withBody("somebody");
        mockServerMatcher.when(new HttpRequest().withPath("abc"), Times.unlimited()).thenRespond(httpResponse);
        Expectation expectation = mockServerMatcher.when(new HttpRequest().withPath("def"), Times.unlimited()).thenRespond(httpResponse);

        // when
        mockServerMatcher.clear(new HttpRequest().withPath("abc"));
View Full Code Here

    }

    @Test
    public void shouldClearMatchingExpectationsByMethodOnly() {
        // given
        HttpResponse httpResponse = new HttpResponse().withBody("somebody");
        mockServerMatcher.when(new HttpRequest().withMethod("GET").withPath("abc"), Times.unlimited()).thenRespond(httpResponse);
        mockServerMatcher.when(new HttpRequest().withMethod("GET").withPath("def"), Times.unlimited()).thenRespond(httpResponse);
        Expectation expectation = mockServerMatcher.when(new HttpRequest().withMethod("POST").withPath("def"), Times.unlimited()).thenRespond(httpResponse);

        // when
View Full Code Here

    }

    @Test
    public void shouldClearMatchingExpectationsByHeaderOnly() {
        // given
        HttpResponse httpResponse = new HttpResponse().withBody("somebody");
        mockServerMatcher.when(new HttpRequest().withMethod("GET").withPath("abc").withHeader(new Header("headerOneName", "headerOneValue")), Times.unlimited()).thenRespond(httpResponse);
        mockServerMatcher.when(new HttpRequest().withMethod("PUT").withPath("def").withHeaders(new Header("headerOneName", "headerOneValue")), Times.unlimited()).thenRespond(httpResponse);
        Expectation expectation = mockServerMatcher.when(new HttpRequest().withMethod("POST").withPath("def"), Times.unlimited()).thenRespond(httpResponse);

        // when
View Full Code Here

    }

    @Test
    public void shouldClearNoExpectations() {
        // given
        HttpResponse httpResponse = new HttpResponse().withBody("somebody");
        Expectation[] expectations = new Expectation[]{
                mockServerMatcher.when(new HttpRequest().withPath("somepath"), Times.unlimited()).thenRespond(httpResponse),
                mockServerMatcher.when(new HttpRequest().withPath("somepath"), Times.unlimited()).thenRespond(httpResponse)
        };
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.