Search in sources :

Example 1 with Archiver

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

the class LocalVirtualFileTest method addFolderInSearcherAfterExtractTarArchive.

@Test
public void addFolderInSearcherAfterExtractTarArchive() throws Exception {
    VirtualFile folder = getRoot().createFolder(generateFolderName());
    Mockito.reset(searcher);
    Archiver archiver = mock(Archiver.class);
    when(archiverFactory.createArchiver(eq(folder), eq("tar"))).thenReturn(archiver);
    folder.untar(new ByteArrayInputStream(new byte[0]), false, 0);
    verify(searcher).add(folder);
}
Also used : VirtualFile(org.eclipse.che.api.vfs.VirtualFile) ByteArrayInputStream(java.io.ByteArrayInputStream) Archiver(org.eclipse.che.api.vfs.Archiver) Test(org.junit.Test)

Example 2 with Archiver

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

the class LocalVirtualFileTest method addFolderInSearcherAfterExtractZipArchive.

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

Example 3 with Archiver

use of org.eclipse.che.api.vfs.Archiver 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 4 with Archiver

use of org.eclipse.che.api.vfs.Archiver 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));
}
Also used : VirtualFile(org.eclipse.che.api.vfs.VirtualFile) VirtualFileFilter(org.eclipse.che.api.vfs.VirtualFileFilter) DataOutputStream(java.io.DataOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) Archiver(org.eclipse.che.api.vfs.Archiver) Test(org.junit.Test)

Example 5 with Archiver

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

the class MemoryVirtualFileTest method addFolderInSearcherAfterExtractZipArchive.

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

Aggregations

Archiver (org.eclipse.che.api.vfs.Archiver)12 VirtualFile (org.eclipse.che.api.vfs.VirtualFile)12 Test (org.junit.Test)12 ByteArrayInputStream (java.io.ByteArrayInputStream)8 InputStream (java.io.InputStream)4 OutputStream (java.io.OutputStream)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 DataOutputStream (java.io.DataOutputStream)2 VirtualFileFilter (org.eclipse.che.api.vfs.VirtualFileFilter)2