You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2021/03/30 12:55:48 UTC
[commons-vfs] branch master updated: Add tests for Gzip, Jar, Tar,
Zip; inspired by P# #92 from PeterAlfredLee GZip test. Note that
testCreateGzipFileSystem fails and is ignored.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-vfs.git
The following commit(s) were added to refs/heads/master by this push:
new 0c4dfca Add tests for Gzip, Jar, Tar, Zip; inspired by P# #92 from PeterAlfredLee GZip test. Note that testCreateGzipFileSystem fails and is ignored.
0c4dfca is described below
commit 0c4dfcaf35b7ac9a2790f800effb406d2001393a
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Mar 30 08:55:43 2021 -0400
Add tests for Gzip, Jar, Tar, Zip; inspired by P# #92 from
PeterAlfredLee GZip test. Note that testCreateGzipFileSystem fails and
is ignored.
---
.../vfs2/impl/DefaultFileSystemManagerTest.java | 38 ++++++++++++++++++++--
1 file changed, 36 insertions(+), 2 deletions(-)
diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/impl/DefaultFileSystemManagerTest.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/impl/DefaultFileSystemManagerTest.java
index 2b8f8c2..83625b8 100644
--- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/impl/DefaultFileSystemManagerTest.java
+++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/impl/DefaultFileSystemManagerTest.java
@@ -28,8 +28,13 @@ import org.apache.commons.vfs2.FileSystemManager;
import org.apache.commons.vfs2.FilesCache;
import org.apache.commons.vfs2.VFS;
import org.apache.commons.vfs2.cache.NullFilesCache;
+import org.apache.commons.vfs2.provider.bzip2.Bzip2FileObject;
+import org.apache.commons.vfs2.provider.gzip.GzipFileObject;
+import org.apache.commons.vfs2.provider.jar.JarFileObject;
import org.apache.commons.vfs2.provider.ram.RamFileProvider;
+import org.apache.commons.vfs2.provider.zip.ZipFileObject;
import org.junit.Assert;
+import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mockito;
@@ -78,12 +83,41 @@ public class DefaultFileSystemManagerTest {
}
}
+ private void testCreateFileSystem(final String path, Class<?> clazz) throws FileSystemException {
+ FileSystemManager manager = VFS.getManager();
+ try (FileObject localFileObject = manager.resolveFile(new File(path).getAbsolutePath());
+ FileObject fileObject = manager.createFileSystem(localFileObject);) {
+ Assert.assertEquals(clazz, fileObject.getClass());
+ }
+ }
+
+ @Test
+ @Ignore
+ public void testCreateGzipFileSystem() throws FileSystemException {
+ testCreateFileSystem("src/test/resources/test-data/好.txt.gz", GzipFileObject.class);
+ }
+
+ @Test
+ public void testCreateBz2FileSystem() throws FileSystemException {
+ testCreateFileSystem("src/test/resources/test-data/bla.txt.bz2", Bzip2FileObject.class);
+ }
+
+ @Test
+ public void testCreateJarFileSystem() throws FileSystemException {
+ testCreateFileSystem("src/test/resources/test-data/nested.jar", JarFileObject.class);
+ }
+
+ @Test
+ public void testCreateZipFileSystem() throws FileSystemException {
+ testCreateFileSystem("src/test/resources/test-data/nested.zip", ZipFileObject.class);
+ }
+
@Test
public void testFileCacheEmptyAfterManagerClose() throws FileSystemException {
final FileSystemManager manager = VFS.getManager();
Assert.assertNotNull(manager);
try (final FileObject fileObject = manager
- .resolveFile(Paths.get("src/test/resources/test-data/read-tests/file1.txt").toUri())) {
+ .resolveFile(Paths.get("src/test/resources/test-data/read-tests/file1.txt").toUri())) {
Assert.assertTrue(fileObject.exists());
final FilesCache filesCache = manager.getFilesCache();
final FileName name = fileObject.getName();
@@ -103,7 +137,7 @@ public class DefaultFileSystemManagerTest {
final FileSystemManager manager = VFS.getManager();
Assert.assertNotNull(manager);
try (final FileObject fileObject = manager
- .resolveFile(Paths.get("src/test/resources/test-data/read-tests/file1.txt").toUri())) {
+ .resolveFile(Paths.get("src/test/resources/test-data/read-tests/file1.txt").toUri())) {
Assert.assertTrue(fileObject.exists());
final FilesCache filesCache = manager.getFilesCache();
final FileName name = fileObject.getName();