@Test
public void testNodesInfoExceptionRemovesServerFromList() throws Exception {

    NodeChecker nodeChecker = new NodeChecker(jestClient, clientConfig);
    JestResult result = new JestResult(new Gson());
    result.setJsonMap(ImmutableMap.<String, Object>of(
            "ok", "true",
            "nodes", ImmutableMap.of(
                    "node1", ImmutableMap.of(
                            "http_address", "inet[/192.168.2.7:9200]"),
                    "node2", ImmutableMap.of(
                            "http_address", "inet[/192.168.2.8:9200]"),
                    "node3", ImmutableMap.of(
                            "http_address", "inet[/192.168.2.9:9200]"))));
    result.setSucceeded(true);
    when(jestClient.execute(isA(Action.class))).thenReturn(result);
    nodeChecker.runOneIteration();
    verify(jestClient).execute(isA(Action.class));
    ArgumentCaptor<LinkedHashSet> argument = ArgumentCaptor.forClass(LinkedHashSet.class);
    verify(jestClient).setServers(argument.capture());
    verify(jestClient).execute(isA(Action.class));
    Set servers = argument.getValue();
    assertEquals(3, servers.size());
    	when(jestClient.execute(isA(Action.class))).thenThrow(new HttpHostConnectException(
          new ConnectException(), new HttpHost("192.168.2.7", 9200, "http"), null));
    when(jestClient.execute(isA(Action.class))).thenThrow(new CouldNotConnectException("http://192.168.2.7:9200", new IOException("Test HttpHostException")));
    nodeChecker.runOneIteration();
    verify(jestClient, times(2)).execute(isA(Action.class));
    verify(jestClient, times(2)).setServers(argument.capture());
    verifyNoMoreInteractions(jestClient);
    servers = argument.getValue();
    assertEquals(2, servers.size());
    Iterator serversItr = servers.iterator();
    assertEquals("http://192.168.2.8:9200", serversItr.next());
    assertEquals("http://192.168.2.9:9200", serversItr.next());
    // fail at the 2nd node
    //      when(jestClient.execute(isA(Action.class))).thenThrow(new HttpHostConnectException(
    //            new ConnectException(), new HttpHost("192.168.2.8", 9200, "http"), null));
    when(jestClient.execute(isA(Action.class))).thenThrow(new CouldNotConnectException("http://192.168.2.8:9200", new IOException("Test HttpHostException")));
    nodeChecker.runOneIteration();
    verify(jestClient, times(3)).execute(isA(Action.class));
    verify(jestClient, times(3)).setServers(argument.capture());
    verifyNoMoreInteractions(jestClient);
    servers = argument.getValue();
    assertEquals(1, servers.size());
    serversItr = servers.iterator();
    assertEquals("http://192.168.2.9:9200", serversItr.next());
    // fail at the last node, fail back to bootstrap
    	when(jestClient.execute(isA(Action.class))).thenThrow(new HttpHostConnectException(
          new ConnectException(), new HttpHost("192.168.2.9", 9200, "http"), null));
    when(jestClient.execute(isA(Action.class))).thenThrow(new CouldNotConnectException("http://192.168.2.9:9200", new IOException("Test HttpHostException")));
    nodeChecker.runOneIteration();
    verify(jestClient, times(4)).execute(isA(Action.class));
    verify(jestClient, times(4)).setServers(argument.capture());
    verifyNoMoreInteractions(jestClient);
    servers = argument.getValue();
    assertEquals(1, servers.size());
    serversItr = servers.iterator();
    assertEquals("http://localhost:9200", serversItr.next());
}