1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.vfs.provider.zip.test;
18
19 import junit.framework.Test;
20 import org.apache.commons.AbstractVfsTestCase;
21 import org.apache.commons.vfs.FileObject;
22 import org.apache.commons.vfs.FileSystemManager;
23 import org.apache.commons.vfs.impl.DefaultFileSystemManager;
24 import org.apache.commons.vfs.provider.zip.ZipFileProvider;
25 import org.apache.commons.vfs.test.AbstractProviderTestConfig;
26 import org.apache.commons.vfs.test.ProviderTestConfig;
27 import org.apache.commons.vfs.test.ProviderTestSuite;
28
29 import java.io.File;
30
31 /***
32 * Tests for the Zip file system.
33 *
34 * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
35 */
36 public class ZipProviderTestCase
37 extends AbstractProviderTestConfig
38 implements ProviderTestConfig
39 {
40 /***
41 * Creates the test suite for the zip file system.
42 */
43 public static Test suite() throws Exception
44 {
45 return new ProviderTestSuite(new ZipProviderTestCase());
46 }
47
48 /***
49 * Prepares the file system manager.
50 */
51 public void prepare(final DefaultFileSystemManager manager) throws Exception
52 {
53 manager.addProvider("zip", new ZipFileProvider());
54 manager.addExtensionMap("zip", "zip");
55 manager.addMimeTypeMap("application/zip", "zip");
56 }
57
58 /***
59 * Returns the base folder for read tests.
60 */
61 public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception
62 {
63 final File zipFile = AbstractVfsTestCase.getTestResource("test.zip");
64 final String uri = "zip:" + zipFile.getAbsolutePath() + "!/";
65 return manager.resolveFile(uri);
66 }
67 }