title: How to test my httpClient can close idled connections?
body: <p>I'm using http-client 4.3.x in my project. In order to close "idled" connections, I started a thread to monitor the connection pool and try to close connections which have been idled for 30s every one second.</p>
  
  <p>The connectionManager:</p>
  
  <pre><code>PoolingHttpClientConnectionManager connectionManager = 
      new PoolingHttpClientConnectionManager(registry);
  </code></pre>
  
  <p>The thread to monitor it and close idled connections:</p>
  
  <pre><code>class ClosingIdleConnectionThread extends Thread {
      private final PoolingHttpClientConnectionManager connectionManager;
      private final int timeout;
  
      public ClosingIdleConnectionThread(PoolingHttpClientConnectionManager connectionManager, int timeout) {
          this.connectionManager = connectionManager;
          this.timeout = timeout;
      }
  
      @Override
      public void run() {
          while (!Thread.currentThread().isInterrupted()) {
              connectionManager.closeIdleConnections(timeout, TimeUnit.MILLISECONDS);
              connectionManager.closeExpiredConnections();
              try {
                  TimeUnit.SECONDS.sleep(1);
              } catch (InterruptedException e) {
                  return;
              }
          }
      }
  }
  </code></pre>
  
  <p>But now I have two problems:</p>
  
  <ol>
  <li>Actually, I'm not sure what does "idled" connection means</li>
  <li>I have to write some tests to make sure my code is working, but I don't know how to test it</li>
  </ol>
  
  <p>Thanks for your help ~</p>