Search in sources :

Example 6 with FailureAnalysis

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);
}
Also used : FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) Test(org.junit.Test)

Example 7 with FailureAnalysis

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);
}
Also used : ArrayList(java.util.ArrayList) FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) InjectionPoint(org.springframework.beans.factory.InjectionPoint)

Example 8 with FailureAnalysis

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;
}
Also used : FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis)

Example 9 with FailureAnalysis

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("└─────┘");
}
Also used : FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) Test(org.junit.Test)

Example 10 with FailureAnalysis

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()));
}
Also used : FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) Test(org.junit.Test)

Aggregations

FailureAnalysis (org.springframework.boot.diagnostics.FailureAnalysis)33 Test (org.junit.Test)27 JCacheNotFoundException (com.giffing.bucket4j.spring.boot.starter.exception.JCacheNotFoundException)1 MissingKeyFilterExpressionException (com.giffing.bucket4j.spring.boot.starter.exception.MissingKeyFilterExpressionException)1 ArrayList (java.util.ArrayList)1 ErrorMessage (org.modelmapper.spi.ErrorMessage)1 FatalBeanException (org.springframework.beans.FatalBeanException)1 InjectionPoint (org.springframework.beans.factory.InjectionPoint)1 NoUniqueBeanDefinitionException (org.springframework.beans.factory.NoUniqueBeanDefinitionException)1 TestBeanConsumer (org.springframework.boot.diagnostics.analyzer.nounique.TestBeanConsumer)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1 FieldError (org.springframework.validation.FieldError)1 ObjectError (org.springframework.validation.ObjectError)1