@Test @DisplayName("Check that the add event listener is notified") void add_callback_1(@TempDir Path temp) throws IOException, InterruptedException { assumeFalse(SystemUtil.OS_TYPE == OsType.MACOS); BlockingQueue<FileListlet> eventQueue = new ArrayBlockingQueue<>(5); Files.createFile(temp.resolve("test.txt")); try (FsHandle fs = new FsHandle(temp.toString())) { fs.addUpdateCallback(ev -> { ev.getListingList().stream().forEachOrdered(eventQueue::add); }); Files.createFile(temp.resolve("added.txt")); FileListlet fileCreated = eventQueue.poll(5000, TimeUnit.MILLISECONDS); assertNotNull(fileCreated); assertEquals("added.txt", fileCreated.getName()); assertEquals(UpdateType.ENTRY_CREATE, fileCreated.getUpdateType()); assertEquals(0, eventQueue.size(), "Unexpected events: " + Arrays.toString(eventQueue.toArray())); } }
public void addUpdateCallback(Consumer<EV_FileListing> callback) { if (callback == null) throw new IllegalArgumentException(); callbacks.add(callback); }
FsHandle implements Closeable { public void addUpdateCallback(Consumer<EV_FileListing> callback) { if (callback == null) throw new IllegalArgumentException(); callbacks.add(callback); } }
FsHandle implements Closeable { public void addUpdateCallback(Consumer<EV_FileListing> callback) { if (callback == null) throw new IllegalArgumentException(); callbacks.add(callback); } FsHandle();  FsHandle(String start);  FsHandle(String start, FsHandleOptions options);  FsHandle(FileSystem fs, String start, FsHandleOptions options); }
FsHandle implements Closeable { public void addUpdateCallback(Consumer<EV_FileListing> callback) { if (callback == null) throw new IllegalArgumentException(); callbacks.add(callback); } FsHandle();  FsHandle(String start);  FsHandle(String start, FsHandleOptions options);  FsHandle(FileSystem fs, String start, FsHandleOptions options); int getId(); String pwd(); void addUpdateCallback(Consumer<EV_FileListing> callback); boolean up(); boolean down(String directory); boolean setPath(String path); List<FileListlet> list(); @Override void close(); }
FsHandle implements Closeable { public void addUpdateCallback(Consumer<EV_FileListing> callback) { if (callback == null) throw new IllegalArgumentException(); callbacks.add(callback); } FsHandle();  FsHandle(String start);  FsHandle(String start, FsHandleOptions options);  FsHandle(FileSystem fs, String start, FsHandleOptions options); int getId(); String pwd(); void addUpdateCallback(Consumer<EV_FileListing> callback); boolean up(); boolean down(String directory); boolean setPath(String path); List<FileListlet> list(); @Override void close();  }