]> source.dussan.org Git - jgit.git/commitdiff
Return info about config subsection when trying to get an invalid enum 33/9133/2
authorTomasz Zarna <tomasz.zarna@tasktop.com>
Mon, 10 Dec 2012 10:20:06 +0000 (11:20 +0100)
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>
Tue, 8 Jan 2013 11:26:36 +0000 (06:26 -0500)
Change-Id: Id4a72a68bdbd485619f4801683d38ad98f9841a2

org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java

index f02012eb5acecdee7f45594485fa597cfeda8833..983603623788011277fbb67afe9eca81fa8fa1eb 100644 (file)
@@ -292,6 +292,25 @@ public class ConfigTest {
                assertSame(TestEnum.ONE_TWO, c.getEnum("s", "b", "c", TestEnum.ONE_TWO));
        }
 
+       @Test
+       public void testGetInvalidEnum() throws ConfigInvalidException {
+               Config c = parse("[a]\n\tb = invalid\n");
+               try {
+                       c.getEnum("a", null, "b", TestEnum.ONE_TWO);
+                       fail();
+               } catch (IllegalArgumentException e) {
+                       assertEquals("Invalid value: a.b=invalid", e.getMessage());
+               }
+
+               c = parse("[a \"b\"]\n\tc = invalid\n");
+               try {
+                       c.getEnum("a", "b", "c", TestEnum.ONE_TWO);
+                       fail();
+               } catch (IllegalArgumentException e) {
+                       assertEquals("Invalid value: a.b.c=invalid", e.getMessage());
+               }
+       }
+
        @Test
        public void testSetEnum() {
                final Config c = new Config();
index 348e1175d92c1b6af8a138a694b57013662b1b81..fb78d0effff910b1f2fbac350609854b1f36d126 100644 (file)
@@ -412,11 +412,13 @@ public class Config {
                }
 
                if (subsection != null)
-                       throw new IllegalArgumentException(MessageFormat.format(JGitText
-                                       .get().enumValueNotSupported3, section, name, value));
+                       throw new IllegalArgumentException(MessageFormat.format(
+                                       JGitText.get().enumValueNotSupported3, section, subsection,
+                                       name, value));
                else
-                       throw new IllegalArgumentException(MessageFormat.format(JGitText
-                                       .get().enumValueNotSupported2, section, name, value));
+                       throw new IllegalArgumentException(
+                                       MessageFormat.format(JGitText.get().enumValueNotSupported2,
+                                                       section, name, value));
        }
 
        /**