use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class MemoryVirtualFileTest method getsRootPath.
@Test
public void getsRootPath() throws Exception {
VirtualFile root = getRoot();
assertEquals("/", root.getPath().toString());
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class MemoryVirtualFileTest method copiesFileUnderNewName.
@Test
public void copiesFileUnderNewName() throws Exception {
VirtualFile root = getRoot();
VirtualFile file = root.createFile(generateFileName(), DEFAULT_CONTENT);
file.setProperty("property1", "value1");
VirtualFile targetFolder = root.createFolder(generateFolderName());
VirtualFile copy = file.copyTo(targetFolder, "new name", false);
assertEquals(file.getContentAsString(), copy.getContentAsString());
assertEquals(file.getProperties(), copy.getProperties());
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class MemoryVirtualFileTest method failsRenameLockedFileWithoutLockToken.
@Test
public void failsRenameLockedFileWithoutLockToken() throws Exception {
VirtualFile folder = getRoot().createFolder(generateFolderName());
VirtualFile file = folder.createFile(generateFileName(), DEFAULT_CONTENT);
file.setProperty("property1", "value1");
Path filePath = file.getPath();
Path newPath = folder.getPath().newPath("new name");
file.lock(0);
try {
file.rename("new name");
thrown.expect(ForbiddenException.class);
} catch (ForbiddenException e) {
assertNull(getRoot().getChild(newPath));
assertTrue(file.isLocked());
assertEquals(file, getRoot().getChild(filePath));
assertEquals(ImmutableMap.of("property1", "value1"), file.getProperties());
assertEquals(DEFAULT_CONTENT, file.getContentAsString());
}
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class MemoryVirtualFileTest method unlocksFile.
@Test
public void unlocksFile() throws Exception {
VirtualFile file = getRoot().createFile(generateFileName(), DEFAULT_CONTENT);
String lockToken = file.lock(0);
file.unlock(lockToken);
assertFalse(file.isLocked());
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class MemoryVirtualFileTest method addsNewlyCreatedFileInSearcher.
@Test
public void addsNewlyCreatedFileInSearcher() throws Exception {
VirtualFile file = getRoot().createFile(generateFileName(), DEFAULT_CONTENT);
verify(searcher).add(file);
}
Aggregations