Package com.github.restdriver.clientdriver

Examples of com.github.restdriver.clientdriver.ClientDriverResponse


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


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

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

    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

    }
   
    @Test
    public void testWithSpecifiedProxyPassesIfProxyIsAvailable() {
        startLocalProxy();
        driver.addExpectation(new ClientDriverRequest("/foo"), new ClientDriverResponse("Content", "text/plain"));
        get(driver.getBaseUrl() + "/foo", usingProxy("localhost", proxyPort));
        assertThat(proxyHits, is(1));
        stopLocalProxy();
    }
View Full Code Here

        stopLocalProxy();
    }
   
    @Test
    public void testWithNoProxyDoesntTryToUseAProxy() {
        driver.addExpectation(new ClientDriverRequest("/foo"), new ClientDriverResponse("Content", "text/plain"));
        get(driver.getBaseUrl() + "/foo", notUsingProxy());
        assertThat(proxyHits, is(0));
    }
View Full Code Here

        assertThat(proxyHits, is(0));
    }
   
    @Test
    public void whenMultipleProxiesAreSpecifiedLastOneWinsNoProxy() {
        driver.addExpectation(new ClientDriverRequest("/foo"), new ClientDriverResponse("Content", "text/plain"));
        get(driver.getBaseUrl() + "/foo", usingProxy("localhost", ClientDriver.getFreePort()), notUsingProxy());
        assertThat(proxyHits, is(0));
    }
View Full Code Here

    }
   
    @Test
    public void whenMultipleProxiesAreSpecifiedLastOneWinsWithProxy() {
        startLocalProxy();
        driver.addExpectation(new ClientDriverRequest("/foo"), new ClientDriverResponse("Content", "text/plain"));
        get(driver.getBaseUrl() + "/foo", notUsingProxy(), usingProxy("localhost", proxyPort));
        stopLocalProxy();
        assertThat(proxyHits, is(1));
    }
View Full Code Here

    }
   
    @Test
    public void twoCallsWithOnlyOneProxiedOnlyUsesProxyOnce() {
       
        driver.addExpectation(new ClientDriverRequest("/foo"), new ClientDriverResponse("Content", "text/plain"));
        driver.addExpectation(new ClientDriverRequest("/foo"), new ClientDriverResponse("Content", "text/plain"));
        driver.addExpectation(new ClientDriverRequest("/foo"), new ClientDriverResponse("Content", "text/plain"));
        startLocalProxy();
       
        get(driver.getBaseUrl() + "/foo");
        assertThat(proxyHits, is(0));
       
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.