This commit is contained in:
Phillip Webb
2017-11-01 15:48:03 -07:00
parent 44d8e09aac
commit c55b5d7111
62 changed files with 237 additions and 229 deletions

View File

@@ -49,8 +49,8 @@ public class SamplePropertyValidationApplicationTests {
@Test
public void bindValidProperties() {
this.context.register(SamplePropertyValidationApplication.class);
TestPropertyValues.of("sample.host:192.168.0.1",
"sample.port:9090").applyTo(this.context);
TestPropertyValues.of("sample.host:192.168.0.1", "sample.port:9090")
.applyTo(this.context);
this.context.refresh();
SampleProperties properties = this.context.getBean(SampleProperties.class);
assertThat(properties.getHost()).isEqualTo("192.168.0.1");
@@ -60,8 +60,8 @@ public class SamplePropertyValidationApplicationTests {
@Test
public void bindInvalidHost() {
this.context.register(SamplePropertyValidationApplication.class);
TestPropertyValues.of("sample.host:xxxxxx",
"sample.port:9090").applyTo(this.context);
TestPropertyValues.of("sample.host:xxxxxx", "sample.port:9090")
.applyTo(this.context);
this.thrown.expect(BeanCreationException.class);
this.thrown.expectMessage("Failed to bind properties under 'sample'");
this.context.refresh();
@@ -79,8 +79,8 @@ public class SamplePropertyValidationApplicationTests {
public void validatorOnlyCalledOnSupportedClass() {
this.context.register(SamplePropertyValidationApplication.class);
this.context.register(ServerProperties.class); // our validator will not apply
TestPropertyValues.of("sample.host:192.168.0.1",
"sample.port:9090").applyTo(this.context);
TestPropertyValues.of("sample.host:192.168.0.1", "sample.port:9090")
.applyTo(this.context);
this.context.refresh();
SampleProperties properties = this.context.getBean(SampleProperties.class);
assertThat(properties.getHost()).isEqualTo("192.168.0.1");