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 static org.junit.jupiter.api.Assertions.assertInstanceOf;
20
21 import java.io.File;
22 import java.io.IOException;
23
24 import org.apache.commons.vfs2.FileObject;
25 import org.apache.commons.vfs2.FileSystemManager;
26 import org.apache.commons.vfs2.VFS;
27 import org.junit.jupiter.api.Test;
28
29
30
31
32
33 public class CreateFileSystemTest {
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 assertInstanceOf(TarFileObject.class, fileObject);
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 assertInstanceOf(TarFileObject.class, fileObject);
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 assertInstanceOf(TarFileObject.class, fileObject);
70 }
71 }
72
73 }