### Question:
ConcurrentReachableAddressFinder { public String findReachable(Iterable<String> addresses, Duration timeout) { AtomicReference<String> result = newReference(); Duration timeoutPerAttempt = Duration.min(Duration.of(2, TimeUnit.SECONDS), timeout); Predicate<Iterable<String>> findOrBreak = updateRefOnAddressReachable(result, timeoutPerAttempt); LOG.debug("blocking on reachability of addresses {} for max {}", addresses, timeout); boolean passed = Repeater .create() .until(addresses, findOrBreak) .backoffTo(Duration.ONE_SECOND) .limitTimeTo(timeout) .run(); if (passed) { LOG.debug("address {} reachable", result); assert result.get() != null; return result.get(); } else { throw new NoSuchElementException("Could not connect to any address in "+addresses+" within "+timeout); } } ConcurrentReachableAddressFinder(ListeningExecutorService userExecutor);  ConcurrentReachableAddressFinder(Reachable pingTester, ListeningExecutorService userExecutor); String findReachable(Iterable<String> addresses, Duration timeout);  }### Answer:
@Test public void testFindsReachable() throws Exception { String result = reachableAddressFinder.findReachable(ImmutableList.of("127.0.0.1"), Duration.TEN_SECONDS); assertEquals(result, "127.0.0.1"); }
@Test public void testFindsReachableKeepsAddressInOriginalFormat() throws Exception { String result = reachableAddressFinder.findReachable(ImmutableList.of("localhost"), Duration.TEN_SECONDS); assertEquals(result, "localhost"); }
@Test(groups="Integration") public void testFindsReachableWhenMultipleAddresses() throws Exception { String result = reachableAddressFinder.findReachable(ImmutableList.of("1.2.3.4", "127.0.0.1"), Duration.TEN_SECONDS); assertEquals(result, "127.0.0.1"); }
@Test(groups="Integration") public void testFindsReachableWhenNoneReachable() throws Exception { try { String result = reachableAddressFinder.findReachable(ImmutableList.of("1.2.3.4", "1.2.3.5"), Duration.of(5, TimeUnit.SECONDS)); fail("Expected NoSuchElementException; got "+result); } catch (NoSuchElementException e) { if (!e.toString().contains("Could not connect to any address")) throw e; } }