use of org.springframework.beans.factory.BeanCreationException in project spring-boot by spring-projects.
the class LiquibaseChangelogMissingFailureAnalyzerTests method performAnalysis.
private FailureAnalysis performAnalysis() {
BeanCreationException failure = createFailure();
assertThat(failure).isNotNull();
return new LiquibaseChangelogMissingFailureAnalyzer().analyze(failure);
}
use of org.springframework.beans.factory.BeanCreationException in project spring-boot by spring-projects.
the class UnboundConfigurationPropertyFailureAnalyzerTests 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;
}
}
use of org.springframework.beans.factory.BeanCreationException in project spring-boot by spring-projects.
the class ConnectionFactoryBeanCreationFailureAnalyzerTests method performAnalysis.
private FailureAnalysis performAnalysis(Class<?> configuration) {
BeanCreationException failure = createFailure(configuration);
assertThat(failure).isNotNull();
ConnectionFactoryBeanCreationFailureAnalyzer failureAnalyzer = new ConnectionFactoryBeanCreationFailureAnalyzer(this.environment);
return failureAnalyzer.analyze(failure);
}
use of org.springframework.beans.factory.BeanCreationException in project spring-boot by spring-projects.
the class ConnectionFactoryBeanCreationFailureAnalyzerTests method createFailure.
private BeanCreationException createFailure(Class<?> configuration) {
try {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
context.setClassLoader(new FilteredClassLoader("io.r2dbc.h2", "io.r2dbc.pool"));
context.setEnvironment(this.environment);
context.register(configuration);
context.refresh();
context.close();
return null;
} catch (BeanCreationException ex) {
return ex;
}
}
use of org.springframework.beans.factory.BeanCreationException in project spring-boot by spring-projects.
the class MockitoPostProcessor method inject.
private void inject(Field field, Object target, String beanName) {
try {
field.setAccessible(true);
Object existingValue = ReflectionUtils.getField(field, target);
Object bean = this.beanFactory.getBean(beanName, field.getType());
if (existingValue == bean) {
return;
}
Assert.state(existingValue == null, () -> "The existing value '" + existingValue + "' of field '" + field + "' is not the same as the new value '" + bean + "'");
ReflectionUtils.setField(field, target, bean);
} catch (Throwable ex) {
throw new BeanCreationException("Could not inject field: " + field, ex);
}
}
Aggregations