use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method getsChildByHierarchicalPath.
@Test
public void getsChildByHierarchicalPath() throws Exception {
VirtualFile root = getRoot();
VirtualFile folder = root.createFolder("a/b/c/d");
String name = generateFileName();
VirtualFile file = folder.createFile(name, DEFAULT_CONTENT);
assertEquals(file, root.getChild(folder.getPath().newPath(name)));
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class MemoryVirtualFileTest method getsContentAsBytes.
@Test
public void getsContentAsBytes() throws Exception {
VirtualFile root = getRoot();
VirtualFile file = root.createFile(generateFileName(), DEFAULT_CONTENT);
byte[] content = file.getContentAsBytes();
assertEquals(DEFAULT_CONTENT, new String(content));
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class MemoryVirtualFileTest method renamesFile.
@Test
public void renamesFile() throws Exception {
VirtualFile folder = getRoot().createFolder(generateFolderName());
VirtualFile file = folder.createFile(generateFileName(), DEFAULT_CONTENT);
file.setProperty("property1", "value1");
Path filePath = file.getPath();
VirtualFile renamedFile = file.rename("new name");
assertEquals(renamedFile, getRoot().getChild(renamedFile.getPath()));
assertEquals(ImmutableMap.of("property1", "value1"), renamedFile.getProperties());
assertEquals(DEFAULT_CONTENT, renamedFile.getContentAsString());
assertNull(getRoot().getChild(filePath));
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class MemoryVirtualFileTest method deletesFolder.
@Test
public void deletesFolder() throws Exception {
VirtualFile folder = getRoot().createFolder(generateFolderName());
folder.setProperty("property1", "value1");
Path folderPath = folder.getPath();
VirtualFile file = folder.createFile(generateFileName(), DEFAULT_CONTENT);
file.setProperty("property1", "value1");
Path filePath = file.getPath();
folder.delete();
assertNull(getRoot().getChild(folderPath));
assertNull(getRoot().getChild(filePath));
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class MemoryVirtualFileTest method updatesFileInSearcherWhenItIsRenamed.
@Test
public void updatesFileInSearcherWhenItIsRenamed() throws Exception {
VirtualFile file = getRoot().createFile(generateFileName(), DEFAULT_CONTENT);
String oldPath = file.getPath().toString();
Mockito.reset(searcher);
VirtualFile renamed = file.rename("new_name");
verify(searcher).add(renamed);
verify(searcher).delete(oldPath, true);
}
Aggregations