use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method compressFolderToTarArchive.
@Test
public void compressFolderToTarArchive() throws Exception {
VirtualFile folder = getRoot().createFolder(generateFolderName());
Archiver archiver = mock(Archiver.class);
when(archiverFactory.createArchiver(eq(folder), eq("tar"))).thenReturn(archiver);
folder.tar();
verify(archiver).compress(any(OutputStream.class), any(VirtualFileFilter.class));
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest 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");
assertionHelper.assertThatIoFileHasContent(renamedFile.getPath(), DEFAULT_CONTENT_BYTES);
assertionHelper.assertThatMetadataIoFileHasContent(renamedFile.getPath(), serializeVirtualFileMetadata(ImmutableMap.of("property1", "value1")));
assertionHelper.assertThatIoFileDoesNotExist(filePath);
assertionHelper.assertThatMetadataIoFileDoesNotExist(filePath);
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method failsMoveFolderWhenTargetFolderContainsItemWithTheSameNameAndOverwritingIsDisabled.
@Test
public void failsMoveFolderWhenTargetFolderContainsItemWithTheSameNameAndOverwritingIsDisabled() throws Exception {
VirtualFile folder = getRoot().createFolder(generateFolderName());
VirtualFile file = folder.createFile(generateFileName(), DEFAULT_CONTENT);
VirtualFile targetFolder = getRoot().createFolder(generateFolderName());
VirtualFile conflictFolder = targetFolder.createFolder(folder.getName());
try {
folder.moveTo(targetFolder);
thrown.expect(ConflictException.class);
} catch (ConflictException expected) {
assertionHelper.assertThatIoFileDoesNotExist(conflictFolder.getPath().newPath(file.getName()));
assertionHelper.assertThatIoFileExists(folder.getPath());
assertionHelper.assertThatIoFileHasContent(file.getPath(), DEFAULT_CONTENT_BYTES);
}
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class MemoryVirtualFileTest method failsUpdateContentOfLockedFileByStringWhenLockTokenIsInvalid.
@Test
public void failsUpdateContentOfLockedFileByStringWhenLockTokenIsInvalid() throws Exception {
VirtualFile root = getRoot();
VirtualFile file = root.createFile(generateFileName(), DEFAULT_CONTENT);
String invalidLockToken = invalidateLockToken(file.lock(0));
try {
file.updateContent("updated content", invalidLockToken);
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 createsFolderHierarchy.
@Test
public void createsFolderHierarchy() throws Exception {
VirtualFile root = getRoot();
VirtualFile folder = root.createFolder("a/b");
assertEquals(folder, root.getChild(Path.of("a/b")));
}
Aggregations