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 2020/12/05 19:20:32 UTC
[commons-io] branch master updated: Add test
testForceDeleteReadOnlyFile.
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-io.git
The following commit(s) were added to refs/heads/master by this push:
new 1dc7834 Add test testForceDeleteReadOnlyFile.
1dc7834 is described below
commit 1dc7834e639b2245ada901bc011f651a09a98aaf
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Dec 5 14:20:28 2020 -0500
Add test testForceDeleteReadOnlyFile.
---
.../java/org/apache/commons/io/FileUtilsTestCase.java | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/src/test/java/org/apache/commons/io/FileUtilsTestCase.java b/src/test/java/org/apache/commons/io/FileUtilsTestCase.java
index 9b19b15..f923c24 100644
--- a/src/test/java/org/apache/commons/io/FileUtilsTestCase.java
+++ b/src/test/java/org/apache/commons/io/FileUtilsTestCase.java
@@ -1465,6 +1465,24 @@ public class FileUtilsTestCase {
}
@Test
+ public void testForceDeleteReadOnlyFile() throws Exception {
+ File destination = File.createTempFile("test-", ".txt");
+ assertTrue(destination.setReadOnly());
+ assertTrue(destination.canRead());
+ assertFalse(destination.canWrite());
+ // sanity check
+ assertTrue(destination.delete());
+ destination = File.createTempFile("test-", ".txt");
+ // real test
+ assertTrue(destination.setReadOnly());
+ assertTrue(destination.canRead());
+ assertFalse(destination.canWrite());
+ assertTrue(destination.exists(), "File doesn't exist to delete");
+ FileUtils.forceDelete(destination);
+ assertTrue(!destination.exists(), "Check deletion");
+ }
+
+ @Test
public void testForceMkdir() throws Exception {
// Tests with existing directory
FileUtils.forceMkdir(temporaryFolder);