|
|
|
@ -175,6 +175,14 @@ class ConfigurationPropertiesTests {
|
|
|
|
|
.withCauseInstanceOf(BindException.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void givenIgnoreUnknownFieldsFalseAndIgnoreInvalidFieldsTrueWhenThereAreUnknownFieldsThenBindingShouldFail() {
|
|
|
|
|
removeSystemProperties();
|
|
|
|
|
assertThatExceptionOfType(ConfigurationPropertiesBindException.class).isThrownBy(
|
|
|
|
|
() -> load(IgnoreUnknownFieldsFalseIgnoreInvalidFieldsTrueConfiguration.class, "name=foo", "bar=baz"))
|
|
|
|
|
.withCauseInstanceOf(BindException.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void loadWhenHasIgnoreInvalidFieldsTrueAndInvalidFieldsShouldBind() {
|
|
|
|
|
load(IgnoreInvalidFieldsFalseProperties.class, "com.example.bar=spam");
|
|
|
|
@ -1000,6 +1008,12 @@ class ConfigurationPropertiesTests {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
|
@EnableConfigurationProperties(IgnoreUnknownFieldsFalseIgnoreInvalidFieldsTrueProperties.class)
|
|
|
|
|
static class IgnoreUnknownFieldsFalseIgnoreInvalidFieldsTrueConfiguration {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
|
@EnableConfigurationProperties(PrefixProperties.class)
|
|
|
|
|
static class PrefixConfiguration {
|
|
|
|
@ -1447,6 +1461,11 @@ class ConfigurationPropertiesTests {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ConfigurationProperties(ignoreUnknownFields = false, ignoreInvalidFields = true)
|
|
|
|
|
static class IgnoreUnknownFieldsFalseIgnoreInvalidFieldsTrueProperties extends BasicProperties {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@EnableConfigurationProperties
|
|
|
|
|
@ConfigurationProperties(prefix = "com.example", ignoreInvalidFields = true)
|
|
|
|
|
static class IgnoreInvalidFieldsFalseProperties {
|
|
|
|
|