ProxyClientManager implements TimerTask { public void removeClient(SocketAddress address) { ProxyClient sc = address2Services.remove(address); if (null != sc) { logger.info("Removed host {}.", address); sc.close(); } } ProxyClientManager(ClientConfig clientConfig,
                              ProxyClient.Builder clientBuilder,
                              HashedWheelTimer timer,
                              HostProvider hostProvider,
                              ClientStats clientStats); @Override void run(Timeout timeout); void registerProxyListener(ProxyListener listener); ProxyClient getClient(final SocketAddress address); void removeClient(SocketAddress address); void removeClient(SocketAddress address, ProxyClient sc); ProxyClient createClient(final SocketAddress address); void handshake(); int getNumProxies(); Map<SocketAddress, ProxyClient> getAllClients(); void close();  }
@Test(timeout = 60000) public void testRemoveClient() throws Exception { SocketAddress address = createSocketAddress(3000); MockProxyClientBuilder builder = new MockProxyClientBuilder(); MockProxyClient mockProxyClient = createMockProxyClient(address); builder.provideProxyClient(address, mockProxyClient); ProxyClientManager clientManager = createProxyClientManager(builder, 0L); assertEquals("There should be no clients in the manager", 0, clientManager.getNumProxies()); clientManager.createClient(address); assertEquals("Create client should build the proxy client", 1, clientManager.getNumProxies()); clientManager.removeClient(address); assertEquals("Remove should remove proxy client", 0, clientManager.getNumProxies()); }