@@ -773,7 +773,7 @@ public void testCopyDirectory_symLink() throws IOException {
773773 assumeTrue (Files .exists (linkPath ));
774774 assumeTrue (Files .exists (linkPath , LinkOption .NOFOLLOW_LINKS ));
775775
776- // Now copy sourceDirectory, including the broken link, to another directory
776+ // Now copy sourceDirectory to another directory
777777 final File destination = new File (tempDirFile , "destination" );
778778 FileUtils .copyDirectory (sourceDirectory , destination );
779779 assertTrue (destination .exists ());
@@ -1099,6 +1099,26 @@ public void testCopyDirectoryWithPotentialFalsePartialMatch() throws IOException
10991099 assertEquals (parFiles .size (), newFilePaths .size ());
11001100 }
11011101
1102+ @ Test
1103+ public void testCopyFile_symLink () throws Exception {
1104+ // Make a file
1105+ final File sourceDirectory = new File (tempDirFile , "source_directory" );
1106+ sourceDirectory .mkdir ();
1107+ final File targetFile = new File (sourceDirectory , "hello.txt" );
1108+ FileUtils .writeStringToFile (targetFile , "HELLO WORLD" , "UTF8" );
1109+
1110+ // Make a symlink to the file
1111+ final Path targetPath = targetFile .toPath ();
1112+ final Path linkPath = sourceDirectory .toPath ().resolve ("linkfile" );
1113+ Files .createSymbolicLink (linkPath , targetPath );
1114+
1115+ // Now copy symlink to another directory
1116+ final File destination = new File (tempDirFile , "destination" );
1117+ FileUtils .copyFile (linkPath .toFile (), destination );
1118+ assertTrue (Files .isSymbolicLink (destination .toPath ()));
1119+ }
1120+
1121+
11021122 @ Test
11031123 public void testCopyFile1 () throws Exception {
11041124 final File destination = new File (tempDirFile , "copy1.txt" );
0 commit comments