You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2023/01/01 20:06:01 UTC

[GitHub] [maven-shared-utils] michael-o commented on a diff in pull request #110: [MSHARED-1176] Test case for NoSuchFileException while copying symbolic

michael-o commented on code in PR #110:
URL: https://github.com/apache/maven-shared-utils/pull/110#discussion_r1059790215


##########
src/test/java/org/apache/maven/shared/utils/io/FileUtilsTest.java:
##########
@@ -463,6 +464,43 @@ public void copyFileWithNoFiltersAndLastModifiedDateOfZeroAndNoDestination()
         assertFileContent( to, "Hello World!" );
     }
 
+    @Test
+    public void copyRelativeSymbolicLinkFileWithNonExistingTargetWithNoFiltersAndNoDestination()
+        throws Exception
+    {
+        write(
+            "target.txt",
+            MODIFIED_YESTERDAY,
+            "Hello World!"
+        );
+        // 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 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 "./non-existing.txt"
+        FileUtils.copyFile( from.toFile(), to, null, (FileUtils.FilterWrapper[]) null );

Review Comment:
   directory, not folder



##########
src/test/java/org/apache/maven/shared/utils/io/FileUtilsTest.java:
##########
@@ -463,6 +464,43 @@ public void copyFileWithNoFiltersAndLastModifiedDateOfZeroAndNoDestination()
         assertFileContent( to, "Hello World!" );
     }
 
+    @Test
+    public void copyRelativeSymbolicLinkFileWithNonExistingTargetWithNoFiltersAndNoDestination()
+        throws Exception
+    {
+        write(
+            "target.txt",
+            MODIFIED_YESTERDAY,
+            "Hello World!"
+        );
+        // 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 creates a symlink in a new folder pointing to a non-existing relative target "./target.txt"

Review Comment:
   directory, not folder



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org