@@ -1761,6 +1761,42 @@ void testForceDeleteUnwritableFile() throws Exception {
17611761 }
17621762 }
17631763
1764+ @ Test
1765+ public void testForceDeleteBrokenSymlink () throws Exception {
1766+ final ImmutablePair <Path , Path > pair = createTempSymbolicLinkedRelativeDir ();
1767+ final Path symlinkedDir = pair .getLeft ();
1768+ final Path targetDir = pair .getRight ();
1769+
1770+ Files .delete (targetDir );
1771+ assertFalse (Files .exists (symlinkedDir ));
1772+ assertTrue (Files .isSymbolicLink (symlinkedDir ));
1773+
1774+ FileUtils .forceDelete (symlinkedDir .toFile ());
1775+
1776+ // check targeted symlink is gone
1777+ assertFalse (Files .exists (symlinkedDir ));
1778+ assertFalse (Files .isSymbolicLink (symlinkedDir ));
1779+ }
1780+
1781+ @ Test
1782+ public void testForceDeleteSymlink () throws Exception {
1783+ final ImmutablePair <Path , Path > pair = createTempSymbolicLinkedRelativeDir ();
1784+ final Path symlinkedDir = pair .getLeft ();
1785+ final Path targetDir = pair .getRight ();
1786+
1787+ assertTrue (Files .exists (symlinkedDir ));
1788+ assertTrue (Files .isSymbolicLink (symlinkedDir ));
1789+ assertTrue (Files .exists (targetDir ));
1790+
1791+ FileUtils .forceDelete (symlinkedDir .toFile ());
1792+
1793+ // check targeted symlink is gone
1794+ assertFalse (Files .exists (symlinkedDir ));
1795+ assertFalse (Files .isSymbolicLink (symlinkedDir ));
1796+ // dir targeted by symlink is not deleted
1797+ assertTrue (Files .exists (targetDir ));
1798+ }
1799+
17641800 @ Test
17651801 void testForceMkdir () throws Exception {
17661802 // Tests with existing directory
0 commit comments