Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
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.java28
1 files changed, 25 insertions, 3 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 8de7ba6c1d..51236e1cc0 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,13 +13,13 @@ 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;
import java.io.File;
import java.io.IOException;
-import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
@@ -182,7 +182,7 @@ public class FSTest {
FS.readPipe(fs.userHome(),
new String[] { "/bin/sh", "-c", "exit 1" },
- Charset.defaultCharset().name());
+ SystemReader.getInstance().getDefaultCharset().name());
}
@Test(expected = CommandFailedException.class)
@@ -192,7 +192,7 @@ public class FSTest {
FS.readPipe(fs.userHome(),
new String[] { "this-command-does-not-exist" },
- Charset.defaultCharset().name());
+ SystemReader.getInstance().getDefaultCharset().name());
}
@Test
@@ -234,4 +234,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"));
+ }
}

Back to the top