Search in sources :

Example 71 with BeanCreationException

use of org.springframework.beans.factory.BeanCreationException in project spring-boot by spring-projects.

the class HikariDriverConfigurationFailureAnalyzerTests method performAnalysis.

private FailureAnalysis performAnalysis(Class<?> configuration) {
    BeanCreationException failure = createFailure(configuration);
    assertThat(failure).isNotNull();
    return new HikariDriverConfigurationFailureAnalyzer().analyze(failure);
}
Also used : BeanCreationException(org.springframework.beans.factory.BeanCreationException)

Example 72 with BeanCreationException

use of org.springframework.beans.factory.BeanCreationException in project spring-boot by spring-projects.

the class HikariDriverConfigurationFailureAnalyzerTests method createFailure.

private BeanCreationException createFailure(Class<?> configuration) {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    TestPropertyValues.of("spring.datasource.type=" + HikariDataSource.class.getName(), "spring.datasource.hikari.data-source-class-name=com.example.Foo", "spring.sql.init.mode=always").applyTo(context);
    context.register(configuration);
    try {
        context.refresh();
        context.close();
        return null;
    } catch (BeanCreationException ex) {
        return ex;
    }
}
Also used : BeanCreationException(org.springframework.beans.factory.BeanCreationException) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) HikariDataSource(com.zaxxer.hikari.HikariDataSource)

Example 73 with BeanCreationException

use of org.springframework.beans.factory.BeanCreationException in project spring-boot by spring-projects.

the class BindValidationFailureAnalyzerTests method createFailure.

private BeanCreationException createFailure(Class<?> configuration, String... environment) {
    try {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
        addEnvironment(context, environment);
        context.register(configuration);
        context.refresh();
        context.close();
        return null;
    } catch (BeanCreationException ex) {
        return ex;
    }
}
Also used : BeanCreationException(org.springframework.beans.factory.BeanCreationException) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext)

Example 74 with BeanCreationException

use of org.springframework.beans.factory.BeanCreationException in project spring-boot by spring-projects.

the class InvalidConfigurationPropertyNameFailureAnalyzerTests method createFailure.

private BeanCreationException createFailure(Class<?> configuration) {
    try {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
        context.register(configuration);
        context.refresh();
        context.close();
        return null;
    } catch (BeanCreationException ex) {
        return ex;
    }
}
Also used : BeanCreationException(org.springframework.beans.factory.BeanCreationException) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext)

Example 75 with BeanCreationException

use of org.springframework.beans.factory.BeanCreationException in project spring-boot by spring-projects.

the class InvalidConfigurationPropertyNameFailureAnalyzer method analyze.

@Override
protected FailureAnalysis analyze(Throwable rootFailure, InvalidConfigurationPropertyNameException cause) {
    BeanCreationException exception = findCause(rootFailure, BeanCreationException.class);
    String action = String.format("Modify '%s' so that it conforms to the canonical names requirements.", cause.getName());
    return new FailureAnalysis(buildDescription(cause, exception), action, cause);
}
Also used : BeanCreationException(org.springframework.beans.factory.BeanCreationException) FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis)

Aggregations

BeanCreationException (org.springframework.beans.factory.BeanCreationException)133 Test (org.junit.Test)30 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)18 BeansException (org.springframework.beans.BeansException)16 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)13 IOException (java.io.IOException)12 Map (java.util.Map)12 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)12 Test (org.junit.jupiter.api.Test)11 HashMap (java.util.HashMap)9 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)9 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)8 ArrayList (java.util.ArrayList)7 PostConstruct (javax.annotation.PostConstruct)7 NoSuchBeanDefinitionException (org.springframework.beans.factory.NoSuchBeanDefinitionException)7 Bean (org.springframework.context.annotation.Bean)7 HasId (org.apache.camel.spi.HasId)6 BeanCurrentlyInCreationException (org.springframework.beans.factory.BeanCurrentlyInCreationException)6 BeanDefinitionStoreException (org.springframework.beans.factory.BeanDefinitionStoreException)6 BeanWrapperImpl (org.springframework.beans.BeanWrapperImpl)5