### Question:
DirectoryWatcher { public T getContents(String fileName) throws FileNotFoundException { checkFileChanges(); File file = new File(m_directory, fileName); if (file.exists()) { FileReloadContainer<T> newContainer = new FileReloadContainer<T>(file, m_loader); newContainer.setReloadCheckInterval(0); FileReloadContainer<T> container = m_contents.putIfAbsent(file.getName(), newContainer); if (container == null) { container = newContainer; } return container.getObject(); } else { m_contents.remove(fileName); throw new FileNotFoundException("there is no file " + fileName + " in directory " + m_directory); } } DirectoryWatcher(File directory, FileReloadCallback<T> loader); Set<String> getFileNames(); Set<String> getBaseNamesWithExtension(String extension); T getContents(String fileName);  }### Answer:
@Test public void testGetContents() throws FileNotFoundException { assertEquals("file1Contents", m_watcher.getContents("file1.xml")); assertEquals("file2Contents", m_watcher.getContents("file2.xml")); }
@Test(expected=FileNotFoundException.class) public void testFileDoesntExist() throws FileNotFoundException { m_watcher.getContents("doesnotexist.xml"); }
@Test public void testFileAdded() throws IOException { assertEquals("file2Contents", m_watcher.getContents("file2.xml")); m_bldr.file("file3.xml", "file3Contents"); assertEquals("file3Contents", m_watcher.getContents("file3.xml")); }
@Test(expected=FileNotFoundException.class) public void testFileDeleted() throws IOException { assertEquals("file2Contents", m_watcher.getContents("file2.xml")); File file2 = new File(m_bldr.getCurrentDir(), "file2.xml"); file2.delete(); m_watcher.getContents("file2.xml"); fail("This should not get here!"); }