@Test public void getMatchingFiles() throws Exception { append("file0"); append("file1"); TaildirMatcher tm = new TaildirMatcher("f1", tmpDir.getAbsolutePath() + File.separator + "file.*", isCachingNeeded); List<String> files = filesToNames(tm.getMatchingFiles()); assertEquals(msgAlreadyExistingFile, 2, files.size()); assertTrue(msgAlreadyExistingFile, files.contains("file1")); append("file1"); files = filesToNames(tm.getMatchingFiles()); assertEquals(msgAfterNewFileCreated, 2, files.size()); assertTrue(msgAfterNewFileCreated, files.contains("file0")); assertTrue(msgAfterNewFileCreated, files.contains("file1")); append("file2"); append("file3"); files = filesToNames(tm.getMatchingFiles()); assertEquals(msgAfterAppend, 4, files.size()); assertTrue(msgAfterAppend, files.contains("file0")); assertTrue(msgAfterAppend, files.contains("file1")); assertTrue(msgAfterAppend, files.contains("file2")); assertTrue(msgAfterAppend, files.contains("file3")); this.files.get("file0").delete(); files = filesToNames(tm.getMatchingFiles()); assertEquals(msgAfterDelete, 3, files.size()); assertFalse(msgAfterDelete, files.contains("file0")); assertTrue(msgNoChange, files.contains("file1")); assertTrue(msgNoChange, files.contains("file2")); assertTrue(msgNoChange, files.contains("file3")); }
List<File> getMatchingFiles() { long now = TimeUnit.SECONDS.toMillis( TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis())); long currentParentDirMTime = parentDir.lastModified(); List<File> result; if (!cachePatternMatching || lastSeenParentDirMTime < currentParentDirMTime || !(currentParentDirMTime < lastCheckedTime)) { lastMatchedFiles = sortByLastModifiedTime(getMatchingFilesNoCache()); lastSeenParentDirMTime = currentParentDirMTime; lastCheckedTime = now; } return lastMatchedFiles; }
TaildirMatcher { List<File> getMatchingFiles() { long now = TimeUnit.SECONDS.toMillis( TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis())); long currentParentDirMTime = parentDir.lastModified(); List<File> result; if (!cachePatternMatching || lastSeenParentDirMTime < currentParentDirMTime || !(currentParentDirMTime < lastCheckedTime)) { lastMatchedFiles = sortByLastModifiedTime(getMatchingFilesNoCache()); lastSeenParentDirMTime = currentParentDirMTime; lastCheckedTime = now; } return lastMatchedFiles; } }
TaildirMatcher { List<File> getMatchingFiles() { long now = TimeUnit.SECONDS.toMillis( TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis())); long currentParentDirMTime = parentDir.lastModified(); List<File> result; if (!cachePatternMatching || lastSeenParentDirMTime < currentParentDirMTime || !(currentParentDirMTime < lastCheckedTime)) { lastMatchedFiles = sortByLastModifiedTime(getMatchingFilesNoCache()); lastSeenParentDirMTime = currentParentDirMTime; lastCheckedTime = now; } return lastMatchedFiles; } TaildirMatcher(String fileGroup, String filePattern, boolean cachePatternMatching); }
TaildirMatcher { List<File> getMatchingFiles() { long now = TimeUnit.SECONDS.toMillis( TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis())); long currentParentDirMTime = parentDir.lastModified(); List<File> result; if (!cachePatternMatching || lastSeenParentDirMTime < currentParentDirMTime || !(currentParentDirMTime < lastCheckedTime)) { lastMatchedFiles = sortByLastModifiedTime(getMatchingFilesNoCache()); lastSeenParentDirMTime = currentParentDirMTime; lastCheckedTime = now; } return lastMatchedFiles; } TaildirMatcher(String fileGroup, String filePattern, boolean cachePatternMatching); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); String getFileGroup(); }
TaildirMatcher { List<File> getMatchingFiles() { long now = TimeUnit.SECONDS.toMillis( TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis())); long currentParentDirMTime = parentDir.lastModified(); List<File> result; if (!cachePatternMatching || lastSeenParentDirMTime < currentParentDirMTime || !(currentParentDirMTime < lastCheckedTime)) { lastMatchedFiles = sortByLastModifiedTime(getMatchingFilesNoCache()); lastSeenParentDirMTime = currentParentDirMTime; lastCheckedTime = now; } return lastMatchedFiles; } TaildirMatcher(String fileGroup, String filePattern, boolean cachePatternMatching); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); String getFileGroup();  }