Examples of ClientDriver


Examples of com.github.restdriver.clientdriver.ClientDriver

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

Examples of com.github.restdriver.clientdriver.ClientDriver

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

Examples of com.github.restdriver.clientdriver.ClientDriver

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

Examples of com.github.restdriver.clientdriver.ClientDriver

       
        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

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

Examples of com.github.restdriver.clientdriver.ClientDriver

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

    @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

Examples of com.github.restdriver.clientdriver.ClientDriver

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");
       
        client.execute(getter);
       
        // Nothing to assert here without relying on system clock and having a long running test :(
       
        driver.shutdown();
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriver

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

Examples of org.apache.derby.jdbc.ClientDriver

        final Map<String, String> attributes = new HashMap<String, String>();
        attributes.put(DROP, "true");
        final String url = getUrl(attributes);
        try {
            new ClientDriver().connect(url, new Properties());
            final String message = MessageUtil.getMessage(ERROR_STOPPING_SERVER, getDatabaseName());
            logger.logError(message);
            return;
        } catch (final SQLException exception) {
            if (!("08006".equals(exception.getSQLState()))) {
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.