File tree Expand file tree Collapse file tree
src/test/java/org/apache/maven/shared/utils/io Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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,28 @@ 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+ // this create a symlink in a newfolder pointing to a non-existing relative target "./target.txt"
484+ FileUtils .copyFile ( from .toFile (), to , null , (FileUtils .FilterWrapper []) null );
485+
486+ // this should not fail
487+ }
488+
466489 @ Test
467490 public void copyFileWithNoFiltersAndOutdatedDestination ()
468491 throws Exception
You can’t perform that action at this time.
0 commit comments