Package com.github.restdriver.clientdriver

Examples of com.github.restdriver.clientdriver.ClientDriverRequest


    }
   
    @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


    public void testMatchWithParamsPattern() throws IOException {
       
        params = asMap("kk", "vv", "k2", "v2");
       
        RealRequest real = mockRealRequest("aaaaa", Method.GET, headers, params, content, contentType);
        ClientDriverRequest expected = new ClientDriverRequest("aaaaa")
                .withMethod(Method.GET)
                .withParam("kk", Pattern.compile("[v]{2}")).withParam("k2", Pattern.compile("v[0-9]"));
       
        assertThat(sut.isMatch(real, expected), is(true));
    }
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

    public void testMatchWithIntegerParam() throws IOException {
       
        params = asMap("number", "10");
       
        RealRequest real = mockRealRequest("aaaaa", Method.GET, headers, params, content, contentType);
        ClientDriverRequest expected = new ClientDriverRequest("aaaaa")
                .withMethod(Method.GET)
                .withParam("number", 10);
       
        assertThat(sut.isMatch(real, expected), is(true));
       
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

    public void testMatchWithLongParam() throws IOException {
       
        params = asMap("number", "10");
       
        RealRequest real = mockRealRequest("aaaaa", Method.GET, headers, params, content, contentType);
        ClientDriverRequest expected = new ClientDriverRequest("aaaaa")
                .withMethod(Method.GET)
                .withParam("number", 10L);
       
        assertThat(sut.isMatch(real, expected), is(true));
       
View Full Code Here

    public void testMatchWithBooleanParam() throws IOException {
       
        params = asMap("number", "true");
       
        RealRequest real = mockRealRequest("aaaaa", Method.GET, headers, params, content, contentType);
        ClientDriverRequest expected = new ClientDriverRequest("aaaaa")
                .withMethod(Method.GET)
                .withParam("number", true);
       
        assertThat(sut.isMatch(real, expected), is(true));
       
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

        Object param = Method.POST;
       
        params = asMap("number", "POST");
       
        RealRequest real = mockRealRequest("aaaaa", Method.GET, headers, params, content, contentType);
        ClientDriverRequest expected = new ClientDriverRequest("aaaaa")
                .withMethod(Method.GET)
                .withParam("number", param);
       
        assertThat(sut.isMatch(real, expected), is(true));
       
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.