}
@Test
public void testFileMonitor() throws Exception {
MyFileMonitor listener = new MyFileMonitor();
DefaultFileMonitor monitor = new DefaultFileMonitor(listener);
monitor.setRecursive(true);
FileObject testDir = vfs.resolveFile(TEST_DIR.toUri().toString());
monitor.addFile(testDir);
monitor.start();
// Copy jar file to a new file name
URL jarPath = this.getClass().getResource("/HelloWorld.jar");
Path src = new Path(jarPath.toURI().toString());
Path dst = new Path(TEST_DIR, "HelloWorld2.jar");
this.hdfs.copyFromLocalFile(src, dst);
// VFS-487 significantly wait to avoid failure
Thread.sleep(7000);
Assert.assertTrue(listener.isFileCreated());
// Update the jar
jarPath = this.getClass().getResource("/HelloWorld.jar");
src = new Path(jarPath.toURI().toString());
dst = new Path(TEST_DIR, "HelloWorld2.jar");
this.hdfs.copyFromLocalFile(src, dst);
// VFS-487 significantly wait to avoid failure
Thread.sleep(7000);
Assert.assertTrue(listener.isFileChanged());
this.hdfs.delete(dst, false);
// VFS-487 significantly wait to avoid failure
Thread.sleep(7000);
Assert.assertTrue(listener.isFileDeleted());
monitor.stop();
}