Skip to content

Commit a795283

Browse files
committed
Add testDeleteDirectoryNoopIfAbsent
Rename previous to testDeleteDirectoryFailsOnFile
1 parent dcf0197 commit a795283

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/test/java/org/apache/commons/io/FileUtilsTest.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import static org.junit.jupiter.api.Assertions.assertNotNull;
2424
import static org.junit.jupiter.api.Assertions.assertNull;
2525
import static org.junit.jupiter.api.Assertions.assertSame;
26+
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
2627
import static org.junit.jupiter.api.Assertions.assertThrows;
2728
import static org.junit.jupiter.api.Assertions.assertThrowsExactly;
2829
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -1547,10 +1548,24 @@ public void testDelete() throws Exception {
15471548
}
15481549

15491550
@Test
1550-
public void testDeleteDirectoryWithNonDirectory() {
1551+
public void testDeleteDirectoryFailsOnFile() {
1552+
// Fail request for a File
15511553
assertThrows(IllegalArgumentException.class, () -> FileUtils.deleteDirectory(testFile1));
15521554
}
15531555

1556+
@Test
1557+
public void testDeleteDirectoryNoopIfAbsent() {
1558+
// Noop on non-existent entry
1559+
assertDoesNotThrow(() -> FileUtils.deleteDirectory(new File("does not exist.nope")));
1560+
}
1561+
1562+
@Test
1563+
public void testDeleteDirectoryIsSymLink() throws IOException {
1564+
final Path symlinkedDir = createTempSymlinkedRelativeDir();
1565+
FileUtils.deleteDirectory(symlinkedDir.toFile());
1566+
assertFalse(Files.exists(symlinkedDir));
1567+
}
1568+
15541569
@Test
15551570
public void testDeleteQuietlyDir() throws IOException {
15561571
final File testDirectory = new File(tempDirFile, "testDeleteQuietlyDir");

0 commit comments

Comments
 (0)