Browse Source

Return info about config subsection when trying to get an invalid enum

Change-Id: Id4a72a68bdbd485619f4801683d38ad98f9841a2
stable-2.3
Tomasz Zarna 12 years ago committed by Gerrit Code Review @ Eclipse.org
parent
commit
928286ad8f
  1. 19
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
  2. 10
      org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java

19
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java

@ -292,6 +292,25 @@ public class ConfigTest {
assertSame(TestEnum.ONE_TWO, c.getEnum("s", "b", "c", TestEnum.ONE_TWO)); 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 @Test
public void testSetEnum() { public void testSetEnum() {
final Config c = new Config(); final Config c = new Config();

10
org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java

@ -412,11 +412,13 @@ public class Config {
} }
if (subsection != null) if (subsection != null)
throw new IllegalArgumentException(MessageFormat.format(JGitText throw new IllegalArgumentException(MessageFormat.format(
.get().enumValueNotSupported3, section, name, value)); JGitText.get().enumValueNotSupported3, section, subsection,
name, value));
else else
throw new IllegalArgumentException(MessageFormat.format(JGitText throw new IllegalArgumentException(
.get().enumValueNotSupported2, section, name, value)); MessageFormat.format(JGitText.get().enumValueNotSupported2,
section, name, value));
} }
/** /**

Loading…
Cancel
Save