Examples of addExpectation()


Examples of com.github.restdriver.clientdriver.ClientDriver.addExpectation()

   
    @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

Examples of com.github.restdriver.clientdriver.ClientDriver.addExpectation()

   
    @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

Examples of com.github.restdriver.clientdriver.ClientDriver.addExpectation()

    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);
        new DefaultHttpClient().execute(getter);
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriver.addExpectation()

        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);
       
        driver.shutdown();
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriver.addExpectation()

   
    @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);
        new DefaultHttpClient().execute(getter);
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriver.addExpectation()

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

Examples of com.github.restdriver.clientdriver.ClientDriver.addExpectation()

    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

Examples of com.github.restdriver.clientdriver.ClientDriver.addExpectation()

       
        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

Examples of com.github.restdriver.clientdriver.ClientDriver.addExpectation()

   
    @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");
       
        client.execute(getter);
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriver.addExpectation()

    public void userCanChooseOwnPort() throws IOException {
       
        int portNum = ClientDriver.getFreePort();
       
        ClientDriver driver = new ClientDriverFactory().createClientDriver(portNum);
        driver.addExpectation(onRequestTo("/url"), giveResponse("hello", "text/plain"));
       
        HttpClient client = new DefaultHttpClient();
        HttpGet getter = new HttpGet("http://localhost:" + portNum + "/url");
        HttpResponse response = client.execute(getter);
       
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.