### Question:
Directory implements Serializable { public void delete() throws DirectoryException { if (!getFile().delete()) { throw new DirectoryException("Could not delete '" + getFile() + "'"); } } 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 testDelete() throws Exception { final Directory directory1 = new Directory(new File(getDirectory(), "a/directory")); directory1.create(); assertTrue(directory1.getFile().exists()); directory1.delete(); assertFalse(directory1.getFile().exists()); final Directory directory2 = new Directory(new File(getDirectory(), "another")); directory2.create(); final File file2 = new File(getDirectory(), "another/file"); assertTrue(file2.createNewFile()); try { directory2.delete(); fail("Expected DirectoryException"); } catch (final Directory.DirectoryException e) { } }