use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class SubversionProjectImporterTest method testInvalidImportSources.
/**
* Test for {@link SubversionProjectImporter#importSources(org.eclipse.che.api.project.server.FolderEntry, org.eclipse.che.api.core.model.project.SourceStorage, org.eclipse.che.api.core.util.LineConsumerFactory)}
* invalid url.
*
* @throws Exception if anything goes wrong
*/
@Test
public void testInvalidImportSources() throws Exception {
final String projectName = NameGenerator.generate("project-", 3);
//root.getChild(org.eclipse.che.api.vfs.Path.of(projectName));
final VirtualFile virtualFile = root.createFolder(projectName);
FolderEntry projectFolder = new FolderEntry(virtualFile);
try {
String fakeUrl = Paths.get(repoRoot.getAbsolutePath()).toUri() + "fake";
when(sourceStorage.getLocation()).thenReturn(fakeUrl);
projectImporter.importSources(projectFolder, sourceStorage, new TestUtils.SystemOutLineConsumerFactory());
fail("The code above should had failed");
} catch (SubversionException e) {
final String message = e.getMessage();
boolean assertBoolean = Pattern.matches("svn: (E[0-9]{6}: )?URL 'file://.*/fake' doesn't exist\n?", message.trim());
assertTrue(message, assertBoolean);
}
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest 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) {
assertionHelper.assertThatIoFileHasContent(file.getPath(), DEFAULT_CONTENT_BYTES);
}
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method getsContentAsStream.
@Test
public void getsContentAsStream() throws Exception {
VirtualFile root = getRoot();
VirtualFile file = root.createFile(generateFileName(), DEFAULT_CONTENT);
byte[] bytes;
try (InputStream content = file.getContent()) {
bytes = ByteStreams.toByteArray(content);
}
assertionHelper.assertThatIoFileHasContent(file.getPath(), DEFAULT_CONTENT_BYTES);
assertEquals(DEFAULT_CONTENT, new String(bytes));
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method getFileTreeAsList.
private List<VirtualFile> getFileTreeAsList(VirtualFile rootOfTree) throws Exception {
List<VirtualFile> list = newArrayList();
rootOfTree.accept(new VirtualFileVisitor() {
@Override
public void visit(VirtualFile virtualFile) throws ServerException {
list.add(virtualFile);
if (virtualFile.isFolder()) {
for (VirtualFile child : virtualFile.getChildren()) {
child.accept(this);
}
}
}
});
return list;
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method folderContentLengthIsZero.
@Test
public void folderContentLengthIsZero() throws Exception {
VirtualFile root = getRoot();
VirtualFile folder = root.createFolder(generateFolderName());
assertEquals(0, folder.getLength());
}
Aggregations