use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class MemoryVirtualFileTest method failsCopyFolderUnderNewNameWhenTargetFolderContainsItemWithSameNameAndOverwritingIsDisabled.
@Test
public void failsCopyFolderUnderNewNameWhenTargetFolderContainsItemWithSameNameAndOverwritingIsDisabled() throws Exception {
VirtualFile folder = getRoot().createFolder(generateFolderName());
VirtualFile file = folder.createFile(generateFileName(), DEFAULT_CONTENT);
VirtualFile targetFolder = getRoot().createFolder(generateFolderName());
VirtualFile conflictFolder = targetFolder.createFolder("new_name");
try {
folder.copyTo(targetFolder, "new_name", false);
thrown.expect(ConflictException.class);
} catch (ConflictException expected) {
assertNull(getRoot().getChild(conflictFolder.getPath().newPath(file.getName())));
}
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class MemoryVirtualFileTest method failsUpdateContentOfLockedFileByBytesWithoutLockToken.
@Test
public void failsUpdateContentOfLockedFileByBytesWithoutLockToken() throws Exception {
VirtualFile root = getRoot();
VirtualFile file = root.createFile(generateFileName(), DEFAULT_CONTENT);
file.lock(0);
try {
file.updateContent("updated content".getBytes());
thrown.expect(ForbiddenException.class);
} catch (ForbiddenException expected) {
assertEquals(DEFAULT_CONTENT, file.getContentAsString());
}
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class MemoryVirtualFileTest method failsDeleteFolderWhenItContainsLockedFile.
@Test
public void failsDeleteFolderWhenItContainsLockedFile() throws Exception {
VirtualFile folder = getRoot().createFolder(generateFolderName());
Path folderPath = folder.getPath();
VirtualFile file = folder.createFile(generateFileName(), DEFAULT_CONTENT);
Path filePath = file.getPath();
file.lock(0);
try {
folder.delete();
thrown.expect(ForbiddenException.class);
} catch (ForbiddenException e) {
assertEquals(folder, getRoot().getChild(folderPath));
assertEquals(file, getRoot().getChild(filePath));
}
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class MemoryVirtualFileTest method updatesFolderInSearcherWhenItIsRenamed.
@Test
public void updatesFolderInSearcherWhenItIsRenamed() throws Exception {
VirtualFile folder = getRoot().createFolder(generateFolderName());
String oldPath = folder.getPath().toString();
Mockito.reset(searcher);
VirtualFile renamed = folder.rename("new_name");
verify(searcher).add(renamed);
verify(searcher).delete(oldPath, false);
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method updatesContentByString.
@Test
public void updatesContentByString() throws Exception {
VirtualFile root = getRoot();
VirtualFile file = root.createFile(generateFileName(), DEFAULT_CONTENT);
file.updateContent("updated content");
assertionHelper.assertThatIoFileHasContent(file.getPath(), "updated content".getBytes());
assertEquals("updated content", file.getContentAsString());
}
Aggregations