Merge branch '2.0.x' into 2.1.x
Closes gh-17078
This commit is contained in:
@@ -45,8 +45,7 @@ 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");
|
||||
@@ -56,18 +55,15 @@ public class SamplePropertyValidationApplicationTests {
|
||||
@Test
|
||||
public void bindInvalidHost() {
|
||||
this.context.register(SamplePropertyValidationApplication.class);
|
||||
TestPropertyValues.of("sample.host:xxxxxx", "sample.port:9090")
|
||||
.applyTo(this.context);
|
||||
assertThatExceptionOfType(BeanCreationException.class)
|
||||
.isThrownBy(() -> this.context.refresh())
|
||||
TestPropertyValues.of("sample.host:xxxxxx", "sample.port:9090").applyTo(this.context);
|
||||
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> this.context.refresh())
|
||||
.withMessageContaining("Failed to bind properties under 'sample'");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bindNullHost() {
|
||||
this.context.register(SamplePropertyValidationApplication.class);
|
||||
assertThatExceptionOfType(BeanCreationException.class)
|
||||
.isThrownBy(() -> this.context.refresh())
|
||||
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> this.context.refresh())
|
||||
.withMessageContaining("Failed to bind properties under 'sample'");
|
||||
}
|
||||
|
||||
@@ -75,8 +71,7 @@ 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");
|
||||
|
||||
Reference in New Issue
Block a user