Examples of ClientDriverRequest


Examples of com.github.restdriver.clientdriver.ClientDriverRequest

    }
   
    @Test
    public void moreComplexJsonPathCanBeRunOverJsonResponse() throws ParseException {
        String jsonContent = makeJson(" { 'thing' : { 'sub' : { 'subsub' : 'valutron' } } } ");
        driver.addExpectation(new ClientDriverRequest("/"), new ClientDriverResponse(jsonContent, "application/json"));
        Response response = get(baseUrl);
       
        assertThat(response.asJson(), hasJsonPath("$..subsub", hasItem(equalTo("valutron"))));
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverRequest

               
                " { 'things' : " +
                        "[ { 'a': 'one', 'c' : 100 } , " +
                        "  { 'a': 'two', 'c' : 150 } ] } ");
       
        driver.addExpectation(new ClientDriverRequest("/"), new ClientDriverResponse(jsonContent, "application/json"));
        Response response = get(baseUrl);
       
        assertThat(response.asJson(), hasJsonPath("$.things[?(@.c > 125)].a", hasItem(equalTo("two"))));
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverRequest

   
    @Test
    public void jsonPathWithoutMatcher() {
        String jsonContent = makeJson("{'this':'thing','that':3}");
       
        driver.addExpectation(new ClientDriverRequest("/"), new ClientDriverResponse(jsonContent, "application/json"));
        Response response = get(baseUrl);
       
        assertThat(response.asJson(), hasJsonPath("$.that"));
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverRequest

        }
    }
   
    private void captureBodyIfRequired(HttpRealRequest realRequest,
            ClientDriverExpectation matchedExpectation) {
        ClientDriverRequest request = matchedExpectation.getPair().getRequest();
        if (request.getBodyCapture() != null) {
            request.getBodyCapture().setBody(realRequest.getBodyContent());
        }
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverRequest

    }
   
    @Test
    public void postEmptyBody() {
        driver.addExpectation(
                new ClientDriverRequest("/").withMethod(ClientDriverRequest.Method.PUT),
                new ClientDriverResponse("Content", "text/plain"));
       
        Response response = put(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.PUT).withBody("Your body", "text/plain"),
                new ClientDriverResponse("Back at you", "text/plain").withStatus(202));
       
        Response response = put(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.PUT)
                        .withBody("<yo/>", "application/xml"),
                new ClientDriverResponse("Back at you", "text/plain").withStatus(202));
       
        Response response = put(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.PUT)
                        .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 putWithDuplicateBodyUsesLastOne() {
        driver.addExpectation(
                new ClientDriverRequest("/xml")
                        .withMethod(ClientDriverRequest.Method.PUT)
                        .withBody("<yo/>", "application/xml"),
                new ClientDriverResponse("Back at you", "text/plain").withStatus(202));
       
        Response response = put(baseUrl + "/xml", body("{}", "application/json"), body("<yo/>", "application/xml"));
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverRequest

    }
   
    @Test
    public void putWithByteArrayBody() {
        driver.addExpectation(
                new ClientDriverRequest("/bytes")
                        .withMethod(ClientDriverRequest.Method.PUT)
                        .withBody("some bytes", "application/pdf"),
                new ClientDriverResponse("The response", "text/plain").withStatus(418));
       
        Response response = put(baseUrl + "/bytes", body("some bytes".getBytes(), "application/pdf"));
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.