source: class HostSelectionWithFallbackTest {
  
      private Map<Host, AtomicBoolean> poolStatus;
      private BaseOperation<Integer, Integer> testOperation;
      private final ConnectionPoolConfigurationImpl cpConfig;
      private final ConnectionPoolMonitor cpMonitor;
       String dc;
       String rack1;
       String rack2;
       String rack3;
       Host h1;
       Host h2;
       Host h3;
       Host h4;
       Host h5;
       Host h6;
       Host[] arr;
       List<Host> hosts;
  
      @Test
      public void testGetConnectionsFromRingWhenPrimaryHostPoolInactive() throws Exception {
  
target: 
          HostSelectionWithFallback<Integer> selection = new HostSelectionWithFallback<Integer>(cpConfig, cpMonitor);
  
          Map<Host, HostConnectionPool<Integer>> pools = new HashMap<Host, HostConnectionPool<Integer>>();
  
          for (Host host : hosts) {
              poolStatus.put(host, new AtomicBoolean(true));
              pools.put(host, getMockHostConnectionPool(host, poolStatus.get(host)));
          }
  
          selection.initWithHosts(pools);
  
          // Put Host H1 as DOWN
          poolStatus.get(h1).set(false);
  
          Collection<String> hostnames = runConnectionsToRingTest(selection);
          verifyPresent(hostnames, "h2");
          verifyAtLeastOnePresent(hostnames, "h3", "h5");
  
          // Put Host H2 as DOWN
          selection.initWithHosts(pools);
          poolStatus.get(h1).set(true);
          poolStatus.get(h2).set(false);
  
          hostnames = runConnectionsToRingTest(selection);
  
          verifyPresent(hostnames, "h1");
          verifyAtLeastOnePresent(hostnames, "h4", "h6");
  
          // Put Hosts H1 and H2 as DOWN
          selection.initWithHosts(pools);
          poolStatus.get(h1).set(false);
          poolStatus.get(h2).set(false);
  
          hostnames = runConnectionsToRingTest(selection);
          verifyAtLeastOnePresent(hostnames, "h3", "h5");
          verifyAtLeastOnePresent(hostnames, "h4", "h6");
  
          // Put Hosts H1,H2,H3 as DOWN
          selection.initWithHosts(pools);
          poolStatus.get(h1).set(false);
          poolStatus.get(h2).set(false);
          poolStatus.get(h3).set(false);
  
          hostnames = runConnectionsToRingTest(selection);
          verifyAtLeastOnePresent(hostnames, "h4", "h6");
          verifyPresent(hostnames, "h5");
  
          // Put Hosts H1,H2,H3,H4 as DOWN
          selection.initWithHosts(pools);
          poolStatus.get(h1).set(false);
          poolStatus.get(h2).set(false);
          poolStatus.get(h3).set(false);
          poolStatus.get(h4).set(false);
  
          hostnames = runConnectionsToRingTest(selection);
          verifyExactly(hostnames, "h5", "h6");
      }
  
  }