use of org.springframework.context.support.GenericXmlApplicationContext in project spring-framework by spring-projects.
the class GroovyAspectIntegrationTests method testJavaBean.
@Test
public void testJavaBean() {
context = new GenericXmlApplicationContext(getClass(), getClass().getSimpleName() + "-java-context.xml");
TestService bean = context.getBean("javaBean", TestService.class);
LogUserAdvice logAdvice = context.getBean(LogUserAdvice.class);
assertThat(logAdvice.getCountThrows()).isEqualTo(0);
assertThatExceptionOfType(RuntimeException.class).isThrownBy(bean::sayHello).withMessage("TestServiceImpl");
assertThat(logAdvice.getCountThrows()).isEqualTo(1);
}
use of org.springframework.context.support.GenericXmlApplicationContext in project spring-framework by spring-projects.
the class GroovyAspectIntegrationTests method testGroovyBeanDynamic.
@Test
public void testGroovyBeanDynamic() {
context = new GenericXmlApplicationContext(getClass(), getClass().getSimpleName() + "-groovy-dynamic-context.xml");
TestService bean = context.getBean("groovyBean", TestService.class);
LogUserAdvice logAdvice = context.getBean(LogUserAdvice.class);
assertThat(logAdvice.getCountThrows()).isEqualTo(0);
assertThatExceptionOfType(RuntimeException.class).isThrownBy(bean::sayHello).withMessage("GroovyServiceImpl");
// No proxy here because the pointcut only applies to the concrete class, not the interface
assertThat(logAdvice.getCountThrows()).isEqualTo(0);
assertThat(logAdvice.getCountBefore()).isEqualTo(0);
}
use of org.springframework.context.support.GenericXmlApplicationContext in project spring-framework by spring-projects.
the class JCacheAspectJNamespaceConfigTests method getApplicationContext.
@Override
protected ApplicationContext getApplicationContext() {
GenericXmlApplicationContext context = new GenericXmlApplicationContext();
// Disallow bean definition overriding to test https://github.com/spring-projects/spring-framework/pull/27499
context.setAllowBeanDefinitionOverriding(false);
context.load("/org/springframework/cache/config/annotation-jcache-aspectj.xml");
context.refresh();
return context;
}
use of org.springframework.context.support.GenericXmlApplicationContext in project spring-framework by spring-projects.
the class AnnotationNamespaceDrivenTests method bothSetOnlyResolverIsUsed.
@Test
public void bothSetOnlyResolverIsUsed() {
ConfigurableApplicationContext context = new GenericXmlApplicationContext("/org/springframework/cache/config/annotationDrivenCacheNamespace-manager-resolver.xml");
CacheInterceptor ci = context.getBean(CacheInterceptor.class);
assertThat(ci.getCacheResolver()).isSameAs(context.getBean("cacheResolver"));
context.close();
}
use of org.springframework.context.support.GenericXmlApplicationContext in project spring-framework by spring-projects.
the class AnnotationNamespaceDrivenTests method cacheResolver.
@Test
public void cacheResolver() {
ConfigurableApplicationContext context = new GenericXmlApplicationContext("/org/springframework/cache/config/annotationDrivenCacheNamespace-resolver.xml");
CacheInterceptor ci = context.getBean(CacheInterceptor.class);
assertThat(ci.getCacheResolver()).isSameAs(context.getBean("cacheResolver"));
context.close();
}
Aggregations