use of org.springframework.boot.diagnostics.FailureAnalysis in project spring-boot by spring-projects.
the class NoSuchBeanDefinitionFailureAnalyzerTests method failureAnalysisForMissingPropertyExactType.
@Test
public void failureAnalysisForMissingPropertyExactType() {
FailureAnalysis analysis = analyzeFailure(createFailure(StringPropertyTypeConfiguration.class));
assertDescriptionConstructorMissingType(analysis, StringHandler.class, 0, String.class);
assertBeanMethodDisabled(analysis, "did not find property 'spring.string.enabled'", TestPropertyAutoConfiguration.class, "string");
assertActionMissingType(analysis, String.class);
}
use of org.springframework.boot.diagnostics.FailureAnalysis in project spring-boot by spring-projects.
the class BeanCurrentlyInCreationFailureAnalyzer method analyze.
@Override
protected FailureAnalysis analyze(Throwable rootFailure, BeanCurrentlyInCreationException cause) {
List<BeanInCycle> cycle = new ArrayList<>();
Throwable candidate = rootFailure;
int cycleStart = -1;
while (candidate != null) {
BeanInCycle beanInCycle = BeanInCycle.get(candidate);
if (beanInCycle != null) {
int index = cycle.indexOf(beanInCycle);
if (index == -1) {
cycle.add(beanInCycle);
}
cycleStart = (cycleStart == -1 ? index : cycleStart);
}
candidate = candidate.getCause();
}
String message = buildMessage(cycle, cycleStart);
return new FailureAnalysis(message, null, cause);
}
use of org.springframework.boot.diagnostics.FailureAnalysis in project spring-boot by spring-projects.
the class BeanCurrentlyInCreationFailureAnalyzerTests method performAnalysis.
private FailureAnalysis performAnalysis(Class<?> configuration) {
FailureAnalysis analysis = this.analyzer.analyze(createFailure(configuration));
assertThat(analysis).isNotNull();
return analysis;
}
use of org.springframework.boot.diagnostics.FailureAnalysis in project spring-boot by spring-projects.
the class BeanCurrentlyInCreationFailureAnalyzerTests method cyclicBeanMethods.
@Test
public void cyclicBeanMethods() throws IOException {
FailureAnalysis analysis = performAnalysis(CyclicBeanMethodsConfiguration.class);
List<String> lines = readDescriptionLines(analysis);
assertThat(lines).hasSize(9);
assertThat(lines.get(0)).isEqualTo("The dependencies of some of the beans in the application context form a cycle:");
assertThat(lines.get(1)).isEqualTo("");
assertThat(lines.get(2)).isEqualTo("┌─────┐");
assertThat(lines.get(3)).startsWith("| one defined in " + InnerInnerConfiguration.class.getName());
assertThat(lines.get(4)).isEqualTo("↑ ↓");
assertThat(lines.get(5)).startsWith("| two defined in " + InnerConfiguration.class.getName());
assertThat(lines.get(6)).isEqualTo("↑ ↓");
assertThat(lines.get(7)).startsWith("| three defined in " + CyclicBeanMethodsConfiguration.class.getName());
assertThat(lines.get(8)).isEqualTo("└─────┘");
}
use of org.springframework.boot.diagnostics.FailureAnalysis in project spring-boot by spring-projects.
the class BeanNotOfRequiredTypeFailureAnalyzerTests method jdkProxyCausesInjectionFailure.
@Test
public void jdkProxyCausesInjectionFailure() {
FailureAnalysis analysis = performAnalysis(JdkProxyConfiguration.class);
assertThat(analysis.getDescription()).startsWith("The bean 'asyncBean'");
assertThat(analysis.getDescription()).contains("'" + AsyncBean.class.getName() + "'");
assertThat(analysis.getDescription()).endsWith(String.format("%s%n", SomeInterface.class.getName()));
}
Aggregations