File tree Expand file tree Collapse file tree
src/test/java/org/apache/commons/io Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1464,6 +1464,24 @@ public void testForceDeleteDir() throws Exception {
14641464 assertFalse (testDirectory .exists (), "TestDirectory must not exist" );
14651465 }
14661466
1467+ @ Test
1468+ public void testForceDeleteReadOnlyFile () throws Exception {
1469+ File destination = File .createTempFile ("test-" , ".txt" );
1470+ assertTrue (destination .setReadOnly ());
1471+ assertTrue (destination .canRead ());
1472+ assertFalse (destination .canWrite ());
1473+ // sanity check
1474+ assertTrue (destination .delete ());
1475+ destination = File .createTempFile ("test-" , ".txt" );
1476+ // real test
1477+ assertTrue (destination .setReadOnly ());
1478+ assertTrue (destination .canRead ());
1479+ assertFalse (destination .canWrite ());
1480+ assertTrue (destination .exists (), "File doesn't exist to delete" );
1481+ FileUtils .forceDelete (destination );
1482+ assertTrue (!destination .exists (), "Check deletion" );
1483+ }
1484+
14671485 @ Test
14681486 public void testForceMkdir () throws Exception {
14691487 // Tests with existing directory
You can’t perform that action at this time.
0 commit comments