Search in sources :

Example 56 with GenericXmlApplicationContext

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);
}
Also used : GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext) Test(org.junit.jupiter.api.Test)

Example 57 with GenericXmlApplicationContext

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);
}
Also used : GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext) Test(org.junit.jupiter.api.Test)

Example 58 with GenericXmlApplicationContext

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

Example 59 with GenericXmlApplicationContext

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();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) CacheInterceptor(org.springframework.cache.interceptor.CacheInterceptor) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext) Test(org.junit.jupiter.api.Test)

Example 60 with GenericXmlApplicationContext

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();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) CacheInterceptor(org.springframework.cache.interceptor.CacheInterceptor) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext) Test(org.junit.jupiter.api.Test)

Aggregations

GenericXmlApplicationContext (org.springframework.context.support.GenericXmlApplicationContext)61 Test (org.junit.Test)21 Test (org.junit.jupiter.api.Test)13 MBeanServer (javax.management.MBeanServer)5 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)5 Scanner (java.util.Scanner)4 ObjectName (javax.management.ObjectName)4 Resource (org.springframework.core.io.Resource)4 QueueChannel (org.springframework.integration.channel.QueueChannel)4 MessageChannel (org.springframework.messaging.MessageChannel)4 ApplicationContext (org.springframework.context.ApplicationContext)3 ByteArrayResource (org.springframework.core.io.ByteArrayResource)3 Message (org.springframework.messaging.Message)3 MBeanOperationInfo (javax.management.MBeanOperationInfo)2 Server (org.eclipse.jetty.server.Server)2 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)2 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)2 BatchStatus (org.springframework.batch.core.BatchStatus)2 BeanDefinitionParsingException (org.springframework.beans.factory.parsing.BeanDefinitionParsingException)2 CacheInterceptor (org.springframework.cache.interceptor.CacheInterceptor)2