3939import java .io .Writer ;
4040import java .net .URL ;
4141import java .nio .file .Files ;
42+ import java .nio .file .Path ;
43+ import java .nio .file .Paths ;
4244import java .util .Arrays ;
4345import java .util .HashMap ;
4446import java .util .HashSet ;
@@ -445,15 +447,14 @@ public void copyFileWithNoFiltersAndLastModifiedDateOfZeroAndNoDestination()
445447 {
446448 File from = write (
447449 "from.txt" ,
448- MODIFIED_YESTERDAY ,
450+ 0 ,
449451 "Hello World!"
450452 );
451453 File to = new File (
452454 tempFolder .getRoot (),
453455 "to.txt"
454456 );
455457
456- from .setLastModified ( 0 );
457458 FileUtils .copyFile ( from , to , null , (FileUtils .FilterWrapper []) null );
458459
459460 assertTrue (
@@ -463,6 +464,32 @@ public void copyFileWithNoFiltersAndLastModifiedDateOfZeroAndNoDestination()
463464 assertFileContent ( to , "Hello World!" );
464465 }
465466
467+ @ Test
468+ public void copyRelativeSymbolicLinkFileWithNonExistingTargetWithNoFiltersAndNoDestination ()
469+ throws Exception
470+ {
471+
472+ File target = write (
473+ "target.txt" ,
474+ MODIFIED_YESTERDAY ,
475+ "Hello World!"
476+ );
477+ // must be a relative symbolic link
478+ Path from = Files .createSymbolicLink ( new File (tempFolder .getRoot (), "symLink" ).toPath (), Paths .get ( "target.txt" ) );
479+ File to = new File (
480+ tempFolder .newFolder ( "destDirectory" ),
481+ "toSymLink"
482+ );
483+
484+ FileUtils .copyFile ( from .toFile (), to , null , (FileUtils .FilterWrapper []) null );
485+
486+ assertTrue (
487+ "toSymLink did not exist so should have been written" ,
488+ to .lastModified () >= MODIFIED_TODAY
489+ );
490+ assertFileContent ( to , "Hello World!" );
491+ }
492+
466493 @ Test
467494 public void copyFileWithNoFiltersAndOutdatedDestination ()
468495 throws Exception
0 commit comments