//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void provideSelectiveWatcher() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ProvideSelectiveWatcher() { File specialFile = new File("special"); File otherFile = new File("other"); FileSystemAbstraction normal = mock(typeof(FileSystemAbstraction)); FileSystemAbstraction special = mock(typeof(FileSystemAbstraction)); FileWatcher specialWatcher = mock(typeof(FileWatcher)); FileWatcher normalWatcher = mock(typeof(FileWatcher)); WatchedResource specialResource = mock(typeof(WatchedResource)); WatchedResource normalResource = mock(typeof(WatchedResource)); when(special.FileWatcher()).thenReturn(specialWatcher); when(normal.FileWatcher()).thenReturn(normalWatcher); when(specialWatcher.Watch(specialFile)).thenReturn(specialResource); when(normalWatcher.Watch(otherFile)).thenReturn(normalResource); using (SelectiveFileSystemAbstraction fs = new SelectiveFileSystemAbstraction(specialFile, special, normal)) { FileWatcher fileWatcher = fs.FileWatcher(); assertSame(specialResource, fileWatcher.Watch(specialFile)); assertSame(normalResource, fileWatcher.Watch(otherFile)); } }
protected internal virtual FileSystemWatcherService CreateFileSystemWatcherService(FileSystemAbstraction fileSystem, File databaseDirectory, LogService logging, JobScheduler jobScheduler, Config config, System.Predicate <string> fileNameFilter) { if (!config.Get(GraphDatabaseSettings.filewatcher_enabled)) { Log log = logging.GetInternalLog(this.GetType()); log.Info("File watcher disabled by configuration."); return(FileSystemWatcherService.EMPTY_WATCHER); } try { RestartableFileSystemWatcher watcher = new RestartableFileSystemWatcher(fileSystem.FileWatcher()); watcher.AddFileWatchEventListener(new DefaultFileDeletionEventListener(logging, fileNameFilter)); watcher.Watch(databaseDirectory); // register to watch database dir parent folder to see when database dir removed watcher.Watch(databaseDirectory.ParentFile); return(new DefaultFileSystemWatcherService(jobScheduler, watcher)); } catch (Exception e) { Log log = logging.GetInternalLog(this.GetType()); log.Warn("Can not create file watcher for current file system. File monitoring capabilities for store " + "files will be disabled.", e); return(FileSystemWatcherService.EMPTY_WATCHER); } }