Search in sources :

Example 21 with FailureAnalysis

use of org.springframework.boot.diagnostics.FailureAnalysis in project spring-boot by spring-projects.

the class ValidationExceptionFailureAnalyzerTests method test.

@Test
public void test() throws Exception {
    try {
        new AnnotationConfigApplicationContext(TestConfiguration.class).close();
        fail("Expected failure did not occur");
    } catch (Exception ex) {
        FailureAnalysis analysis = new ValidationExceptionFailureAnalyzer().analyze(ex);
        assertThat(analysis).isNotNull();
    }
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) Test(org.junit.Test)

Example 22 with FailureAnalysis

use of org.springframework.boot.diagnostics.FailureAnalysis in project spring-boot by spring-projects.

the class BeanCurrentlyInCreationFailureAnalyzerTests method cycleWithAutowiredFields.

@Test
public void cycleWithAutowiredFields() throws IOException {
    FailureAnalysis analysis = performAnalysis(CycleWithAutowiredFields.class);
    assertThat(analysis.getDescription()).startsWith("The dependencies of some of the beans in the application context form a cycle:");
    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("|  three defined in " + BeanThreeConfiguration.class.getName());
    assertThat(lines.get(4)).isEqualTo("↑     ↓");
    assertThat(lines.get(5)).startsWith("|  one defined in " + CycleWithAutowiredFields.class.getName());
    assertThat(lines.get(6)).isEqualTo("↑     ↓");
    assertThat(lines.get(7)).startsWith("|  " + BeanTwoConfiguration.class.getName() + " (field private " + BeanThree.class.getName());
    assertThat(lines.get(8)).isEqualTo("└─────┘");
}
Also used : FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) Test(org.junit.Test)

Example 23 with FailureAnalysis

use of org.springframework.boot.diagnostics.FailureAnalysis in project spring-boot by spring-projects.

the class BeanCurrentlyInCreationFailureAnalyzerTests method cycleReferencedViaOtherBeans.

@Test
public void cycleReferencedViaOtherBeans() throws IOException {
    FailureAnalysis analysis = performAnalysis(CycleReferencedViaOtherBeansConfiguration.class);
    List<String> lines = readDescriptionLines(analysis);
    assertThat(lines).hasSize(12);
    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)).contains("refererOne " + "(field " + RefererTwo.class.getName());
    assertThat(lines.get(3)).isEqualTo("      ↓");
    assertThat(lines.get(4)).contains("refererTwo " + "(field " + BeanOne.class.getName());
    assertThat(lines.get(5)).isEqualTo("┌─────┐");
    assertThat(lines.get(6)).startsWith("|  one defined in " + CycleReferencedViaOtherBeansConfiguration.class.getName());
    assertThat(lines.get(7)).isEqualTo("↑     ↓");
    assertThat(lines.get(8)).startsWith("|  two defined in " + CycleReferencedViaOtherBeansConfiguration.class.getName());
    assertThat(lines.get(9)).isEqualTo("↑     ↓");
    assertThat(lines.get(10)).startsWith("|  three defined in " + CycleReferencedViaOtherBeansConfiguration.class.getName());
    assertThat(lines.get(11)).isEqualTo("└─────┘");
}
Also used : FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) Test(org.junit.Test)

Example 24 with FailureAnalysis

use of org.springframework.boot.diagnostics.FailureAnalysis in project spring-boot by spring-projects.

the class NoSuchBeanDefinitionFailureAnalyzerTests method failureAnalysisForSeveralConditionsType.

@Test
public void failureAnalysisForSeveralConditionsType() {
    FailureAnalysis analysis = analyzeFailure(createFailure(SeveralAutoConfigurationTypeConfiguration.class));
    assertDescriptionConstructorMissingType(analysis, StringHandler.class, 0, String.class);
    assertBeanMethodDisabled(analysis, "did not find property 'spring.string.enabled'", TestPropertyAutoConfiguration.class, "string");
    assertClassDisabled(analysis, "did not find required class 'com.example.FooBar'", "string");
    assertActionMissingType(analysis, String.class);
}
Also used : FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) Test(org.junit.Test)

Example 25 with FailureAnalysis

use of org.springframework.boot.diagnostics.FailureAnalysis in project spring-boot by spring-projects.

the class NoSuchBeanDefinitionFailureAnalyzerTests method failureAnalysisForMissingPropertySubType.

@Test
public void failureAnalysisForMissingPropertySubType() {
    FailureAnalysis analysis = analyzeFailure(createFailure(IntegerPropertyTypeConfiguration.class));
    assertThat(analysis).isNotNull();
    assertDescriptionConstructorMissingType(analysis, NumberHandler.class, 0, Number.class);
    assertBeanMethodDisabled(analysis, "did not find property 'spring.integer.enabled'", TestPropertyAutoConfiguration.class, "integer");
    assertActionMissingType(analysis, Number.class);
}
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