}
@Test(expectedExceptions = TimeoutException.class)
public void setMaxConnectionsPerHost() throws InterruptedException,
ExecutionException, TimeoutException, IOException {
final ConnectionManager pool = new ConnectionPool();
pool.setMaxConnectionsPerHost(1);
try {
Connection connection = pool.acquire(host);
Assert.assertNotNull(connection);
pool.release(connection);
connection = pool.acquire(host);
Assert.assertNotNull(connection);
ExecutorService service = Executors.newSingleThreadExecutor();
service.invokeAny(Collections.singleton(new Callable<Connection>() {
@Override
public Connection call() throws Exception {
return pool.acquire(host);
}
}), 2, TimeUnit.SECONDS);
} finally {
pool.shutdown();
}
}