Search in sources :

Example 1 with BeanDefinitionOverrideException

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

the class BeanDefinitionOverrideFailureAnalyzerTests method createFailure.

private BeanDefinitionOverrideException createFailure(ApplicationContextInitializer<AnnotationConfigApplicationContext> initializer) {
    try {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
        context.setAllowBeanDefinitionOverriding(false);
        initializer.initialize(context);
        context.refresh();
        context.close();
        return null;
    } catch (BeanDefinitionOverrideException ex) {
        return ex;
    }
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) BeanDefinitionOverrideException(org.springframework.beans.factory.support.BeanDefinitionOverrideException)

Example 2 with BeanDefinitionOverrideException

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

the class BeanDefinitionOverrideFailureAnalyzerTests method performAnalysis.

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

Example 3 with BeanDefinitionOverrideException

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

the class BeanDefinitionOverrideFailureAnalyzerTests method createFailure.

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

Example 4 with BeanDefinitionOverrideException

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

the class BeanDefinitionOverrideFailureAnalyzerTests method performAnalysis.

private FailureAnalysis performAnalysis(ApplicationContextInitializer<AnnotationConfigApplicationContext> initializer) {
    BeanDefinitionOverrideException failure = createFailure(initializer);
    assertThat(failure).isNotNull();
    return new BeanDefinitionOverrideFailureAnalyzer().analyze(failure);
}
Also used : BeanDefinitionOverrideException(org.springframework.beans.factory.support.BeanDefinitionOverrideException)

Aggregations

BeanDefinitionOverrideException (org.springframework.beans.factory.support.BeanDefinitionOverrideException)4 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)2