### Question:
DnsUtil { public static List<URI> readDnsConf() { final Logger logger = LoggerFactory.getLogger(DnsUtil.class); final boolean debug = logger.isDebugEnabled(); final File file = new File(Sys.sysProp(QBIT_DNS_RESOLV_CONF, "/etc/resolv.conf")); if (file.exists()) { final List<String> lines = IO.readLines(file); if (debug) logger.debug("file contents {}", lines); return lines.stream().filter(line -> line.startsWith("nameserver")) .map(line -> { if (debug) logger.debug("file content line = {}", line); final String uriToParse = line.replace("nameserver ", "").trim(); final String[] split = Str.split(uriToParse, ':'); try { if (split.length == 1) { return new URI("dns", "", split[0], 53, "", "", ""); } else if (split.length >= 2) { return new URI("dns", "", split[0], Integer.parseInt(split[1]), "", "", ""); } else { throw new IllegalStateException("Unable to parse URI from /etc/resolv.conf"); } } catch (URISyntaxException e) { throw new IllegalStateException("failed to convert to URI"); } }) .collect(Collectors.toList()); } else { throw new IllegalStateException("" + file + " not found"); } }  static List<URI> readDnsConf(); static ServiceDiscovery createDnsServiceDiscovery(); static final String QBIT_DNS_RESOLV_CONF; }### Answer:
@Test public void test() { final List<URI> uris = DnsUtil.readDnsConf(); assertTrue(uris.size() > 0); for (URI uri : uris) { puts(uri.getPort(), uri.getHost()); assertNotNull(uri); } }
@Test public void testResolvOverride() { Sys.putSysProp(DnsUtil.QBIT_DNS_RESOLV_CONF, "./qbit/service-discovery/src/test/test-files/resolv.conf"); final List<URI> uris = DnsUtil.readDnsConf(); assertTrue(uris.size() > 0); for (URI uri : uris) { puts(uri.getPort(), uri.getHost()); assertNotNull(uri); } assertEquals("localhost", uris.get(0).getHost()); assertEquals(5354, uris.get(0).getPort()); }