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 d3910a91 Test PathUtils.deleteDirectory(Path) d3910a91 is described below commit d3910a914787db46207886bc6cd3c3ac803a4f76 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Thu Jun 8 08:33:54 2023 -0400 Test PathUtils.deleteDirectory(Path) --- .../commons/io/file/PathUtilsDeleteDirectoryTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/test/java/org/apache/commons/io/file/PathUtilsDeleteDirectoryTest.java b/src/test/java/org/apache/commons/io/file/PathUtilsDeleteDirectoryTest.java index 121b2dc0..298e24c9 100644 --- a/src/test/java/org/apache/commons/io/file/PathUtilsDeleteDirectoryTest.java +++ b/src/test/java/org/apache/commons/io/file/PathUtilsDeleteDirectoryTest.java @@ -18,9 +18,12 @@ package org.apache.commons.io.file; import static org.apache.commons.io.file.CounterAssertions.assertCounts; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.IOException; import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; import org.junit.jupiter.api.Test; @@ -30,6 +33,18 @@ import org.junit.jupiter.api.Test; */ public class PathUtilsDeleteDirectoryTest extends AbstractTempDirTest { + @Test + public void testDeleteAbsentDirectory() throws IOException { + final Path absent = tempDirPath.resolve("ThisDirectoryDoesNotExist"); + assertFalse(Files.exists(absent)); + final Class<IllegalArgumentException> expectedType = IllegalArgumentException.class; + assertThrows(expectedType, () -> PathUtils.deleteDirectory(absent)); + assertThrows(expectedType, () -> PathUtils.deleteDirectory(absent, StandardDeleteOption.OVERRIDE_READ_ONLY)); + assertThrows(expectedType, () -> PathUtils.deleteDirectory(absent, PathUtils.EMPTY_DELETE_OPTION_ARRAY)); + // This will throw if not empty. + Files.deleteIfExists(tempDirPath); + } + /** * Tests a directory with one file of size 0. */