Package com.github.restdriver.clientdriver

Examples of com.github.restdriver.clientdriver.ClientDriverRequest


    public void testMatchWrongWithRequestHeaderString() throws Exception {
       
        headers.put("Cache-Control", "cache-please!");
       
        RealRequest real = mockRealRequest("aaaaa", Method.GET, headers, params, content, contentType);
        ClientDriverRequest expected = new ClientDriverRequest("aaaaa").withMethod(Method.GET).withHeader("Cache-Control", "no-cache");
       
        assertThat(sut.isMatch(real, expected), is(false));
    }
View Full Code Here


    public void testMatchWrongWithMissingRequestHeaderString() throws Exception {
       
        headers.put("Another-Header", "no-cache");
       
        RealRequest real = mockRealRequest("aaaaa", Method.GET, headers, params, content, contentType);
        ClientDriverRequest expected = new ClientDriverRequest("aaaaa").withMethod(Method.GET).withHeader("Cache-Control", "no-cache");
       
        assertThat(sut.isMatch(real, expected), is(false));
    }
View Full Code Here

    public void testMatchWithRequestHeaderPattern() throws Exception {
       
        headers.put("Content-Length", "1234");
       
        RealRequest real = mockRealRequest("aaaaa", Method.GET, headers, params, content, contentType);
        ClientDriverRequest expected = new ClientDriverRequest("aaaaa").withMethod(Method.GET).withHeader("Content-Length", Pattern.compile("\\d+"));
       
        assertThat(sut.isMatch(real, expected), is(true));
    }
View Full Code Here

    public void testMatchWrongWithRequestHeaderPattern() throws Exception {
       
        headers.put("Content-Length", "invalid");
       
        RealRequest real = mockRealRequest("aaaaa", Method.GET, headers, params, content, contentType);
        ClientDriverRequest expected = new ClientDriverRequest("aaaaa").withMethod(Method.GET).withHeader("Content-Length", Pattern.compile("\\d+"));
       
        assertThat(sut.isMatch(real, expected), is(false));
    }
View Full Code Here

   
    @Test
    public void testMatchWrongWithMissingRequestHeaderPattern() throws Exception {
       
        RealRequest real = mockRealRequest("aaaaa", Method.GET, headers, params, content, contentType);
        ClientDriverRequest expected = new ClientDriverRequest("aaaaa").withMethod(Method.GET).withHeader("Content-Length", Pattern.compile("\\d+"));
       
        assertThat(sut.isMatch(real, expected), is(false));
    }
View Full Code Here

    @Test
    public void testExpectedHeadersAreCheckedCaseInsensitively() throws Exception {
       
        headers.put("host", "testhost");
        RealRequest real = mockRealRequest("aaaaa", Method.GET, headers, params, content, contentType);
        ClientDriverRequest expected = new ClientDriverRequest("aaaaa").withMethod(Method.GET).withHeader("Host", Pattern.compile("testhost"));
       
        assertThat(sut.isMatch(real, expected), is(true));
    }
View Full Code Here

    @Test
    public void testExcludedHeadersAreCheckedCaseInsensitively() throws Exception {
       
        headers.put("host", "testhost");
        RealRequest real = mockRealRequest("aaaaa", Method.GET, headers, params, content, contentType);
        ClientDriverRequest expected = new ClientDriverRequest("aaaaa").withMethod(Method.GET).withoutHeader("Host");
       
        assertThat(sut.isMatch(real, expected), is(false));
    }
View Full Code Here

    }
   
    @Test
    public void simpleHeadRetrievesStatus() {
        driver.addExpectation(
                new ClientDriverRequest("/").withMethod(Method.HEAD),
                new ClientDriverResponse());
       
        Response response = head(baseUrl);
       
        assertThat(response, hasStatusCode(204));
View Full Code Here

    }
   
    @Test
    public void headIgnoresEntity() {
        driver.addExpectation(
                new ClientDriverRequest("/").withMethod(Method.HEAD),
                new ClientDriverResponse("some content", "text/plain"));
       
        Response response = headOf(baseUrl);
       
        assertThat(response.getContent(), nullValue());
View Full Code Here

   
    @Test
    public void getOnSameResourceAsHeadRequestRetrievesSameHeadersButWithAnEntity() {
       
        driver.addExpectation(
                new ClientDriverRequest("/").withMethod(Method.HEAD),
                new ClientDriverResponse("Content", "text/plain"));
        Response headResponse = doHeadOf(baseUrl);
       
        assertThat(headResponse, hasStatusCode(200));
       
        driver.addExpectation(
                new ClientDriverRequest("/").withMethod(Method.GET),
                new ClientDriverResponse("Content", "text/plain"));
        Response getResponse = get(baseUrl);
       
        assertThat(getResponse, hasStatusCode(200));
        assertThat(getResponse.getContent(), not(nullValue()));
View Full Code Here

TOP

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

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.