File tree Expand file tree Collapse file tree
src/test/java/org/apache/commons/io/file Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818package org .apache .commons .io .file ;
1919
2020import static org .apache .commons .io .file .CounterAssertions .assertCounts ;
21+ import static org .junit .jupiter .api .Assertions .assertFalse ;
22+ import static org .junit .jupiter .api .Assertions .assertThrows ;
2123
2224import java .io .IOException ;
2325import java .nio .file .Files ;
26+ import java .nio .file .Path ;
2427import java .nio .file .Paths ;
2528
2629import org .junit .jupiter .api .Test ;
3033 */
3134public class PathUtilsDeleteDirectoryTest extends AbstractTempDirTest {
3235
36+ @ Test
37+ public void testDeleteAbsentDirectory () throws IOException {
38+ final Path absent = tempDirPath .resolve ("ThisDirectoryDoesNotExist" );
39+ assertFalse (Files .exists (absent ));
40+ final Class <IllegalArgumentException > expectedType = IllegalArgumentException .class ;
41+ assertThrows (expectedType , () -> PathUtils .deleteDirectory (absent ));
42+ assertThrows (expectedType , () -> PathUtils .deleteDirectory (absent , StandardDeleteOption .OVERRIDE_READ_ONLY ));
43+ assertThrows (expectedType , () -> PathUtils .deleteDirectory (absent , PathUtils .EMPTY_DELETE_OPTION_ARRAY ));
44+ // This will throw if not empty.
45+ Files .deleteIfExists (tempDirPath );
46+ }
47+
3348 /**
3449 * Tests a directory with one file of size 0.
3550 */
You can’t perform that action at this time.
0 commit comments