Package com.github.restdriver.clientdriver

Examples of com.github.restdriver.clientdriver.ClientDriverFactory


    public ExpectedException thrown = ExpectedException.none();
   
    @Test
    public void notSpecifyingExpectationNumberDefaultsToOnce() throws Exception {
       
        ClientDriver driver = new ClientDriverFactory().createClientDriver();
        driver.addExpectation(onRequestTo("/request"), giveEmptyResponse());
       
        HttpClient client = new DefaultHttpClient();
        HttpGet getter = new HttpGet(driver.getBaseUrl() + "/request");
        client.execute(getter);
View Full Code Here


    }
   
    @Test
    public void specifyingNumberOfTimesForExpectationExpectsItThatNumberOfTimes() throws Exception {
       
        ClientDriver driver = new ClientDriverFactory().createClientDriver();
        driver.addExpectation(onRequestTo("/request"), giveEmptyResponse()).times(2);
       
        HttpGet getter = new HttpGet(driver.getBaseUrl() + "/request");
        new DefaultHttpClient().execute(getter);
        new DefaultHttpClient().execute(getter);
View Full Code Here

    @Test
    public void specifyingNumberOfTimesForExpectationAndNotRequestingCorrectNumberOfTimesFails() throws Exception {
       
        thrown.expect(ClientDriverFailedExpectationException.class);
       
        ClientDriver driver = new ClientDriverFactory().createClientDriver();
        driver.addExpectation(onRequestTo("/request"), giveEmptyResponse()).times(2);
       
        HttpGet getter = new HttpGet(driver.getBaseUrl() + "/request");
        new DefaultHttpClient().execute(getter);
        new DefaultHttpClient().execute(getter);
View Full Code Here

       
        thrown.expect(ClientDriverFailedExpectationException.class);
        thrown.expectMessage("1 unmatched expectation(s):");
        thrown.expectMessage("expected: 2, actual: 1 -> ClientDriverRequest: GET \"/request\";");
       
        ClientDriver driver = new ClientDriverFactory().createClientDriver();
        driver.addExpectation(onRequestTo("/request"), giveEmptyResponse()).times(2);
       
        HttpGet getter = new HttpGet(driver.getBaseUrl() + "/request");
        new DefaultHttpClient().execute(getter);
       
View Full Code Here

    }
   
    @Test
    public void specifyingAnyTimesForExpectationWorks() throws Exception {
       
        ClientDriver driver = new ClientDriverFactory().createClientDriver();
        driver.addExpectation(onRequestTo("/request"), giveEmptyResponse()).anyTimes();
       
        HttpGet getter = new HttpGet(driver.getBaseUrl() + "/request");
        new DefaultHttpClient().execute(getter);
        new DefaultHttpClient().execute(getter);
View Full Code Here

    }
   
    @Test
    public void specifyingAnyTimesForExpectationAnyNotCallingItWorks() throws Exception {
       
        ClientDriver driver = new ClientDriverFactory().createClientDriver();
        driver.addExpectation(onRequestTo("/request"), giveEmptyResponse()).anyTimes();
       
        driver.shutdown();
       
    }
View Full Code Here

    @Test
    public void specifyingAnyTimesBeforeOtherExpectationsConsidersLaterExpectationsCorrectly() throws Exception {
       
        thrown.expect(ClientDriverFailedExpectationException.class);
       
        ClientDriver driver = new ClientDriverFactory().createClientDriver();
        driver.addExpectation(onRequestTo("/anytimes"), giveEmptyResponse()).anyTimes();
        driver.addExpectation(onRequestTo("/one"), giveEmptyResponse());
       
        driver.shutdown();
       
View Full Code Here

    /**
     * Starts the client driver. This will be called before your subclass' {@link Before}-annotated methods.
     */
    @Before
    public final void startClientDriver() {
        clientDriver = new ClientDriverFactory().createClientDriver();
    }
View Full Code Here

public class SlowResponsesTest {
   
    @Test
    public void notSpecifyingExpectationNumberDefaultsToOnce() throws Exception {
       
        ClientDriver driver = new ClientDriverFactory().createClientDriver();
        driver.addExpectation(onRequestTo("/request"), giveEmptyResponse().after(250, MILLISECONDS));
       
        HttpClient client = new DefaultHttpClient();
        HttpGet getter = new HttpGet(driver.getBaseUrl() + "/request");
       
View Full Code Here

        }
    }
   
    @Test
    public void testJettyWorkingWithIncorrectHeaderPattern() throws Exception {
        clientDriver = new ClientDriverFactory().createClientDriver();
       
        clientDriver.addExpectation(onRequestTo("/test").withHeader("Content-Length", Pattern.compile("\\d+")),
                giveEmptyResponse().withStatus(204).withHeader("Content-Type", "abcd"));
       
        HttpClient client = new DefaultHttpClient();
View Full Code Here

TOP

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

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.