@Test
    public void testServerListRefresh() throws IOException {
        String content = "Hello world";
        MockWebServer server1 = new MockWebServer();
        MockWebServer server2 = new MockWebServer();
        MockWebServer server3 = new MockWebServer();
        MockResponse mockResponse = new MockResponse().setResponseCode(200).setHeader("Content-type", "text/plain")
                .setBody(content);
        server1.enqueue(mockResponse);
        server2.enqueue(mockResponse);
        server3.enqueue(mockResponse);
        server1.play();
        server2.play();
        server3.play();
        try {
            BaseLoadBalancer lb = new BaseLoadBalancer();
            List<Server> initialList = Lists.newArrayList(new Server("localhost", server1.getPort()), new Server("localhost", server2.getPort()));
            lb.setServersList(initialList);
            LoadBalancingHttpClient<ByteBuf, ByteBuf> client = RibbonTransport.newHttpClient(lb);
            HttpClientRequest<ByteBuf> request = HttpClientRequest.createGet("/");
            client.submit(request).toBlocking().last();
            client.submit(request).toBlocking().last();
            HttpClientRequest<ByteBuf> request2 = HttpClientRequest.createGet("http://localhost:" + server3.getPort());
            client.submit(request2).toBlocking().last();
            Set<Server> cachedServers = client.getRxClients().keySet();
            assertEquals(Sets.newHashSet(new Server("localhost", server1.getPort()), new Server("localhost", server2.getPort()), new Server("localhost", server3.getPort())), cachedServers);
            List<Server> newList = Lists.newArrayList(new Server("localhost", server1.getPort()), new Server("localhost", 99999));
            lb.setServersList(newList);
            cachedServers = client.getRxClients().keySet();
            assertEquals(Sets.newHashSet(new Server("localhost", server1.getPort()), new Server("localhost", server3.getPort())), cachedServers);
        } finally {
            server1.shutdown();
            server2.shutdown();
            server3.shutdown();
        }
    }
This test ensures that when server list is refreshed in the load balancer, the set of servers
which equals to (oldList - newList) should be removed from the map of cached RxClient. Any server
that is not part of oldList should stay in the map.

@throws IOException
ribbon-transport/src/test/java/com/netflix/ribbon/transport/netty/http/ServerListRefreshTest.java