You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "garydgregory (via GitHub)" <gi...@apache.org> on 2023/04/19 11:46:08 UTC

[GitHub] [commons-io] garydgregory commented on a diff in pull request #450: IO-790 Fix symbolic link file filter

garydgregory commented on code in PR #450:
URL: https://github.com/apache/commons-io/pull/450#discussion_r1171219812


##########
src/test/java/org/apache/commons/io/filefilter/SymbolicLinkFileFilterTest.java:
##########
@@ -17,21 +17,198 @@
 
 package org.apache.commons.io.filefilter;
 
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
+import java.io.File;
+import java.io.IOException;
 import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.function.BiFunction;
 
 import org.apache.commons.io.file.PathUtils;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 /**
  * Tests {@link SymbolicLinkFileFilter}.
  */
 public class SymbolicLinkFileFilterTest {
 
+    public static final String TARGET_SHORT_NAME = "SLFF_Target";
+    public static final String TARGET_EXT = ".txt";
+    public static final String TARGET_NAME = TARGET_SHORT_NAME + TARGET_EXT;
+    public static final String DIRECTORY_NAME = "SLFF_TargetDirectory";
+    public static final String DIRECTORY_LINK_NAME = "SLFF_LinkDirectory";
+    public static final String MISSING = "Missing";
+    private static File testTargetFile;         // hard file
+    private static Path testTargetPath;         // hard file Path
+    private static File parentDirectoryFile;    // System Temp directory
+    private static File testLinkFile;           // symbolic link to hard file
+    private static String linkName;             // Name of link file
+    private static Path testLinkPath;           // symbolic link to hard file Path
+    private static File targetDirFile;          //
+    private static Path targetDirPath;          // hard directory Path
+    private static Path testLinkDirPath;        // symbolic link to hardDirectory
+    private static File testLinkDirFile;
+    private static File missingFile;            // non-existent file
+    private static SymbolicLinkFileFilter filter;
+
+    private static Path createRealSymbolicLink(Path link, Path target) {
+        try {
+            if (Files.exists(link)) {
+                Files.delete(link);
+            }
+            return Files.createSymbolicLink(link, target);
+        } catch (IOException e) {
+            throw new IllegalStateException("Failure to create Symbolic Link", e);
+        }
+    }
+
+    private static Path createMockSymbolicLink(Path lnk, Path tgt) {

Review Comment:
   No weird abbreviations needed.



-- 
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@commons.apache.org

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