### Question:
FileUtil { public static File getExistingFile(String path, String toolHome) { final File file = getFile(path, toolHome); if (file != null) { if (!file.isFile()) { final String message = String.format("File '%s': is not existing", file); throw new ToolException(message, ToolException.TOOL_IO_ERROR); } } return file; }  static File getExistingFile(String path, String toolHome); static File getExistingDirectory(String directory, String toolHome);  }### Answer:
@Test public void testGetExistingFile_notExisting() { final File toolHomeFile = new File("."); final String toolHome = toolHomeFile.getAbsolutePath(); try { FileUtil.getExistingFile("schneck", toolHome); fail("ToolException expected"); } catch (ToolException expected) { } }
@Test public void testGetExistingFile_existing() throws IOException { final File toolHomeFile = new File("."); final String toolHome = toolHomeFile.getAbsolutePath(); final File existingFile = new File(toolHome, "delete_me"); if (!existingFile.createNewFile()) { fail("failed to create test file"); } try { final File file = FileUtil.getExistingFile(existingFile.getAbsolutePath(), toolHome); assertNotNull(file); assertEquals(existingFile.getAbsolutePath(), file.getAbsolutePath()); } finally { if (!existingFile.delete()) { fail("failed to delete test file"); } } }