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();
}
}
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("└─────┘");
}
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("└─────┘");
}
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);
}
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);
}
Aggregations