Package com.github.restdriver.clientdriver

Examples of com.github.restdriver.clientdriver.ClientDriverResponse


        ClientDriverRequestResponsePair matchingPair = getMatchingRequestPair(request);
       
        if (matchingPair != null) {
            matchedResponses.add(matchingPair);
           
            ClientDriverResponse matchedResponse = matchingPair.getResponse();
           
            response.setContentType(matchedResponse.getContentType());
            response.setStatus(matchedResponse.getStatus());
            response.setHeader("Server", "rest-client-driver(" + RestDriverProperties.getVersion() + ")");
           
            for (Entry<String, String> thisHeader : matchedResponse.getHeaders().entrySet()) {
                response.setHeader(thisHeader.getKey(), thisHeader.getValue());
            }
           
            if (matchedResponse.hasBody()) {
                OutputStream output = response.getOutputStream();
                output.write(matchedResponse.getContentAsBytes());
            }
           
            delayIfNecessary(matchingPair.getResponse());
        } else {
            response.setStatus(404);
View Full Code Here


               
                if (expectation.shouldMatchAnyTimes()) {
                    continue;
                }
               
                ClientDriverResponse response = expectation.getPair().getResponse();
               
                if (response.canExpire() && response.hasNotExpired()) {
                    period = DEFAULT_WAIT_INTERVAL;
                    break;
                }
               
                failedExpectations.add(expectation);
View Full Code Here

   
    @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));
        assertThat(response.getContent(), is("Content"));
View Full Code Here

   
    @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));
        assertThat(response.getContent(), is("Back at you"));
View Full Code Here

    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"));
       
        assertThat(response, hasStatusCode(202));
        assertThat(response.getContent(), is("Back at you"));
View Full Code Here

        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));
       
        Response response = put(baseUrl + "/jsons", body("<yo/>", "application/xml"), header("Accept", "Nothing"));
       
        assertThat(response, hasStatusCode(202));
        assertThat(response.getContent(), is("Back at you"));
View Full Code Here

    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"));
       
        assertThat(response, hasStatusCode(202));
        assertThat(response.getContent(), is("Back at you"));
View Full Code Here

    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"));
       
        assertThat(response, hasStatusCode(418));
        assertThat(response.getContent(), is("The response"));
View Full Code Here

   
    @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));
        assertThat(response.getContent(), is("Content"));
View Full Code Here

   
    @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));
        assertThat(response.getContent(), is("Back at you"));
View Full Code Here

TOP

Related Classes of com.github.restdriver.clientdriver.ClientDriverResponse

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.