commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1802441 - /commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/zip/test/FileLockTestCase.java
Date Thu, 20 Jul 2017 00:06:23 GMT
Author: ggregory
Date: Thu Jul 20 00:06:22 2017
New Revision: 1802441

URL: http://svn.apache.org/viewvc?rev=1802441&view=rev
Log:
Add failing test for Tests https://issues.apache.org/jira/browse/VFS-291 with @Ignore.

Added:
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/zip/test/FileLockTestCase.java

Added: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/zip/test/FileLockTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/zip/test/FileLockTestCase.java?rev=1802441&view=auto
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/zip/test/FileLockTestCase.java
(added)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/zip/test/FileLockTestCase.java
Thu Jul 20 00:06:22 2017
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.vfs2.provider.zip.test;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.commons.AbstractVfsTestCase;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.vfs2.FileObject;
+import org.apache.commons.vfs2.FileSystemManager;
+import org.apache.commons.vfs2.VFS;
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Tests https://issues.apache.org/jira/browse/VFS-291
+ */
+public class FileLockTestCase {
+
+    /**
+     * This test checks whether we can modify an underlying zip file after we have performed
IO operations on files
+     * within it, but although we no longer have any FileObjects explicitely open.
+     * 
+     * @throws IOException
+     */
+    @Test
+    @Ignore
+    public void testResourcesReleasedByZipFileProvider() throws Exception {
+        FileSystemManager manager = VFS.getManager();
+        //
+        // We copy the normal test zip to a second, nominally temporary, file so that we
can try to delete it with
+        // impunity. Since the test fails, the file will be left behind, so it should probably
be created in a temporary
+        // directory somewhere.
+        //
+        final File zipFile = new File("src/test/resources/test-data/test.zip");
+        final File newZipFile = new File(AbstractVfsTestCase.getTestDirectory(), "test2.zip");
+        FileUtils.copyFile(zipFile, newZipFile);
+
+        final String uri = "zip:file:" + newZipFile.getAbsolutePath() + "!/read-tests/file1.txt";
+        try (final FileObject fileOne = manager.resolveFile(uri)) {
+            fileOne.getContent().getInputStream().close();
+        }
+
+        Assert.assertTrue("Could not delete file", newZipFile.delete());
+    }
+}



Mime
View raw message