Search in sources :

Example 61 with AnnotationConfigApplicationContext

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);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Cache(org.springframework.cache.Cache) Test(org.junit.Test)

Example 62 with AnnotationConfigApplicationContext

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();
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) AnnotatedGenericBeanDefinition(org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Example 63 with AnnotationConfigApplicationContext

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;
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext)

Example 64 with AnnotationConfigApplicationContext

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");
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ContextCustomizer(org.springframework.test.context.ContextCustomizer) Test(org.junit.Test)

Example 65 with AnnotationConfigApplicationContext

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();
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) DefaultListableBeanFactory(org.springframework.beans.factory.support.DefaultListableBeanFactory) Test(org.junit.Test)

Aggregations

AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)800 Test (org.junit.Test)528 DSLContext (org.jooq.DSLContext)53 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)42 ApplicationContext (org.springframework.context.ApplicationContext)25 Before (org.junit.Before)23 DIConfiguration (com.khartec.waltz.service.DIConfiguration)15 Filter (javax.servlet.Filter)15 Map (java.util.Map)14 OncePerRequestFilter (org.springframework.web.filter.OncePerRequestFilter)14 TestBean (org.springframework.tests.sample.beans.TestBean)13 PropertyPlaceholderAutoConfiguration (org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration)12 MockMvc (org.springframework.test.web.servlet.MockMvc)12 EntityKind (com.khartec.waltz.model.EntityKind)11 List (java.util.List)10 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)10 MockEnvironment (org.springframework.mock.env.MockEnvironment)10 EntityReference (com.khartec.waltz.model.EntityReference)9 MapPropertySource (org.springframework.core.env.MapPropertySource)9 IOException (java.io.IOException)8