Examples of ClientDriverResponse


Examples of com.github.restdriver.clientdriver.ClientDriverResponse

        assertThat(response.getContentAsBytes(), is(("some text").getBytes()));
    }
   
    @Test
    public void creatingResponseWithInputStreamReturnsCorrectByteArrayWhenFetchingContent() {
        ClientDriverResponse response = new ClientDriverResponse(IOUtils.toInputStream("some text"), "application/octet-stream");
       
        assertThat(response.getContentAsBytes(), is(("some text").getBytes()));
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverResponse

    }
   
    @Test
    public void creatingEmptyResponseHasNullByteArrayWhenFetchingContent() {
       
        assertThat(new ClientDriverResponse().getContentAsBytes(), is(nullValue()));
        assertThat(new ClientDriverResponse((String) null, null).getContentAsBytes(), is(nullValue()));
        assertThat(new ClientDriverResponse("", null).getContentAsBytes(), is(nullValue()));
        assertThat(new ClientDriverResponse((InputStream) null, null).getContentAsBytes(), is(nullValue()));
        assertThat(new ClientDriverResponse(IOUtils.toInputStream(""), null).getContentAsBytes(), is(nullValue()));
       
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverResponse

        thrown.expectMessage("unable to create client driver response");
       
        InputStream mockInputStream = mock(InputStream.class);
        when(mockInputStream.read((byte[]) anyObject())).thenThrow(new IOException("exception reading stream"));
       
        new ClientDriverResponse(mockInputStream, "application/octet-stream");
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverResponse

    }
   
    @SuppressWarnings("deprecation")
    @Test
    public void usingHeaderCanOverrideContentType() {
        ClientDriverResponse response = new ClientDriverResponse("hello").withContentType("text/plain");
       
        assertThat(response.getContentType(), is("text/plain"));
       
        response.withHeader("Content-Type", "text/xml");
       
        assertThat(response.getContentType(), is("text/xml"));
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverResponse

    }
   
    @SuppressWarnings("deprecation")
    @Test
    public void usingHeaderCanOverrideContentTypeIgnoringCase() {
        ClientDriverResponse response = new ClientDriverResponse("hello").withContentType("text/plain");
       
        assertThat(response.getContentType(), is("text/plain"));
       
        response.withHeader("content-type", "text/xml");
       
        assertThat(response.getContentType(), is("text/xml"));
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverResponse

        baseUrl = driver.getBaseUrl();
    }
   
    @Test
    public void testToStringWithoutResponseBody() {
        driver.addExpectation(new ClientDriverRequest("/"), new ClientDriverResponse("", null).withStatus(400));
       
        Response response = get(baseUrl);
       
        assertThat(response.toString(), containsString("HTTP/1.1 400 Bad Request"));
        assertThat(response.toString(), containsString("Content-Length: 0"));
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverResponse

       
    }
   
    @Test
    public void testToStringWithResponseBody() {
        driver.addExpectation(new ClientDriverRequest("/"), new ClientDriverResponse("This is the content", "text/plain"));
       
        Response response = get(baseUrl);
       
        assertThat(response.toString(), containsString("HTTP/1.1 200 OK"));
        assertThat(response.toString(), containsString("Content-Type: text/plain"));
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverResponse

        assertThat(response.getContentType(), is("text/xml"));
    }
   
    @Test
    public void usingStatusCodeOverridesDefaultStatusCode() {
        ClientDriverResponse response = new ClientDriverResponse().withStatus(201);
       
        assertThat(response.getStatus(), is(201));
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverResponse

        assertThat(response.getStatus(), is(201));
    }
   
    @Test
    public void customHeadersCanBeSet() {
        ClientDriverResponse response = new ClientDriverResponse();
       
        response.withHeader("Server", "server-name");
       
        assertThat(response.getHeaders(), hasEntry("Server", "server-name"));
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverResponse

    private String baseUrl;
   
    @Before
    public void getServerDetails() {
        baseUrl = driver.getBaseUrl();
        driver.addExpectation(new ClientDriverRequest("/"), new ClientDriverResponse("NOT YET...", "text/plain"));
        driver.addExpectation(new ClientDriverRequest("/"), new ClientDriverResponse("NOT YET...", "text/plain"));
        driver.addExpectation(new ClientDriverRequest("/"), new ClientDriverResponse("NOW!", "text/plain"));
    }
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.