use of com.intellij.openapi.vfs.newvfs.events.VFileDeleteEvent in project intellij-community by JetBrains.
the class LocalFileSystemTest method testFindRoot.
public void testFindRoot() throws IOException {
VirtualFile root = myFS.findFileByPath("wrong_path");
assertNull(root);
VirtualFile root2;
if (SystemInfo.isWindows) {
root = myFS.findFileByPath("\\\\unit-133");
assertNotNull(root);
root2 = myFS.findFileByPath("//UNIT-133");
assertNotNull(root2);
assertEquals(String.valueOf(root2), root, root2);
RefreshQueue.getInstance().processSingleEvent(new VFileDeleteEvent(this, root, false));
root = myFS.findFileByIoFile(new File("\\\\unit-133"));
assertNotNull(root);
RefreshQueue.getInstance().processSingleEvent(new VFileDeleteEvent(this, root, false));
if (new File("c:").exists()) {
root = myFS.findFileByPath("c:");
assertNotNull(root);
assertEquals("C:/", root.getPath());
root2 = myFS.findFileByPath("C:\\");
assertSame(String.valueOf(root), root, root2);
VirtualFileManager fm = VirtualFileManager.getInstance();
root = fm.findFileByUrl("file://C:/");
assertNotNull(root);
root2 = fm.findFileByUrl("file:///c:/");
assertSame(String.valueOf(root), root, root2);
}
} else if (SystemInfo.isUnix) {
root = myFS.findFileByPath("/");
assertNotNull(root);
assertEquals("/", root.getPath());
}
root = myFS.findFileByPath("");
assertNotNull(root);
File jarFile = IoTestUtil.createTestJar();
assertNotNull(getVirtualFile(jarFile));
root = VirtualFileManager.getInstance().findFileByUrl("jar://" + jarFile.getPath() + "!/");
assertNotNull(root);
root2 = VirtualFileManager.getInstance().findFileByUrl("jar://" + jarFile.getPath().replace(File.separator, "//") + "!/");
assertEquals(String.valueOf(root2), root, root2);
if (!SystemInfo.isFileSystemCaseSensitive) {
root2 = VirtualFileManager.getInstance().findFileByUrl("jar://" + jarFile.getPath().toUpperCase(Locale.US) + "!/");
assertEquals(String.valueOf(root2), root, root2);
}
}
use of com.intellij.openapi.vfs.newvfs.events.VFileDeleteEvent in project intellij-community by JetBrains.
the class LocalFileSystemTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect(getTestRootDisposable());
connection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener() {
@Override
public void before(@NotNull List<? extends VFileEvent> events) {
checkFiles(events, true);
}
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
checkFiles(events, false);
}
private void checkFiles(List<? extends VFileEvent> events, boolean before) {
for (VFileEvent event : events) {
VirtualFile file = event.getFile();
if (file != null) {
boolean shouldBeInvalid = event instanceof VFileCreateEvent && before && !((VFileCreateEvent) event).isReCreation() || event instanceof VFileDeleteEvent && !before;
assertEquals(event.toString(), !shouldBeInvalid, file.isValid());
}
}
}
});
myFS = LocalFileSystem.getInstance();
}
Aggregations