diff options
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FSTest.java')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FSTest.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FSTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FSTest.java index 171d80c3da..3a7fa2388e 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FSTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FSTest.java @@ -13,6 +13,7 @@ package org.eclipse.jgit.util; import static java.time.Instant.EPOCH; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeNoException; import static org.junit.Assume.assumeTrue; @@ -28,8 +29,12 @@ import java.nio.file.attribute.PosixFilePermission; import java.time.Duration; import java.time.ZoneId; import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.List; import java.util.Locale; import java.util.Set; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import org.eclipse.jgit.errors.CommandFailedException; @@ -195,6 +200,23 @@ public class FSTest { } @Test + @SuppressWarnings("boxing") + public void testConcurrentSymlinkSupport() + throws ExecutionException, InterruptedException { + Assume.assumeTrue(FS.DETECTED.supportsSymlinks()); + int n = 3; + List<CompletableFuture<Boolean>> futures = new ArrayList<>(); + for (int i = 0; i < n; i++) { + futures.add(CompletableFuture.supplyAsync( + () -> FS.DETECTED.newInstance().supportsSymlinks())); + } + + for (int i = 0; i < n; i++) { + assertTrue(futures.get(i).get()); + } + } + + @Test public void testFsTimestampResolution() throws Exception { DateTimeFormatter formatter = DateTimeFormatter .ofPattern("uuuu-MMM-dd HH:mm:ss.nnnnnnnnn", Locale.ENGLISH) @@ -233,4 +255,26 @@ public class FSTest { assertFalse(RepositoryCache.FileKey .isGitRepository(new File("repo.git"), FS.DETECTED)); } + + @Test + public void testSearchPath() throws IOException { + File f1 = new File(trash, "file1"); + FileUtils.createNewFile(f1); + f1.setExecutable(true); + File f2 = new File(trash, "file2"); + FileUtils.createNewFile(f2); + assertEquals(f1, FS.searchPath(trash.getAbsolutePath(), "file1")); + assertNull(FS.searchPath(trash.getAbsolutePath(), "file2")); + } + + @Test + public void testSearchPathEmptyPath() { + assertNull(FS.searchPath("", "file1")); + assertNull(FS.searchPath(File.pathSeparator, "file1")); + assertNull(FS.searchPath(File.pathSeparator + File.pathSeparator, + "file1")); + assertNull(FS.searchPath( + " " + File.pathSeparator + " " + File.pathSeparator + " \t", + "file1")); + } } |