From dff4f6cc74d54e28252d9c83cc486bf1c8e26d5b Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Mon, 8 Apr 2019 12:52:36 +0900 Subject: [PATCH] ConfigTest: Add test for parsing invalid group header Test that an exception is raised for an invalid group header: [group "foo" ] foo = bar i.e. where there is a space between the group subsection name and the closing ']'. Change-Id: I8933ae100b77634b0afb66bb8aa43d24c955799e Signed-off-by: David Pursehouse --- .../tst/org/eclipse/jgit/lib/ConfigTest.java | 7 +++++++ 1 file changed, 7 insertions(+) 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 21d8d66ad..5a4bd886a 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 @@ -1450,6 +1450,13 @@ public class ConfigTest { assertEquals("xt", parseEscapedSubsection("\"x\\t\"")); } + @Test + public void testInvalidGroupHeader() throws ConfigInvalidException { + expectedEx.expect(ConfigInvalidException.class); + expectedEx.expectMessage(JGitText.get().badGroupHeader); + parse("[foo \"bar\" ]\nfoo=bar\n"); + } + private static void assertValueRoundTrip(String value) throws ConfigInvalidException { assertValueRoundTrip(value, value);