### Question:
BasicHttpClientConnectionManager implements HttpClientConnectionManager { public synchronized void closeIdle(final TimeValue idleTime) { Args.notNull(idleTime, "Idle time"); if (this.closed.get()) { return; } if (!this.leased) { long time = idleTime.toMilliseconds(); if (time < 0) { time = 0; } final long deadline = System.currentTimeMillis() - time; if (this.updated <= deadline) { closeConnection(CloseMode.GRACEFUL); } } } BasicHttpClientConnectionManager(
            final Lookup<ConnectionSocketFactory> socketFactoryRegistry,
            final HttpConnectionFactory<ManagedHttpClientConnection> connFactory,
            final SchemePortResolver schemePortResolver,
            final DnsResolver dnsResolver);  BasicHttpClientConnectionManager(
            final HttpClientConnectionOperator httpClientConnectionOperator,
            final HttpConnectionFactory<ManagedHttpClientConnection> connFactory);  BasicHttpClientConnectionManager(
            final Lookup<ConnectionSocketFactory> socketFactoryRegistry,
            final HttpConnectionFactory<ManagedHttpClientConnection> connFactory);  BasicHttpClientConnectionManager(
            final Lookup<ConnectionSocketFactory> socketFactoryRegistry);  BasicHttpClientConnectionManager(); @Override void close(); @Override void close(final CloseMode closeMode); synchronized SocketConfig getSocketConfig(); synchronized void setSocketConfig(final SocketConfig socketConfig); LeaseRequest lease(final String id, final HttpRoute route, final Object state); @Override LeaseRequest lease(final String id, final HttpRoute route, final Timeout requestTimeout, final Object state); @Override synchronized void release(final ConnectionEndpoint endpoint, final Object state, final TimeValue keepAlive); @Override void connect(final ConnectionEndpoint endpoint, final TimeValue connectTimeout, final HttpContext context); @Override void upgrade(
            final ConnectionEndpoint endpoint,
            final HttpContext context); synchronized void closeExpired(); synchronized void closeIdle(final TimeValue idleTime);  }### Answer:
@Test public void testCloseIdle() throws Exception { final HttpHost target = new HttpHost("somehost", 80); final HttpRoute route = new HttpRoute(target); Mockito.when(connFactory.createConnection(Mockito.<Socket>any())).thenReturn(conn); final LeaseRequest connRequest1 = mgr.lease("some-id", route, null); final ConnectionEndpoint endpoint1 = connRequest1.get(Timeout.ZERO_MILLISECONDS); Assert.assertNotNull(endpoint1); Mockito.verify(connFactory, Mockito.times(1)).createConnection(Mockito.<Socket>any()); Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE, Boolean.FALSE); mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECOND); Assert.assertEquals(route, mgr.getRoute()); Assert.assertEquals(null, mgr.getState()); Thread.sleep(100); mgr.closeIdle(TimeValue.ofMilliseconds(50)); Mockito.verify(conn).close(CloseMode.GRACEFUL); }