DnsResolverConnectionStrategy extends AbstractConnectionStrategy { @Override public Iterator<LdapURL> iterator() { if (!isInitialized()) { throw new IllegalStateException("Strategy is not initialized"); } if (Instant.now().isAfter(expirationTime)) { populate(ldapUrls, ldapURLSet); } if (iterFunction != null) { return iterFunction.apply(ldapURLSet.getUrls()); } return new DefaultLdapURLIterator(ldapURLSet.getUrls()); } DnsResolverConnectionStrategy();  DnsResolverConnectionStrategy(final Duration ttl);  DnsResolverConnectionStrategy(final Function<List<LdapURL>, Iterator<LdapURL>> function);  DnsResolverConnectionStrategy(final Function<List<LdapURL>, Iterator<LdapURL>> function, final Duration ttl); Function<String, InetAddress[]> getResolverFunction(); void setResolverFunction(final Function<String, InetAddress[]> func); @Override Iterator<LdapURL> iterator(); @Override void populate(final String urls, final LdapURLSet urlSet);  }
@Test(groups = "conn", dataProvider = "urls") public void iterator(final String actual, final LdapURL[] expected) { final DnsResolverConnectionStrategy strategy = new DnsResolverConnectionStrategy(); strategy.setResolverFunction(customResolver); strategy.initialize(actual, ldapURL -> true); Assert.assertEquals( StreamSupport.stream(strategy.spliterator(), false).collect(Collectors.toList()), Arrays.asList(expected)); }