use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project spring-framework by spring-projects.
the class EnableCachingIntegrationTests method beanCondition.
@Test
public void beanCondition() {
this.context = new AnnotationConfigApplicationContext(BeanConditionConfig.class);
Cache cache = getCache();
FooService service = this.context.getBean(FooService.class);
Object key = new Object();
service.getWithCondition(key);
assertCacheMiss(key, cache);
}
use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project spring-boot by spring-projects.
the class AbstractDevToolsDataSourceAutoConfigurationTests method emptyFactoryMethodMetadataIgnored.
@Test
public void emptyFactoryMethodMetadataIgnored() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
DataSource dataSource = mock(DataSource.class);
AnnotatedGenericBeanDefinition beanDefinition = new AnnotatedGenericBeanDefinition(dataSource.getClass());
context.registerBeanDefinition("dataSource", beanDefinition);
context.register(DataSourcePropertiesConfiguration.class);
context.register(DevToolsDataSourceAutoConfiguration.class);
context.refresh();
context.close();
}
use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project spring-boot by spring-projects.
the class TestDatabaseAutoConfigurationNoEmbeddedTests method doLoad.
public ConfigurableApplicationContext doLoad(Class<?> config, String... environment) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
if (config != null) {
ctx.register(config);
}
ctx.register(TestDatabaseAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(ctx, environment);
ctx.refresh();
return ctx;
}
use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project spring-boot by spring-projects.
the class PropertyMappingContextCustomizerFactoryTests method prepareContextShouldAddPropertySource.
@Test
public void prepareContextShouldAddPropertySource() throws Exception {
ContextCustomizer customizer = this.factory.createContextCustomizer(AttributeMapping.class, null);
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
customizer.customizeContext(context, null);
assertThat(context.getEnvironment().getProperty("mapped")).isEqualTo("Mapped");
}
use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project spring-boot by spring-projects.
the class BitronixDependentBeanFactoryPostProcessorTests method setsDependsOn.
@Test
public void setsDependsOn() {
DefaultListableBeanFactory beanFactory = spy(new DefaultListableBeanFactory());
this.context = new AnnotationConfigApplicationContext(beanFactory);
this.context.register(Config.class);
this.context.refresh();
String name = "bitronixTransactionManager";
verify(beanFactory).registerDependentBean(name, "dataSource");
verify(beanFactory).registerDependentBean(name, "connectionFactory");
this.context.close();
}
Aggregations