ConfigFileMonitor implements FileListener { @Override public void fileDeleted(FileChangeEvent fileChangeEvent) throws FileSystemException { FileObject fileObject = fileChangeEvent.getFile(); LOGGER.info(String.format("Received file deletion event for file: %s", fileObject)); File file = new File(fileObject.getName().getPath()); if (ConfigFileFilter.isFileSupported(file)) { configurationService.deleteByBundle(file.getParentFile().getName()); Map<String, Object> params = new HashMap<>(); params.put(ConfigurationConstants.FILE_PATH, file.getAbsolutePath()); sendEvent(ConfigurationConstants.FILE_DELETED_EVENT_SUBJECT, params); } }  void setFileMonitor(DefaultFileMonitor fileMonitor); @PostConstruct void init(); @Override void fileCreated(FileChangeEvent fileChangeEvent); @Override void fileChanged(FileChangeEvent fileChangeEvent); @Override void fileDeleted(FileChangeEvent fileChangeEvent); @PreDestroy void stop(); void updateFileMonitor();  }
@Test public void shouldDeleteConfigWhenFileIsDeleted() throws FileSystemException { final String fileName = "res:config/org.motechproject.motech-module1/somemodule.properties"; FileObject fileObject = VFS.getManager().resolveFile(fileName); configFileMonitor.fileDeleted(new FileChangeEvent(fileObject)); verify(configurationService).deleteByBundle(new File(fileObject.getName().getPath()).getParentFile().getName()); }