Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java84
1 files changed, 82 insertions, 2 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
index fb1ee8cadb..7862005ebc 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
@@ -808,8 +808,14 @@ public class ConfigTest {
fbConfig.load();
fail();
} catch (ConfigInvalidException cie) {
- assertEquals(JGitText.get().tooManyIncludeRecursions,
- cie.getCause().getMessage());
+ for (Throwable t = cie; t != null; t = t.getCause()) {
+ if (t.getMessage()
+ .equals(JGitText.get().tooManyIncludeRecursions)) {
+ return;
+ }
+ }
+ fail("Expected to find expected exception message: "
+ + JGitText.get().tooManyIncludeRecursions);
}
}
@@ -824,6 +830,80 @@ public class ConfigTest {
assertFalse(parsed.getBoolean("foo", "bar", false));
}
+ @Test
+ public void testIncludeCaseInsensitiveSection()
+ throws IOException, ConfigInvalidException {
+ File included = tmp.newFile("included");
+ String content = "[foo]\nbar=true\n";
+ Files.write(included.toPath(), content.getBytes());
+
+ File config = tmp.newFile("config");
+ content = "[Include]\npath=" + pathToString(included) + "\n";
+ Files.write(config.toPath(), content.getBytes());
+
+ FileBasedConfig fbConfig = new FileBasedConfig(null, config,
+ FS.DETECTED);
+ fbConfig.load();
+ assertTrue(fbConfig.getBoolean("foo", "bar", false));
+ }
+
+ @Test
+ public void testIncludeCaseInsensitiveKey()
+ throws IOException, ConfigInvalidException {
+ File included = tmp.newFile("included");
+ String content = "[foo]\nbar=true\n";
+ Files.write(included.toPath(), content.getBytes());
+
+ File config = tmp.newFile("config");
+ content = "[include]\nPath=" + pathToString(included) + "\n";
+ Files.write(config.toPath(), content.getBytes());
+
+ FileBasedConfig fbConfig = new FileBasedConfig(null, config,
+ FS.DETECTED);
+ fbConfig.load();
+ assertTrue(fbConfig.getBoolean("foo", "bar", false));
+ }
+
+ @Test
+ public void testIncludeExceptionContainsLine() {
+ try {
+ parse("[include]\npath=\n");
+ fail("Expected ConfigInvalidException");
+ } catch (ConfigInvalidException e) {
+ assertTrue(
+ "Expected to find the problem line in the exception message",
+ e.getMessage().contains("include.path"));
+ }
+ }
+
+ @Test
+ public void testIncludeExceptionContainsFile() throws IOException {
+ File included = tmp.newFile("included");
+ String includedPath = pathToString(included);
+ String content = "[include]\npath=\n";
+ Files.write(included.toPath(), content.getBytes());
+
+ File config = tmp.newFile("config");
+ String include = "[include]\npath=" + includedPath + "\n";
+ Files.write(config.toPath(), include.getBytes());
+ FileBasedConfig fbConfig = new FileBasedConfig(null, config,
+ FS.DETECTED);
+ try {
+ fbConfig.load();
+ fail("Expected ConfigInvalidException");
+ } catch (ConfigInvalidException e) {
+ // Check that there is some exception in the chain that contains
+ // includedPath
+ for (Throwable t = e; t != null; t = t.getCause()) {
+ if (t.getMessage().contains(includedPath)) {
+ return;
+ }
+ }
+ fail("Expected to find the path in the exception message: "
+ + includedPath);
+ }
+ }
+
private static void assertReadLong(long exp) throws ConfigInvalidException {
assertReadLong(exp, String.valueOf(exp));
}

Back to the top