Search in sources :

Example 71 with AnnotationConfigApplicationContext

use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project spring-boot by spring-projects.

the class ServletComponentScanRegistrarTests method packagesConfiguredWithValueAsm.

@Test
public void packagesConfiguredWithValueAsm() {
    this.context = new AnnotationConfigApplicationContext();
    this.context.registerBeanDefinition("valuePackages", new RootBeanDefinition(ValuePackages.class.getName()));
    this.context.refresh();
    ServletComponentRegisteringPostProcessor postProcessor = this.context.getBean(ServletComponentRegisteringPostProcessor.class);
    assertThat(postProcessor.getPackagesToScan()).contains("com.example.foo", "com.example.bar");
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) Test(org.junit.Test)

Example 72 with AnnotationConfigApplicationContext

use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project spring-framework by spring-projects.

the class JCacheErrorHandlerTests method setup.

@Before
public void setup() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
    this.cache = context.getBean("mockCache", Cache.class);
    this.errorCache = context.getBean("mockErrorCache", Cache.class);
    this.errorHandler = context.getBean(CacheErrorHandler.class);
    this.simpleService = context.getBean(SimpleService.class);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) CacheErrorHandler(org.springframework.cache.interceptor.CacheErrorHandler) Cache(org.springframework.cache.Cache) Before(org.junit.Before)

Example 73 with AnnotationConfigApplicationContext

use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project spring-framework by spring-projects.

the class JCacheJavaConfigTests method bothSetOnlyResolverIsUsed.

@Test
public void bothSetOnlyResolverIsUsed() {
    ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(FullCachingConfigSupport.class);
    DefaultJCacheOperationSource cos = context.getBean(DefaultJCacheOperationSource.class);
    assertSame(context.getBean("cacheResolver"), cos.getCacheResolver());
    assertSame(context.getBean("keyGenerator"), cos.getKeyGenerator());
    assertSame(context.getBean("exceptionCacheResolver"), cos.getExceptionCacheResolver());
    context.close();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) DefaultJCacheOperationSource(org.springframework.cache.jcache.interceptor.DefaultJCacheOperationSource) Test(org.junit.Test)

Example 74 with AnnotationConfigApplicationContext

use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project spring-framework by spring-projects.

the class JCacheJavaConfigTests method fullCachingConfig.

@Test
public void fullCachingConfig() throws Exception {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(FullCachingConfig.class);
    DefaultJCacheOperationSource cos = context.getBean(DefaultJCacheOperationSource.class);
    assertSame(context.getBean(KeyGenerator.class), cos.getKeyGenerator());
    assertSame(context.getBean("cacheResolver", CacheResolver.class), cos.getCacheResolver());
    assertSame(context.getBean("exceptionCacheResolver", CacheResolver.class), cos.getExceptionCacheResolver());
    JCacheInterceptor interceptor = context.getBean(JCacheInterceptor.class);
    assertSame(context.getBean("errorHandler", CacheErrorHandler.class), interceptor.getErrorHandler());
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) JCacheInterceptor(org.springframework.cache.jcache.interceptor.JCacheInterceptor) DefaultJCacheOperationSource(org.springframework.cache.jcache.interceptor.DefaultJCacheOperationSource) SimpleCacheErrorHandler(org.springframework.cache.interceptor.SimpleCacheErrorHandler) CacheErrorHandler(org.springframework.cache.interceptor.CacheErrorHandler) SimpleCacheResolver(org.springframework.cache.interceptor.SimpleCacheResolver) CacheResolver(org.springframework.cache.interceptor.CacheResolver) NamedCacheResolver(org.springframework.cache.interceptor.NamedCacheResolver) SomeKeyGenerator(org.springframework.cache.config.SomeKeyGenerator) KeyGenerator(org.springframework.cache.interceptor.KeyGenerator) SimpleKeyGenerator(org.springframework.cache.interceptor.SimpleKeyGenerator) Test(org.junit.Test)

Example 75 with AnnotationConfigApplicationContext

use of org.springframework.context.annotation.AnnotationConfigApplicationContext in project spring-framework by spring-projects.

the class JCacheJavaConfigTests method emptyConfigSupport.

@Test
public void emptyConfigSupport() {
    ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(EmptyConfigSupportConfig.class);
    DefaultJCacheOperationSource cos = context.getBean(DefaultJCacheOperationSource.class);
    assertNotNull(cos.getCacheResolver());
    assertEquals(SimpleCacheResolver.class, cos.getCacheResolver().getClass());
    assertSame(context.getBean(CacheManager.class), ((SimpleCacheResolver) cos.getCacheResolver()).getCacheManager());
    assertNull(cos.getExceptionCacheResolver());
    context.close();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) DefaultJCacheOperationSource(org.springframework.cache.jcache.interceptor.DefaultJCacheOperationSource) SimpleCacheManager(org.springframework.cache.support.SimpleCacheManager) ConcurrentMapCacheManager(org.springframework.cache.concurrent.ConcurrentMapCacheManager) CacheManager(org.springframework.cache.CacheManager) NoOpCacheManager(org.springframework.cache.support.NoOpCacheManager) 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