Skip to content

Commit

Permalink
Add test for symbolic link whose target does not even exist for the
Browse files Browse the repository at this point in the history
source symlink file
  • Loading branch information
kwin committed Jul 27, 2022
1 parent da11090 commit 8ff14a5
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/test/java/org/apache/maven/shared/utils/io/FileUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -468,19 +468,34 @@ public void copyFileWithNoFiltersAndLastModifiedDateOfZeroAndNoDestination()
public void copyRelativeSymbolicLinkFileWithNonExistingTargetWithNoFiltersAndNoDestination()
throws Exception
{

File target = write(
write(
"target.txt",
MODIFIED_YESTERDAY,
"Hello World!"
);
// must be a relative symbolic link
// must be a relative symbolic link to existing target
Path from = Files.createSymbolicLink( new File(tempFolder.getRoot(), "symLink").toPath(), Paths.get( "target.txt" ) );
File to = new File(
tempFolder.newFolder( "destDirectory" ),
"toSymLink"
);
// this create a symlink in a newfolder pointing to a non-existing relative target "./target.txt"
// this creates a symlink in a new folder pointing to a non-existing relative target "./target.txt"
FileUtils.copyFile( from.toFile(), to, null, (FileUtils.FilterWrapper[]) null );

// this should not fail
}

@Test
public void copySymbolicLinkFileWithNonExistingTargetWithNoFiltersAndNoDestination()
throws Exception
{
// link to non existing target
Path from = Files.createSymbolicLink( new File(tempFolder.getRoot(), "symLink").toPath(), Paths.get( "non-existing.txt" ) );
File to = new File(
tempFolder.getRoot(),
"toSymLink"
);
// this creates a symlink in a new folder pointing to a non-existing relative target "./target.txt"
FileUtils.copyFile( from.toFile(), to, null, (FileUtils.FilterWrapper[]) null );

// this should not fail
Expand Down

0 comments on commit 8ff14a5

Please sign in to comment.