### Question:
ConnectionPool { public void acquire(Handler<AsyncResult<Connection>> waiter) { if (context != null) { context.emit(waiter, this::doAcquire); } else { doAcquire(waiter); } } ConnectionPool(ConnectionFactory connector, int maxSize);  ConnectionPool(ConnectionFactory connector, int maxSize, int maxWaitQueueSize);  ConnectionPool(ConnectionFactory connector, Context context, int maxSize, int maxWaitQueueSize); int available(); int size(); void acquire(Handler<AsyncResult<Connection>> waiter); Future<Void> close(); void close(Promise<Void> promise);  }### Answer:
@Test public void testDoubleConnectionAcquire() { ConnectionQueue queue = new ConnectionQueue(); ConnectionPool pool = new ConnectionPool(queue, 1); SimpleHolder holder = new SimpleHolder(); pool.acquire(holder); SimpleConnection conn = new SimpleConnection(); queue.connect(conn); holder.init(); try { holder.init(); fail(); } catch (IllegalStateException ignore) { } }
@Test public void testMaxQueueSize1() { ConnectionQueue queue = new ConnectionQueue(); ConnectionPool pool = new ConnectionPool(queue, 1, 0); SimpleHolder holder1 = new SimpleHolder(); pool.acquire(holder1); SimpleConnection conn = new SimpleConnection(); queue.connect(conn); holder1.init(); SimpleHolder holder2 = new SimpleHolder(); pool.acquire(holder2); assertTrue(holder2.isFailed()); }
@Test public void testMaxQueueSize2() { SimpleHolder holder2 = new SimpleHolder(); SimpleConnection conn = new SimpleConnection(); ConnectionPool[] poolRef = new ConnectionPool[1]; ConnectionPool pool = new ConnectionPool(new ConnectionFactory() { @Override public Future<Connection> connect() { Promise<Connection> promise = Promise.promise(); poolRef[0].acquire(holder2); assertFalse(holder2.isComplete()); promise.complete(conn); assertFalse(holder2.isComplete()); return promise.future(); } }, 1, 0); poolRef[0] = pool; SimpleHolder holder1 = new SimpleHolder(); pool.acquire(holder1); assertTrue(holder1.isComplete()); assertTrue(holder2.isFailed()); }