Search in sources :

Example 66 with FailureAnalysis

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

the class RedisUrlSyntaxFailureAnalyzerTests method analyzeRedisSocketUrl.

@Test
void analyzeRedisSocketUrl() {
    RedisUrlSyntaxException exception = new RedisUrlSyntaxException("redis-socket:///redis/redis.sock");
    FailureAnalysis analysis = new RedisUrlSyntaxFailureAnalyzer().analyze(exception);
    assertThat(analysis.getDescription()).contains("The URL 'redis-socket:///redis/redis.sock' is not valid").contains("The scheme 'redis-socket' is not supported");
    assertThat(analysis.getAction()).contains("Configure the appropriate Spring Data Redis connection beans");
}
Also used : FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) Test(org.junit.jupiter.api.Test)

Example 67 with FailureAnalysis

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

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(org.springframework.boot.diagnostics.FailureAnalysis) Test(org.junit.jupiter.api.Test)

Example 68 with FailureAnalysis

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

the class NotConstructorBoundInjectionFailureAnalyzer method analyze.

@Override
protected FailureAnalysis analyze(Throwable rootFailure, NoSuchBeanDefinitionException cause, String description) {
    InjectionPoint injectionPoint = findInjectionPoint(rootFailure);
    if (isConstructorBindingConfigurationProperties(injectionPoint)) {
        String simpleName = injectionPoint.getMember().getDeclaringClass().getSimpleName();
        String action = String.format("Update your configuration so that " + simpleName + " is defined via @" + ConfigurationPropertiesScan.class.getSimpleName() + " or @" + EnableConfigurationProperties.class.getSimpleName() + ".", simpleName);
        return new FailureAnalysis(simpleName + " is annotated with @" + ConstructorBinding.class.getSimpleName() + " but it is defined as a regular bean which caused dependency injection to fail.", action, cause);
    }
    return null;
}
Also used : InjectionPoint(org.springframework.beans.factory.InjectionPoint) FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis)

Example 69 with FailureAnalysis

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

the class ConnectionFactoryBeanCreationFailureAnalyzerTests method failureAnalysisIsPerformed.

@Test
void failureAnalysisIsPerformed() {
    FailureAnalysis failureAnalysis = performAnalysis(TestConfiguration.class);
    assertThat(failureAnalysis.getDescription()).contains("'url' attribute is not specified", "no embedded database could be configured");
    assertThat(failureAnalysis.getAction()).contains("If you want an embedded database (H2), please put it on the classpath", "If you have database settings to be loaded from a particular profile you may need to activate it", "(no profiles are currently active)");
}
Also used : FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) Test(org.junit.jupiter.api.Test)

Example 70 with FailureAnalysis

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

the class NonUniqueSessionRepositoryFailureAnalyzerTests method failureAnalysisWithMultipleCandidates.

@Test
void failureAnalysisWithMultipleCandidates() {
    FailureAnalysis analysis = analyzeFailure(createFailure(JdbcIndexedSessionRepository.class, HazelcastIndexedSessionRepository.class));
    assertThat(analysis).isNotNull();
    assertThat(analysis.getDescription()).contains(JdbcIndexedSessionRepository.class.getName(), HazelcastIndexedSessionRepository.class.getName());
    assertThat(analysis.getAction()).contains("spring.session.store-type");
}
Also used : HazelcastIndexedSessionRepository(org.springframework.session.hazelcast.HazelcastIndexedSessionRepository) JdbcIndexedSessionRepository(org.springframework.session.jdbc.JdbcIndexedSessionRepository) FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) Test(org.junit.jupiter.api.Test)

Aggregations

FailureAnalysis (org.springframework.boot.diagnostics.FailureAnalysis)89 Test (org.junit.jupiter.api.Test)69 Test (org.junit.Test)6 MapPropertySource (org.springframework.core.env.MapPropertySource)6 InvalidConfigurationPropertyValueException (org.springframework.boot.context.properties.source.InvalidConfigurationPropertyValueException)4 MutuallyExclusiveConfigurationPropertiesException (org.springframework.boot.context.properties.source.MutuallyExclusiveConfigurationPropertiesException)4 BeanCreationException (org.springframework.beans.factory.BeanCreationException)3 InjectionPoint (org.springframework.beans.factory.InjectionPoint)3 LinkedHashMap (java.util.LinkedHashMap)2 FailureAnalyzer (org.springframework.boot.diagnostics.FailureAnalyzer)2 FieldError (org.springframework.validation.FieldError)2 JCacheNotFoundException (com.giffing.bucket4j.spring.boot.starter.exception.JCacheNotFoundException)1 MissingKeyFilterExpressionException (com.giffing.bucket4j.spring.boot.starter.exception.MissingKeyFilterExpressionException)1 Annotation (java.lang.annotation.Annotation)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ErrorMessage (org.modelmapper.spi.ErrorMessage)1 FatalBeanException (org.springframework.beans.FatalBeanException)1 NoUniqueBeanDefinitionException (org.springframework.beans.factory.NoUniqueBeanDefinitionException)1 LoggingFailureAnalysisReporter (org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter)1