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

Change-Id: Id4a72a68bdbd485619f4801683d38ad98f9841a2
This commit is contained in:
Tomasz Zarna 2012-12-10 11:20:06 +01:00 committed by Gerrit Code Review @ Eclipse.org
parent 3328f45dde
commit 928286ad8f
2 changed files with 25 additions and 4 deletions

View File

@ -292,6 +292,25 @@ public void testGetEnum() throws ConfigInvalidException {
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();

View File

@ -412,11 +412,13 @@ else if (StringUtils.equalsIgnoreCase(e.name(), "FALSE")) //$NON-NLS-1$
}
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));
}
/**