@Test(expected = SQLException.class)
public void testGetConnection_FailToGetConnection() throws Exception {

    ComboPooledDataSource cpds1 = createMock(ComboPooledDataSource.class);
    expectNew(ComboPooledDataSource.class).andReturn(cpds1);
    cpds1.setDriverClass("org.postgresql.Driver");
    expectLastCall().once();
    cpds1.setJdbcUrl("jdbc:postgresql://host:port/template1");
    expectLastCall().once();
    cpds1.setUser("user");
    expectLastCall().once();
    cpds1.setPassword("password");
    expectLastCall().once();
    cpds1.setInitialPoolSize(0);
    expectLastCall().once();
    cpds1.setMinPoolSize(0);
    expectLastCall().once();
    cpds1.setMaxPoolSize(1);
    expectLastCall().once();
    cpds1.setMaxIdleTime(600);
    expectLastCall().once();
    cpds1.setAcquireRetryAttempts(5);
    expectLastCall().once();
    cpds1.setAcquireRetryDelay(1000);
    expectLastCall().once();
    Connection conn1 = createMock(Connection.class);
    expect(cpds1.getConnection()).andThrow(new SQLException("fail"));
    replay(cpds1, ComboPooledDataSource.class);
    replay(conn1);
    datasource.getConnection("host", "port", "user", "password");
}