### Question:
ResolverConfReader { public static String getDomainFromResolverConf(final String file) { try (final InputStream in = new FileInputStream(file)) { final InputStreamReader isr = new InputStreamReader(in); try (final BufferedReader br = new BufferedReader(isr)) { String line; while ((line = br.readLine()) != null) { if (line.startsWith("domain")) { final StringTokenizer st = new StringTokenizer(line); st.nextToken(); if (!st.hasMoreTokens()) { continue; } return st.nextToken(); } } } } catch (FileNotFoundException e) { log.warn("Resolver config file not found", e); } catch (IOException e) { log.warn("Error reading config file", e); } return ""; }  static String getDomainFromResolverConf(final String file);  }### Answer:
@Test public void test() throws Exception { final File f = temporaryFolder.newFile(); final String absolutePath = f.getAbsolutePath(); final FileOutputStream fos = new FileOutputStream(absolutePath); final ByteBuffer bytes = Charsets.UTF_8.encode( "nameserver 127.0.0.1\nsearch spotify.com\ndomain foo.bar\n"); fos.write(bytes.array()); fos.close(); assertEquals("foo.bar", ResolverConfReader.getDomainFromResolverConf(absolutePath)); }
@Test public void testFileNotFound() throws Exception { assertEquals("", ResolverConfReader.getDomainFromResolverConf( "/this_file_really-ShoUldnt=exist")); }