Search in sources :

Example 1 with FailureAnalysis

use of cn.taketoday.framework.diagnostics.FailureAnalysis in project today-infrastructure by TAKETODAY.

the class IncompatibleConfigurationFailureAnalyzerTests method incompatibleConfigurationListsKeys.

@Test
void incompatibleConfigurationListsKeys() {
    FailureAnalysis failureAnalysis = performAnalysis("spring.first.key", "spring.second.key");
    assertThat(failureAnalysis.getDescription()).contains("The following configuration properties have incompatible values: [spring.first.key, spring.second.key]");
    assertThat(failureAnalysis.getAction()).contains("Review the docs for spring.first.key, spring.second.key and change the configured values.");
}
Also used : FailureAnalysis(cn.taketoday.framework.diagnostics.FailureAnalysis) Test(org.junit.jupiter.api.Test)

Example 2 with FailureAnalysis

use of cn.taketoday.framework.diagnostics.FailureAnalysis in project today-infrastructure by TAKETODAY.

the class ConfigDataNotFoundFailureAnalyzerTests method analyzeWhenOptionalConfigDataLocationNotFoundException.

@Test
void analyzeWhenOptionalConfigDataLocationNotFoundException() {
    ConfigDataLocation location = ConfigDataLocation.valueOf("optional:test");
    ConfigDataLocationNotFoundException exception = new ConfigDataLocationNotFoundException(location);
    FailureAnalysis result = this.analyzer.analyze(exception);
    assertThat(result.getDescription()).isEqualTo("Config data location 'optional:test' does not exist");
    assertThat(result.getAction()).isEqualTo("Check that the value 'optional:test' is correct");
}
Also used : FailureAnalysis(cn.taketoday.framework.diagnostics.FailureAnalysis) Test(org.junit.jupiter.api.Test)

Example 3 with FailureAnalysis

use of cn.taketoday.framework.diagnostics.FailureAnalysis in project today-infrastructure by TAKETODAY.

the class BeanCurrentlyInCreationFailureAnalyzerTests method cycleWithCircularReferencesAllowed.

@Test
void cycleWithCircularReferencesAllowed() throws IOException {
    FailureAnalysis analysis = performAnalysis(CyclicBeanMethodsConfiguration.class, true);
    assertThat(analysis.getAction()).contains("Despite circular references being allowed");
}
Also used : FailureAnalysis(cn.taketoday.framework.diagnostics.FailureAnalysis) Test(org.junit.jupiter.api.Test)

Example 4 with FailureAnalysis

use of cn.taketoday.framework.diagnostics.FailureAnalysis in project today-infrastructure by TAKETODAY.

the class BeanCurrentlyInCreationFailureAnalyzerTests method testSelfReferenceCycle.

@Test
void testSelfReferenceCycle() throws IOException {
    FailureAnalysis analysis = performAnalysis(SelfReferenceBeanConfiguration.class);
    List<String> lines = readDescriptionLines(analysis);
    assertThat(lines).hasSize(5);
    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("|  bean defined in " + SelfReferenceBeanConfiguration.class.getName());
    assertThat(lines.get(4)).isEqualTo("└──<-──┘");
    assertThat(analysis.getAction()).isNotNull();
}
Also used : FailureAnalysis(cn.taketoday.framework.diagnostics.FailureAnalysis) Test(org.junit.jupiter.api.Test)

Example 5 with FailureAnalysis

use of cn.taketoday.framework.diagnostics.FailureAnalysis in project today-infrastructure by TAKETODAY.

the class BeanCurrentlyInCreationFailureAnalyzerTests method cycleWithCircularReferencesProhibited.

@Test
void cycleWithCircularReferencesProhibited() throws IOException {
    FailureAnalysis analysis = performAnalysis(CyclicBeanMethodsConfiguration.class, false);
    assertThat(analysis.getAction()).contains("As a last resort");
}
Also used : FailureAnalysis(cn.taketoday.framework.diagnostics.FailureAnalysis) Test(org.junit.jupiter.api.Test)

Aggregations

FailureAnalysis (cn.taketoday.framework.diagnostics.FailureAnalysis)118 Test (org.junit.jupiter.api.Test)108 MapPropertySource (cn.taketoday.core.env.MapPropertySource)12 InvalidConfigurationPropertyValueException (cn.taketoday.context.properties.source.InvalidConfigurationPropertyValueException)8 MutuallyExclusiveConfigurationPropertiesException (cn.taketoday.context.properties.source.MutuallyExclusiveConfigurationPropertiesException)8 BeanCreationException (cn.taketoday.beans.factory.BeanCreationException)6 ApplicationContextException (cn.taketoday.context.ApplicationContextException)4 LinkedHashMap (java.util.LinkedHashMap)4 FatalBeanException (cn.taketoday.beans.FatalBeanException)2 BeanCurrentlyInCreationException (cn.taketoday.beans.factory.BeanCurrentlyInCreationException)2 NoUniqueBeanDefinitionException (cn.taketoday.beans.factory.NoUniqueBeanDefinitionException)2 LoggingFailureAnalysisReporter (cn.taketoday.framework.diagnostics.LoggingFailureAnalysisReporter)2 TestBeanConsumer (cn.taketoday.framework.diagnostics.analyzer.nounique.TestBeanConsumer)2 ReactiveWebServerApplicationContext (cn.taketoday.framework.web.reactive.context.ReactiveWebServerApplicationContext)2 ReactiveWebServerFactory (cn.taketoday.framework.web.reactive.server.ReactiveWebServerFactory)2 ServletWebServerApplicationContext (cn.taketoday.framework.web.servlet.context.ServletWebServerApplicationContext)2 ServletWebServerFactory (cn.taketoday.framework.web.servlet.server.ServletWebServerFactory)2 Origin (cn.taketoday.origin.Origin)2 BindException (cn.taketoday.validation.BindException)2 FieldError (cn.taketoday.validation.FieldError)2