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");
}
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);
}
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();
}
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());
}
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();
}
Aggregations