Search in sources :

Example 56 with VirtualFile

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());
}
Also used : VirtualFile(org.eclipse.che.api.vfs.VirtualFile) Test(org.junit.Test)

Example 57 with VirtualFile

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());
}
Also used : VirtualFile(org.eclipse.che.api.vfs.VirtualFile) Test(org.junit.Test)

Example 58 with VirtualFile

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());
    }
}
Also used : VirtualFile(org.eclipse.che.api.vfs.VirtualFile) Path(org.eclipse.che.api.vfs.Path) ForbiddenException(org.eclipse.che.api.core.ForbiddenException) Test(org.junit.Test)

Example 59 with VirtualFile

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());
}
Also used : VirtualFile(org.eclipse.che.api.vfs.VirtualFile) Test(org.junit.Test)

Example 60 with VirtualFile

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);
}
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