Examples of ClientDriverRequest


Examples of com.github.restdriver.clientdriver.ClientDriverRequest

    }
   
    @Test
    public void postEmptyBody() {
        driver.addExpectation(
                new ClientDriverRequest("/").withMethod(ClientDriverRequest.Method.POST),
                new ClientDriverResponse("Content", "text/plain"));
       
        Response response = post(baseUrl);
       
        assertThat(response, hasStatusCode(200));
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverRequest

    }
   
    @Test
    public void postWithTextPlainBody() {
        driver.addExpectation(
                new ClientDriverRequest("/").withMethod(ClientDriverRequest.Method.POST).withBody("Your body", "text/plain"),
                new ClientDriverResponse("Back at you", "text/plain").withStatus(202));
       
        Response response = post(baseUrl, body("Your body", "text/plain"));
       
        assertThat(response, hasStatusCode(202));
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverRequest

    }
   
    @Test
    public void postWithApplicationXmlBody() {
        driver.addExpectation(
                new ClientDriverRequest("/")
                        .withMethod(ClientDriverRequest.Method.POST)
                        .withBody("<yo/>", "application/xml"),
                new ClientDriverResponse("Back at you", "text/plain").withStatus(202));
       
        Response response = post(baseUrl, body("<yo/>", "application/xml"));
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverRequest

    }
   
    @Test
    public void postWithApplicationJsonBodyAndHeaders() {
        driver.addExpectation(
                new ClientDriverRequest("/jsons")
                        .withMethod(ClientDriverRequest.Method.POST)
                        .withBody("<yo/>", "application/xml")
                        .withHeader("Accept", "Nothing"),
                new ClientDriverResponse("Back at you", "text/plain").withStatus(202));
       
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverRequest

    }
   
    @Test
    public void postWithDuplicateBodyUsesLastOne() {
        driver.addExpectation(
                new ClientDriverRequest("/xml")
                        .withMethod(ClientDriverRequest.Method.POST)
                        .withBody("<yo/>", "application/xml"),
                new ClientDriverResponse("Back at you", "text/plain").withStatus(202));
       
        Response response = post(baseUrl + "/xml", body("{}", "application/json"), body("<yo/>", "application/xml"));
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverRequest

    }
   
    @Test
    public void postWithByteArrayBody() {
        driver.addExpectation(
                new ClientDriverRequest("/bytes")
                        .withMethod(ClientDriverRequest.Method.POST)
                        .withBody("some bytes", "application/pdf"),
                new ClientDriverResponse("The response", "text/plain").withStatus(418));
       
        Response response = post(baseUrl + "/bytes", body("some bytes".getBytes(), "application/pdf"));
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverRequest

   
    @Test
    public void testMatchNoParams() {
       
        RealRequest real = mockRealRequest("aaaaa", Method.GET, headers, params, content, contentType);
        ClientDriverRequest expected = new ClientDriverRequest("aaaaa").withMethod(Method.GET);
       
        assertThat(sut.isMatch(real, expected), is(true));
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverRequest

   
    @Test
    public void testMatchNoParamsPattern() {
       
        RealRequest real = mockRealRequest("aaaaa", Method.GET, headers, params, content, contentType);
        ClientDriverRequest expected = new ClientDriverRequest(Pattern.compile("[a]{5}")).withMethod(Method.GET);
       
        assertThat(sut.isMatch(real, expected), is(true));
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverRequest

    public ExpectedException thrown = ExpectedException.none();
   
    @Test
    public void testWithSpecifiedProxyFailsIfProxyIsNotAvailable() {
        thrown.expect(RuntimeHttpHostConnectException.class);
        driver.addExpectation(new ClientDriverRequest("/foo"), new ClientDriverResponse("Content", "text/plain"));
        get(driver.getBaseUrl() + "/foo", usingProxy("localhost", ClientDriver.getFreePort()));
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverRequest

    public void testMatchWithParams() {
       
        params = asMap("kk", "vv", "k2", "v2");
       
        RealRequest real = mockRealRequest("aaaaa", Method.GET, headers, params, content, contentType);
        ClientDriverRequest expected = new ClientDriverRequest("aaaaa")
                .withMethod(Method.GET)
                .withParam("kk", "vv")
                .withParam("k2", "v2");
       
        assertThat(sut.isMatch(real, expected), is(true));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.