1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.vfs2.provider.tar;
18
19 import java.io.File;
20 import java.io.IOException;
21
22 import org.apache.commons.vfs2.FileObject;
23 import org.apache.commons.vfs2.FileSystemManager;
24 import org.apache.commons.vfs2.VFS;
25 import org.junit.Assert;
26 import org.junit.Test;
27
28
29
30
31
32
33 public class CreateFileSystemTestCase {
34
35 private FileObject createFileSystem(final String testFilePath) throws IOException {
36
37 final File testFile = new File(testFilePath);
38 final FileSystemManager manager = VFS.getManager();
39
40
41 try (FileObject localFileObject = manager.resolveFile(testFile.getAbsolutePath())) {
42 return manager.createFileSystem(localFileObject);
43 }
44 }
45
46 @Test
47 public void testTarFile() throws IOException {
48
49 final String testFilePath = "src/test/resources/test-data/test.tar";
50 try (FileObject fileObject = createFileSystem(testFilePath)) {
51 Assert.assertTrue(fileObject instanceof TarFileObject);
52 }
53 }
54
55 @Test
56 public void testTbz2File() throws IOException {
57
58 final String testFilePath = "src/test/resources/test-data/test.tbz2";
59 try (FileObject fileObject = createFileSystem(testFilePath)) {
60 Assert.assertTrue(fileObject instanceof TarFileObject);
61 }
62 }
63
64 @Test
65 public void testTgzFile() throws IOException {
66
67 final String testFilePath = "src/test/resources/test-data/test.tgz";
68 try (FileObject fileObject = createFileSystem(testFilePath)) {
69 Assert.assertTrue(fileObject instanceof TarFileObject);
70 }
71 }
72 }