Package org.mockserver.model

Examples of org.mockserver.model.HttpRequest


    }

    @Test
    public void shouldDumpAllToLogAsJSONIfMatchAll() {
        // when
        logFilter.dumpToLog(new HttpRequest(), false);

        // then
        verify(logger).warn(new ExpectationSerializer().serialize(new Expectation(httpRequest, Times.once()).thenRespond(httpResponseOne)));
        verify(logger).warn(new ExpectationSerializer().serialize(new Expectation(httpRequest, Times.once()).thenRespond(httpResponseThree)));
        verify(logger).warn(new ExpectationSerializer().serialize(new Expectation(otherHttpRequest, Times.once()).thenRespond(httpResponseTwo)));
View Full Code Here


    }

    @Test
    public void shouldDumpAllToLogAsJavaIfMatchAll() {
        // when
        logFilter.dumpToLog(new HttpRequest(), true);

        // then
        verify(logger).warn(new ExpectationSerializer().serializeAsJava(new Expectation(httpRequest, Times.once()).thenRespond(httpResponseOne)));
        verify(logger).warn(new ExpectationSerializer().serializeAsJava(new Expectation(httpRequest, Times.once()).thenRespond(httpResponseThree)));
        verify(logger).warn(new ExpectationSerializer().serializeAsJava(new Expectation(otherHttpRequest, Times.once()).thenRespond(httpResponseTwo)));
View Full Code Here

    }

    @Test
    public void shouldDumpOnlyMatchingToLogAsJSON() {
        // when
        logFilter.dumpToLog(new HttpRequest().withPath("some_path"), false);

        // then
        verify(logger).warn(new ExpectationSerializer().serialize(new Expectation(httpRequest, Times.once()).thenRespond(httpResponseOne)));
        verify(logger).warn(new ExpectationSerializer().serialize(new Expectation(httpRequest, Times.once()).thenRespond(httpResponseThree)));
        verifyNoMoreInteractions(logger);

        // when
        logFilter.dumpToLog(new HttpRequest().withPath("some_other_path"), false);

        // then
        verify(logger).warn(new ExpectationSerializer().serialize(new Expectation(otherHttpRequest, Times.once()).thenRespond(httpResponseTwo)));
        verifyNoMoreInteractions(logger);
    }
View Full Code Here

    }

    @Test
    public void shouldDumpOnlyMatchingToLogAsJava() {
        // when
        logFilter.dumpToLog(new HttpRequest().withPath("some_path"), true);

        // then
        verify(logger).warn(new ExpectationSerializer().serializeAsJava(new Expectation(httpRequest, Times.once()).thenRespond(httpResponseOne)));
        verify(logger).warn(new ExpectationSerializer().serializeAsJava(new Expectation(httpRequest, Times.once()).thenRespond(httpResponseThree)));
        verifyNoMoreInteractions(logger);

        // when
        logFilter.dumpToLog(new HttpRequest().withPath("some_other_path"), true);

        // then
        verify(logger).warn(new ExpectationSerializer().serializeAsJava(new Expectation(otherHttpRequest, Times.once()).thenRespond(httpResponseTwo)));
        verifyNoMoreInteractions(logger);
    }
View Full Code Here

public class HopByHopHeaderFilterTest {

    @Test
    public void shouldNotForwardHopByHopHeaders() throws Exception {
        // given
        HttpRequest httpRequest = new HttpRequest();
        httpRequest.withHeaders(
                new Header("some_other_header"),
                new Header("proxy-connection"),
                new Header("connection"),
                new Header("keep-alive"),
                new Header("transfer-encoding"),
                new Header("te"),
                new Header("trailer"),
                new Header("proxy-authorization"),
                new Header("proxy-authenticate"),
                new Header("upgrade")
        );

        // when
        new HopByHopHeaderFilter().onRequest(httpRequest);

        // then
        assertEquals(httpRequest.getHeaders().size(), 1);
    }
View Full Code Here

    }

    @Test
    public void shouldMapGETRequest() throws Exception {
        // when
        apacheHttpClient.sendRequest(new HttpRequest().withMethod("GET").withURL("http://localhost"), false);

        // then
        Assert.assertEquals(HttpGet.class, requestArgumentCaptor.getValue().getClass());
    }
View Full Code Here

    }

    @Test
    public void shouldMapDELETERequest() throws Exception {
        // when
        apacheHttpClient.sendRequest(new HttpRequest().withMethod("DELETE").withURL("http://localhost"), false);

        // then
        Assert.assertEquals(HttpDelete.class, requestArgumentCaptor.getValue().getClass());
    }
View Full Code Here

    }

    @Test
    public void shouldMapHEADRequest() throws Exception {
        // when
        apacheHttpClient.sendRequest(new HttpRequest().withMethod("HEAD").withURL("http://localhost"), false);

        // then
        Assert.assertEquals(HttpHead.class, requestArgumentCaptor.getValue().getClass());
    }
View Full Code Here

    }

    @Test
    public void shouldMapOPTIONSRequest() throws Exception {
        // when
        apacheHttpClient.sendRequest(new HttpRequest().withMethod("OPTIONS").withURL("http://localhost"), false);

        // then
        Assert.assertEquals(HttpOptions.class, requestArgumentCaptor.getValue().getClass());
    }
View Full Code Here

    }

    @Test
    public void shouldMapPOSTRequest() throws Exception {
        // when
        apacheHttpClient.sendRequest(new HttpRequest().withMethod("POST").withURL("http://localhost"), false);

        // then
        Assert.assertEquals(HttpPost.class, requestArgumentCaptor.getValue().getClass());
    }
View Full Code Here

TOP

Related Classes of org.mockserver.model.HttpRequest

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.