1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.vfs2.provider.res;
19
20 import org.apache.commons.vfs2.AbstractProviderTestCase;
21 import org.apache.commons.vfs2.AbstractProviderTestConfig;
22 import org.apache.commons.vfs2.AbstractVfsTestCase;
23 import org.apache.commons.vfs2.FileName;
24 import org.apache.commons.vfs2.FileObject;
25 import org.apache.commons.vfs2.FileSystemException;
26 import org.apache.commons.vfs2.FileSystemManager;
27 import org.apache.commons.vfs2.ProviderTestSuite;
28 import org.apache.commons.vfs2.impl.DefaultFileSystemManager;
29 import org.apache.commons.vfs2.provider.zip.ZipFileProvider;
30 import org.junit.Assert;
31 import org.junit.Test;
32
33
34
35
36 public class Vfs444TestCase extends AbstractProviderTestConfig {
37
38 public static class Vfs444Tests extends AbstractProviderTestCase {
39
40 @Test
41 public void testResolveFullPathFile0() throws FileSystemException {
42 final FileObject result = getManager().resolveFile("res:test-data/test.zip");
43 Assert.assertTrue(result.exists());
44 }
45
46 @Test
47 public void testResolveFullPathFile1() throws FileSystemException {
48 final FileObject result = getManager().resolveFile("res:/test-data/test.zip");
49 Assert.assertTrue(result.exists());
50 }
51
52 @Test
53 public void testResolveFullPathFile2() throws FileSystemException {
54 final FileObject result = getManager().resolveFile("res://test-data/test.zip");
55 Assert.assertTrue(result.exists());
56 }
57
58 @Test
59 public void testResolveFullPathURI0() throws FileSystemException {
60 final FileName result = getManager().resolveURI("res:test-data/test.zip");
61 Assert.assertTrue(result.isFile());
62 }
63
64 @Test
65 public void testResolveFullPathURI1() throws FileSystemException {
66 final FileName result = getManager().resolveURI("res:/test-data/test.zip");
67 Assert.assertTrue(result.isFile());
68 }
69
70 @Test
71 public void testResolveFullPathURI2() throws FileSystemException {
72 final FileName result = getManager().resolveURI("res://test-data/test.zip");
73 Assert.assertTrue(result.isFile());
74 }
75
76 @Test
77 public void testResolvePartialPath1() throws FileSystemException {
78 final FileName result = getManager().resolveURI("res:test-data");
79 Assert.assertTrue(result.isFile());
80 }
81
82 @Test
83 public void testResolvePartialPath2() throws FileSystemException {
84 final FileName root = getManager().resolveURI("res:test-data");
85 final FileName file = getManager().resolveName(root, "test.zip");
86 final String uri = file.getURI();
87 final FileObject result = getManager().resolveFile(uri);
88 Assert.assertNotNull(result);
89 Assert.assertTrue(result.exists());
90 }
91 }
92
93 public static junit.framework.Test suite() throws Exception {
94 final ProviderTestSuiteTestSuite.html#ProviderTestSuite">ProviderTestSuite suite = new ProviderTestSuite(new Vfs444TestCase(), true);
95 suite.addTests(Vfs444Tests.class);
96 return suite;
97 }
98
99
100
101
102 @Override
103 public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception {
104 final String baseDir = AbstractVfsTestCase.getResourceTestDirectory();
105 return manager.resolveFile("zip:res:" + baseDir + "/test.zip");
106 }
107
108
109
110
111 @Override
112 public void prepare(final DefaultFileSystemManager manager) throws Exception {
113 manager.addProvider("res", new ResourceFileProvider());
114 manager.addProvider("zip", new ZipFileProvider());
115 }
116 }