Add a few more binding tests

See gh-2304
This commit is contained in:
Phillip Webb 2015-01-07 22:24:32 -08:00
parent 6056b96828
commit 6fbccbe61d
1 changed files with 10 additions and 7 deletions

View File

@ -135,22 +135,25 @@ public class ConfigurationPropertiesBindingPostProcessorTests {
@Test
public void testPropertyWithEnum() throws Exception {
this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, "test.the-value:foo");
this.context.register(PropertyWithEnum.class);
this.context.refresh();
assertThat(this.context.getBean(PropertyWithEnum.class).getTheValue(),
equalTo(FooEnum.FOO));
doEnumTest("test.theValue:foo");
}
@Test
public void testRelaxedPropertyWithEnum() throws Exception {
doEnumTest("test.the-value:FoO");
doEnumTest("TEST_THE_VALUE:FoO");
doEnumTest("test.THE_VALUE:FoO");
doEnumTest("test_the_value:FoO");
}
private void doEnumTest(String property) {
this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, "TEST_THE_VALUE:FoO");
EnvironmentTestUtils.addEnvironment(this.context, property);
this.context.register(PropertyWithEnum.class);
this.context.refresh();
assertThat(this.context.getBean(PropertyWithEnum.class).getTheValue(),
equalTo(FooEnum.FOO));
this.context.close();
}
@Test