Skip to content

Commit 6fbccbe

Browse files
committed
Add a few more binding tests
See gh-2304
1 parent 6056b96 commit 6fbccbe

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessorTests.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,22 +135,25 @@ public void testInitializersSeeBoundProperties() {
135135

136136
@Test
137137
public void testPropertyWithEnum() throws Exception {
138-
this.context = new AnnotationConfigApplicationContext();
139-
EnvironmentTestUtils.addEnvironment(this.context, "test.the-value:foo");
140-
this.context.register(PropertyWithEnum.class);
141-
this.context.refresh();
142-
assertThat(this.context.getBean(PropertyWithEnum.class).getTheValue(),
143-
equalTo(FooEnum.FOO));
138+
doEnumTest("test.theValue:foo");
144139
}
145140

146141
@Test
147142
public void testRelaxedPropertyWithEnum() throws Exception {
143+
doEnumTest("test.the-value:FoO");
144+
doEnumTest("TEST_THE_VALUE:FoO");
145+
doEnumTest("test.THE_VALUE:FoO");
146+
doEnumTest("test_the_value:FoO");
147+
}
148+
149+
private void doEnumTest(String property) {
148150
this.context = new AnnotationConfigApplicationContext();
149-
EnvironmentTestUtils.addEnvironment(this.context, "TEST_THE_VALUE:FoO");
151+
EnvironmentTestUtils.addEnvironment(this.context, property);
150152
this.context.register(PropertyWithEnum.class);
151153
this.context.refresh();
152154
assertThat(this.context.getBean(PropertyWithEnum.class).getTheValue(),
153155
equalTo(FooEnum.FOO));
156+
this.context.close();
154157
}
155158

156159
@Test

0 commit comments

Comments
 (0)