public HostsFileReader(String inFile,
                         String exFile) throws IOException {
    HostDetails hostDetails = new HostDetails(
        inFile, Collections.emptySet(),
        exFile, Collections.emptyMap());
    current = new AtomicReference<>(hostDetails);
    refresh(inFile, exFile);
  }
@Test
  public void testHostsFileReader() throws Exception {

    FileWriter efw = new FileWriter(excludesFile);
    FileWriter ifw = new FileWriter(includesFile);

    efw.write("#DFS-Hosts-excluded\n");
    efw.write("somehost1\n");
    efw.write("#This-is-comment\n");
    efw.write("somehost2\n");
    efw.write("somehost3 # host3\n");
    efw.write("somehost4\n");
    efw.write("somehost4 somehost5\n");
    efw.close();

    ifw.write("#Hosts-in-DFS\n");
    ifw.write("somehost1\n");
    ifw.write("somehost2\n");
    ifw.write("somehost3\n");
    ifw.write("#This-is-comment\n");
    ifw.write("somehost4 # host4\n");
    ifw.write("somehost4 somehost5\n");
    ifw.close();

    HostsFileReader hfp = new HostsFileReader(includesFile, excludesFile);

    int includesLen = hfp.getHosts().size();
    int excludesLen = hfp.getExcludedHosts().size();

    assertEquals(5, includesLen);
    assertEquals(5, excludesLen);

    assertTrue(hfp.getHosts().contains("somehost5"));
    assertFalse(hfp.getHosts().contains("host3"));

    assertTrue(hfp.getExcludedHosts().contains("somehost5"));
    assertFalse(hfp.getExcludedHosts().contains("host4"));

    // test for refreshing hostreader wit new include/exclude host files
    String newExcludesFile = HOSTS_TEST_DIR + "/dfs1.exclude";
    String newIncludesFile = HOSTS_TEST_DIR + "/dfs1.include";

    efw = new FileWriter(newExcludesFile);
    ifw = new FileWriter(newIncludesFile);

    efw.write("#DFS-Hosts-excluded\n");
    efw.write("node1\n");
    efw.close();

    ifw.write("#Hosts-in-DFS\n");
    ifw.write("node2\n");
    ifw.close();

    hfp.refresh(newIncludesFile, newExcludesFile);
    assertTrue(hfp.getExcludedHosts().contains("node1"));
    assertTrue(hfp.getHosts().contains("node2"));

    HostDetails hostDetails = hfp.getHostDetails();
    assertTrue(hostDetails.getExcludedHosts().contains("node1"));
    assertTrue(hostDetails.getIncludedHosts().contains("node2"));
    assertEquals(newIncludesFile, hostDetails.getIncludesFile());
    assertEquals(newExcludesFile, hostDetails.getExcludesFile());
  }