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 2024/03/24 14:40:45 UTC
(commons-io) branch master updated: Passes on macOS, fails on Linux and Windows with AccessDeniedException.
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 4b47b44bc Passes on macOS, fails on Linux and Windows with AccessDeniedException.
4b47b44bc is described below
commit 4b47b44bc0b10b456d03a04cb52433c15df21496
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Mar 24 10:40:40 2024 -0400
Passes on macOS, fails on Linux and Windows with AccessDeniedException.
- Better comment
- Bullet-proof old test for re-runs
---
.../java/org/apache/commons/io/FileUtilsTest.java | 24 +++++++---------------
1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/src/test/java/org/apache/commons/io/FileUtilsTest.java b/src/test/java/org/apache/commons/io/FileUtilsTest.java
index 626f50747..d3aa328f7 100644
--- a/src/test/java/org/apache/commons/io/FileUtilsTest.java
+++ b/src/test/java/org/apache/commons/io/FileUtilsTest.java
@@ -1731,28 +1731,18 @@ public class FileUtilsTest extends AbstractTempDirTest {
}
@Test
- public void testForceDeleteUnwritableDirectory() throws Exception {
- try (TempDirectory destDir = TempDirectory.create("dir-");
- TempFile destination = TempFile.create(destDir, "test-", ".txt")) {
- // sanity check structure
- assertTrue(Files.isDirectory(destDir.get()));
- assertEquals(destDir.get(), destination.get().getParent());
- // sanity check attributes
- final File file = destDir.toFile();
+ public void testForceDeleteUnwritableFile() throws Exception {
+ try (TempFile destination = TempFile.create("test-", ".txt")) {
+ final File file = destination.toFile();
assertTrue(file.canWrite());
assertTrue(file.setWritable(false));
assertFalse(file.canWrite());
assertTrue(file.canRead());
- // sanity check that File.delete() cannot delete non-empty directories.
- assertFalse(file.delete());
+ // sanity check that File.delete() deletes unwritable files.
+ assertTrue(file.delete());
}
- try (TempDirectory destDir = TempDirectory.create("dir-");
- TempFile destination = TempFile.create(destDir, "test-", ".txt")) {
- // sanity check structure
- assertTrue(Files.isDirectory(destDir.get()));
- assertEquals(destDir.get(), destination.get().getParent());
- // sanity check attributes
- final File file = destDir.toFile();
+ try (TempFile destination = TempFile.create("test-", ".txt")) {
+ final File file = destination.toFile();
// real test
assertTrue(file.canWrite());
assertTrue(file.setWritable(false));