|
|
|
@ -28,6 +28,7 @@ import org.springframework.beans.factory.BeanCreationException;
|
|
|
|
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
|
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
|
|
|
import org.springframework.boot.diagnostics.FailureAnalysis;
|
|
|
|
|
import org.springframework.boot.logging.LogLevel;
|
|
|
|
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
|
|
|
|
import org.springframework.core.env.MapPropertySource;
|
|
|
|
|
import org.springframework.core.env.MutablePropertySources;
|
|
|
|
@ -88,6 +89,16 @@ class BindFailureAnalyzerTests {
|
|
|
|
|
"failed to convert java.lang.String to java.lang.Class<?> (caused by java.lang.ClassNotFoundException: com.example.Missing"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void bindExceptionDueToMapConversionFailure() {
|
|
|
|
|
FailureAnalysis analysis = performAnalysis(LoggingLevelFailureConfiguration.class, "logging.level=debug");
|
|
|
|
|
assertThat(analysis.getDescription()).contains(failure("logging.level", "debug",
|
|
|
|
|
"\"logging.level\" from property source \"test\"",
|
|
|
|
|
"org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting "
|
|
|
|
|
+ "from type [java.lang.String] to type [java.util.Map<java.lang.String, "
|
|
|
|
|
+ "org.springframework.boot.logging.LogLevel>]"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static String failure(String property, String value, String origin, String reason) {
|
|
|
|
|
return String.format("Property: %s%n Value: %s%n Origin: %s%n Reason: %s", property, value, origin,
|
|
|
|
|
reason);
|
|
|
|
@ -150,6 +161,11 @@ class BindFailureAnalyzerTests {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@EnableConfigurationProperties(LoggingProperties.class)
|
|
|
|
|
static class LoggingLevelFailureConfiguration {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ConfigurationProperties("test.foo")
|
|
|
|
|
@Validated
|
|
|
|
|
static class FieldValidationFailureProperties {
|
|
|
|
@ -237,6 +253,21 @@ class BindFailureAnalyzerTests {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ConfigurationProperties("logging")
|
|
|
|
|
static class LoggingProperties {
|
|
|
|
|
|
|
|
|
|
private Map<String, LogLevel> level = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
Map<String, LogLevel> getLevel() {
|
|
|
|
|
return this.level;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setLevel(Map<String, LogLevel> level) {
|
|
|
|
|
this.level = level;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum Fruit {
|
|
|
|
|
|
|
|
|
|
APPLE, BANANA, ORANGE
|
|
|
|
|