HostsFileReader { public void lazyRefresh(String includesFile, String excludesFile) throws IOException { refreshInternal(includesFile, excludesFile, true); } HostsFileReader(String inFile,
                         String exFile); @Private  HostsFileReader(String includesFile, InputStream inFileInputStream,
      String excludesFile, InputStream exFileInputStream); static void readFileToSet(String type,
      String filename, Set<String> set); @Private static void readFileToSetWithFileInputStream(String type,
      String filename, InputStream fileInputStream, Set<String> set); void refresh(); static void readFileToMap(String type,
      String filename, Map<String, Integer> map); static void readFileToMapWithFileInputStream(String type,
      String filename, InputStream inputStream, Map<String, Integer> map); static void readXmlFileToMapWithFileInputStream(String type,
      String filename, InputStream fileInputStream, Map<String, Integer> map); void refresh(String includesFile, String excludesFile); void lazyRefresh(String includesFile, String excludesFile); void finishRefresh(); @Private void refresh(InputStream inFileInputStream,
      InputStream exFileInputStream); Set<String> getHosts(); Set<String> getExcludedHosts(); @Deprecated void getHostDetails(Set<String> includes, Set<String> excludes); @Deprecated void getHostDetails(Set<String> includeHosts,
                             Map<String, Integer> excludeHosts); HostDetails getHostDetails(); HostDetails getLazyLoadedHostDetails(); void setIncludesFile(String includesFile); void setExcludesFile(String excludesFile); void updateFileNames(String includesFile, String excludesFile);  }
@Test public void testLazyRefresh() throws IOException { FileWriter efw = new FileWriter(excludesFile); FileWriter ifw = new FileWriter(includesFile); efw.write("host1\n"); efw.write("host2\n"); efw.close(); ifw.write("host3\n"); ifw.write("host4\n"); ifw.close(); HostsFileReader hfp = new HostsFileReader(includesFile, excludesFile); ifw = new FileWriter(includesFile); ifw.close(); efw = new FileWriter(excludesFile, true); efw.write("host3\n"); efw.write("host4\n"); efw.close(); hfp.lazyRefresh(includesFile, excludesFile); HostDetails details = hfp.getHostDetails(); HostDetails lazyDetails = hfp.getLazyLoadedHostDetails(); assertEquals("Details: no. of excluded hosts", 2, details.getExcludedHosts().size()); assertEquals("Details: no. of included hosts", 2, details.getIncludedHosts().size()); assertEquals("LazyDetails: no. of excluded hosts", 4, lazyDetails.getExcludedHosts().size()); assertEquals("LayDetails: no. of included hosts", 0, lazyDetails.getIncludedHosts().size()); hfp.finishRefresh(); details = hfp.getHostDetails(); assertEquals("Details: no. of excluded hosts", 4, details.getExcludedHosts().size()); assertEquals("Details: no. of included hosts", 0, details.getIncludedHosts().size()); assertNull("Lazy host details should be null", hfp.getLazyLoadedHostDetails()); }