Search in sources :

Example 61 with VirtualFile

use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.

the class MemoryVirtualFileTest method locksFile.

@Test
public void locksFile() throws Exception {
    VirtualFile file = getRoot().createFile(generateFileName(), DEFAULT_CONTENT);
    file.lock(0);
    assertTrue(file.isLocked());
}
Also used : VirtualFile(org.eclipse.che.api.vfs.VirtualFile) Test(org.junit.Test)

Example 62 with VirtualFile

use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.

the class LocalVirtualFileTest method checksIsRoot.

@Test
public void checksIsRoot() throws Exception {
    VirtualFile root = getRoot();
    VirtualFile file = root.createFile(generateFileName(), DEFAULT_CONTENT);
    VirtualFile folder = root.createFolder(generateFolderName());
    assertFalse(file.isRoot());
    assertFalse(folder.isRoot());
    assertTrue(root.isRoot());
}
Also used : VirtualFile(org.eclipse.che.api.vfs.VirtualFile) Test(org.junit.Test)

Example 63 with VirtualFile

use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.

the class LocalVirtualFileTest method deletesLockedFileWithLockToken.

@Test
public void deletesLockedFileWithLockToken() throws Exception {
    VirtualFile folder = getRoot().createFolder(generateFolderName());
    VirtualFile file = folder.createFile(generateFileName(), DEFAULT_CONTENT);
    file.setProperty("property1", "value1");
    Path filePath = file.getPath();
    String lockToken = file.lock(0);
    file.delete(lockToken);
    assertionHelper.assertThatIoFileDoesNotExist(filePath);
    assertionHelper.assertThatMetadataIoFileDoesNotExist(filePath);
    assertionHelper.assertThatLockIoFileDoesNotExist(filePath);
}
Also used : VirtualFile(org.eclipse.che.api.vfs.VirtualFile) Path(org.eclipse.che.api.vfs.Path) Test(org.junit.Test)

Example 64 with VirtualFile

use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.

the class LocalVirtualFileTest method unzipsInFolder.

@Test
public void unzipsInFolder() throws Exception {
    VirtualFile folder = getRoot().createFolder(generateFolderName());
    Archiver archiver = mock(Archiver.class);
    when(archiverFactory.createArchiver(eq(folder), eq("zip"))).thenReturn(archiver);
    folder.unzip(new ByteArrayInputStream(new byte[0]), false, 0);
    verify(archiver).extract(any(InputStream.class), eq(false), eq(0));
}
Also used : VirtualFile(org.eclipse.che.api.vfs.VirtualFile) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Archiver(org.eclipse.che.api.vfs.Archiver) Test(org.junit.Test)

Example 65 with VirtualFile

use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.

the class LocalVirtualFileTest method getsChildrenWithFilter.

@Test
public void getsChildrenWithFilter() throws Exception {
    VirtualFile root = getRoot();
    root.createFolder(generateFolderName());
    VirtualFile file1 = root.createFile(generateFileName(), DEFAULT_CONTENT);
    VirtualFile file2 = root.createFile(generateFileName(), DEFAULT_CONTENT);
    List<VirtualFile> expectedResult = newArrayList(file1, file2);
    Collections.sort(expectedResult);
    List<VirtualFile> children = root.getChildren(file -> file.equals(file1) || file.equals(file2));
    assertEquals(expectedResult, children);
}
Also used : VirtualFile(org.eclipse.che.api.vfs.VirtualFile) Test(org.junit.Test)

Aggregations

VirtualFile (org.eclipse.che.api.vfs.VirtualFile)321 Test (org.junit.Test)267 Path (org.eclipse.che.api.vfs.Path)62 ForbiddenException (org.eclipse.che.api.core.ForbiddenException)54 ByteArrayInputStream (java.io.ByteArrayInputStream)32 ConflictException (org.eclipse.che.api.core.ConflictException)28 VirtualFileSystem (org.eclipse.che.api.vfs.VirtualFileSystem)27 MemoryVirtualFileSystem (org.eclipse.che.api.vfs.impl.memory.MemoryVirtualFileSystem)22 QueryExpression (org.eclipse.che.api.vfs.search.QueryExpression)22 ServerException (org.eclipse.che.api.core.ServerException)18 Test (org.testng.annotations.Test)18 File (java.io.File)17 Archiver (org.eclipse.che.api.vfs.Archiver)14 InputStream (java.io.InputStream)10 IOException (java.io.IOException)8 ArrayList (java.util.ArrayList)7 OutputStream (java.io.OutputStream)6 LockedFileFinder (org.eclipse.che.api.vfs.LockedFileFinder)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 Map (java.util.Map)5