File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
src/test/java/org/apache/commons/io Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 2020import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
2121import static org .junit .jupiter .api .Assertions .assertEquals ;
2222import static org .junit .jupiter .api .Assertions .assertFalse ;
23+ import static org .junit .jupiter .api .Assertions .assertInstanceOf ;
2324import static org .junit .jupiter .api .Assertions .assertNotEquals ;
2425import static org .junit .jupiter .api .Assertions .assertNotNull ;
2526import static org .junit .jupiter .api .Assertions .assertNull ;
@@ -1820,7 +1821,11 @@ void testForceDeleteRestoresReadOnlyOnFailure(@TempDir Path tempDir) throws Exce
18201821 assertFalse (file .canWrite (), "Sanity: Windows canWrite() should be false when dos:readonly is set" );
18211822
18221823 // 3) Attempt forced deletion; should fail with AccessDeniedException due to ACLs.
1823- assertThrows (AccessDeniedException .class , () -> FileUtils .forceDelete (file ), "Deletion must fail because DELETE/DELETE_CHILD are denied" );
1824+ final IOException wrappedException = assertThrows (IOException .class ,
1825+ () -> FileUtils .forceDelete (file ),
1826+ "Deletion must fail because DELETE/DELETE_CHILD are denied" );
1827+ final Throwable cause = wrappedException .getCause ();
1828+ assertInstanceOf (AccessDeniedException .class , cause , "Cause must be AccessDeniedException" );
18241829
18251830 // 4) Critical assertion: even though deletion failed, the DOS readonly flag must be restored.
18261831 assertTrue (isDosReadOnly (readOnly ), "dos:readonly must be preserved/restored after failed deletion" );
You can’t perform that action at this time.
0 commit comments