use of ch.cyberduck.core.local.DisabledFileWatcherListener in project cyberduck by iterate-ch.
the class DefaultWatchEditorTest method testEditNullApplication.
@Test(expected = IOException.class)
public void testEditNullApplication() throws Exception {
final DefaultWatchEditor editor = new DefaultWatchEditor(new Host(new TestProtocol()), new Path("/remote", EnumSet.of(Path.Type.file)), new DisabledListProgressListener());
final Local local = new DefaultTemporaryFileService().create("remote");
new DefaultLocalTouchFeature().touch(local);
final Path file = new Path("/remote.txt", EnumSet.of(Path.Type.file));
editor.edit(EditorFactory.getEditor(file.getName()), file, local, new DisabledFileWatcherListener());
}
use of ch.cyberduck.core.local.DisabledFileWatcherListener in project cyberduck by iterate-ch.
the class DefaultWatchEditorTest method testEditNullApplicationNoFile.
@Test(expected = IOException.class)
public void testEditNullApplicationNoFile() throws Exception {
final DefaultWatchEditor editor = new DefaultWatchEditor(new Host(new TestProtocol()), new Path("/remote", EnumSet.of(Path.Type.file)), new DisabledListProgressListener());
final Path file = new Path("/remote", EnumSet.of(Path.Type.file));
editor.edit(EditorFactory.getEditor(file.getName()), file, new DefaultTemporaryFileService().create("remote"), new DisabledFileWatcherListener());
}
use of ch.cyberduck.core.local.DisabledFileWatcherListener in project cyberduck by iterate-ch.
the class DefaultWatchEditorTest method testNotfound.
@Test(expected = NoSuchFileException.class)
public void testNotfound() throws Exception {
final DefaultWatchEditor editor = new DefaultWatchEditor(new Host(new TestProtocol()), new Path("/remote", EnumSet.of(Path.Type.file)), new DisabledListProgressListener());
editor.watch(new Application("com.app"), new Local(System.getProperty("java.io.tmpdir") + "/notfound", UUID.randomUUID().toString()), new DisabledFileWatcherListener(), new DisabledApplicationQuitCallback());
}
use of ch.cyberduck.core.local.DisabledFileWatcherListener in project cyberduck by iterate-ch.
the class NIOEventWatchServiceTest method testListenerEventWatchServiceWindows.
@Test
public void testListenerEventWatchServiceWindows() throws Exception {
assumeTrue(Factory.Platform.getDefault().equals(Factory.Platform.Name.windows));
final FileWatcher watcher = new FileWatcher(new NIOEventWatchService());
final Local file = LocalFactory.get(LocalFactory.get(System.getProperty("java.io.tmpdir")), String.format("é%s", new AlphanumericRandomStringService().random()));
final CountDownLatch update = new CountDownLatch(1);
final CountDownLatch delete = new CountDownLatch(1);
final FileWatcherListener listener = new DisabledFileWatcherListener() {
@Override
public void fileWritten(final Local file) {
try {
assertEquals(new File(file.getAbsolute()).getCanonicalPath(), new File(file.getAbsolute()).getCanonicalPath());
} catch (IOException e) {
fail();
}
update.countDown();
}
@Override
public void fileDeleted(final Local file) {
try {
assertEquals(new File(file.getAbsolute()).getCanonicalPath(), new File(file.getAbsolute()).getCanonicalPath());
} catch (IOException e) {
fail();
}
delete.countDown();
}
};
LocalTouchFactory.get().touch(file);
assertTrue(watcher.register(file.getParent(), new FileWatcher.DefaultFileFilter(file), listener).await(1, TimeUnit.SECONDS));
final ProcessBuilder sh = new ProcessBuilder("cmd", "/c", String.format("echo 'Test' >> %s", file.getAbsolute()));
final Process cat = sh.start();
assertTrue(cat.waitFor(5L, TimeUnit.SECONDS));
assertTrue(update.await(5L, TimeUnit.SECONDS));
file.delete();
assertTrue(delete.await(5L, TimeUnit.SECONDS));
watcher.close();
}
use of ch.cyberduck.core.local.DisabledFileWatcherListener in project cyberduck by iterate-ch.
the class FSEventWatchServiceTest method testListener.
@Test
@Ignore
public void testListener() throws Exception {
final FileWatcher watcher = new FileWatcher(new FSEventWatchService());
final Local file = LocalFactory.get(LocalFactory.get(System.getProperty("java.io.tmpdir")), String.format("é%s", new AlphanumericRandomStringService().random()));
final CountDownLatch update = new CountDownLatch(1);
final CountDownLatch delete = new CountDownLatch(1);
final FileWatcherListener listener = new DisabledFileWatcherListener() {
@Override
public void fileWritten(final Local file) {
try {
assertEquals(new File(file.getAbsolute()).getCanonicalPath(), new File(file.getAbsolute()).getCanonicalPath());
} catch (IOException e) {
fail();
}
update.countDown();
}
@Override
public void fileDeleted(final Local file) {
try {
assertEquals(new File(file.getAbsolute()).getCanonicalPath(), new File(file.getAbsolute()).getCanonicalPath());
} catch (IOException e) {
fail();
}
delete.countDown();
}
};
LocalTouchFactory.get().touch(file);
assertTrue(file.exists());
assertTrue(watcher.register(file.getParent(), new FileWatcher.DefaultFileFilter(file), listener).await(1, TimeUnit.SECONDS));
final ProcessBuilder sh = new ProcessBuilder("sh", "-c", String.format("echo 'Test' >> %s", file.getAbsolute()));
final Process cat = sh.start();
assertTrue(cat.waitFor(5L, TimeUnit.SECONDS));
assertTrue(update.await(5L, TimeUnit.SECONDS));
file.delete();
assertTrue(delete.await(5L, TimeUnit.SECONDS));
watcher.close();
}
Aggregations