1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.commons.compress;
20
21 import java.io.File;
22 import java.io.FileInputStream;
23
24 import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
25 import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
26 import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
27 import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
28
29
30 public class ChainingTestCase extends AbstractTestCase {
31
32 public void testTarGzip() throws Exception {
33 File file = getFile("bla.tgz");
34 final TarArchiveInputStream is = new TarArchiveInputStream(new GzipCompressorInputStream(new FileInputStream(file)));
35 final TarArchiveEntry entry = (TarArchiveEntry)is.getNextEntry();
36 assertNotNull(entry);
37 assertEquals("test1.xml", entry.getName());
38 is.close();
39 }
40
41 public void testTarBzip2() throws Exception {
42 File file = getFile("bla.tar.bz2");
43 final TarArchiveInputStream is = new TarArchiveInputStream(new BZip2CompressorInputStream(new FileInputStream(file)));
44 final TarArchiveEntry entry = (TarArchiveEntry)is.getNextEntry();
45 assertNotNull(entry);
46 assertEquals("test1.xml", entry.getName());
47 is.close();
48 }
49 }