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 org.apache.commons.vfs2.AbstractProviderTestConfig;
20 import org.apache.commons.vfs2.AbstractVfsTestCase;
21 import org.apache.commons.vfs2.FileObject;
22 import org.apache.commons.vfs2.FileSystemManager;
23 import org.apache.commons.vfs2.FileSystemOptions;
24 import org.apache.commons.vfs2.ProviderTestSuite;
25 import org.apache.commons.vfs2.auth.StaticUserAuthenticator;
26 import org.apache.commons.vfs2.impl.DefaultFileSystemConfigBuilder;
27 import org.apache.commons.vfs2.impl.DefaultFileSystemManager;
28
29 import junit.framework.Test;
30
31
32
33
34 public class NestedTarTestCase extends AbstractProviderTestConfig {
35
36
37
38 public static Test suite() throws Exception {
39 return new ProviderTestSuite(new NestedTarTestCase(), true);
40 }
41
42
43
44
45 @Override
46 public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception {
47
48 final FileSystemOptions opts = new FileSystemOptions();
49 DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts,
50 new StaticUserAuthenticator("domain", null, null));
51
52
53 final String tarFilePath = AbstractVfsTestCase.getTestResource("nested.tar").getAbsolutePath();
54
55
56 final String uri = "tar:file:" + tarFilePath + "!/test.tar";
57 final FileObject tarFile = manager.resolveFile(uri, opts);
58 final FileObject nestedFS = manager.createFileSystem(tarFile);
59 return nestedFS.resolveFile("/");
60 }
61
62
63
64
65 @Override
66 public void prepare(final DefaultFileSystemManager manager) throws Exception {
67 manager.addProvider("tar", new TarFileProvider());
68 manager.addExtensionMap("tar", "tar");
69 manager.addMimeTypeMap("application/x-tar", "tar");
70 }
71 }