### Question:
Directory implements Serializable { public File[] listContents(final FileFilter filter) { return listContents(filter, false, false); } Directory();  Directory(final File directory); static FileFilter getMatchAllFilesFilter(); void create(); File getFile(); File getFile(final File child); File[] listContents(final FileFilter filter); File[] listContents(final FileFilter filter,
                             final boolean includeDirectories,
                             final boolean absolutePaths); void deleteContents(); void delete(); File rebaseFromCWD(final File file); File relativeFile(final File file, final boolean mustBeChild); List<File> rebasePath(final String path); boolean isParentOf(final File file); void copyTo(final Directory target, final boolean incremental); String[] getWarnings(); @Override int hashCode(); @Override boolean equals(final Object o);  }### Answer:
@Test public void testListContents() throws Exception { final Directory directory = new Directory(getDirectory()); final String[] files = { "first/three", "will-not-be-picked-up", "because/they/are/too/old", "directory/foo/bah/blah", "directory/blah", "a/b/c/d/e", "a/b/f/g/h", "a/b/f/g/i", "x", "y/z", "another", }; final Set<File> expected = new HashSet<File>(); for (int i=0; i<files.length; ++i) { final File file = new File(getDirectory(), files[i]); file.getParentFile().mkdirs(); assertTrue(file.createNewFile()); if (i < 3) { assertTrue(file.setLastModified(10000L * (i + 1))); } else { expected.add(new File(files[i])); } } final File[] badDirectories = { new File(getDirectory(), "directory/foo/bah/blah.cantread"), new File(getDirectory(), "cantread"), }; for (final File badDirectorie : badDirectories) { badDirectorie.getParentFile().mkdirs(); assertTrue(badDirectorie.mkdir()); FileUtilities.setCanAccess(badDirectorie, false); } final File[] filesAfterTimeT = directory.listContents( new FileFilter() { @Override public boolean accept(File file) { return file.isDirectory() || file.lastModified() > 50000L; } }); for (final File element : filesAfterTimeT) { assertTrue("Contains " + element, expected.contains(element)); } final String[] warnings = directory.getWarnings(); assertEquals(badDirectories.length, warnings.length); final StringBuffer warningsBuffer = new StringBuffer(); for (final String warning : warnings) { warningsBuffer.append(warning); warningsBuffer.append("\n"); } final String warningsString = warningsBuffer.toString(); for (final File badDirectorie : badDirectories) { assertTrue(warningsBuffer + " contains " + badDirectorie.getPath(), warningsString.indexOf(badDirectorie.getPath()) > -1); FileUtilities.setCanAccess(badDirectorie, true); } final File[] allFiles = directory.listContents(Directory.getMatchAllFilesFilter()); assertEquals(files.length, allFiles.length); }