Search in sources :

Example 51 with ConfigurableApplicationContext

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

the class EnableCachingTests method emptyConfigSupport.

@Test
public void emptyConfigSupport() {
    ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(EmptyConfigSupportConfig.class);
    CacheInterceptor ci = context.getBean(CacheInterceptor.class);
    assertNotNull(ci.getCacheResolver());
    assertEquals(SimpleCacheResolver.class, ci.getCacheResolver().getClass());
    assertSame(context.getBean(CacheManager.class), ((SimpleCacheResolver) ci.getCacheResolver()).getCacheManager());
    context.close();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) NoOpCacheManager(org.springframework.cache.support.NoOpCacheManager) CacheManager(org.springframework.cache.CacheManager) CacheInterceptor(org.springframework.cache.interceptor.CacheInterceptor) Test(org.junit.Test)

Example 52 with ConfigurableApplicationContext

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

the class ExpressionCachingIntegrationTests method expressionIsCacheBasedOnActualMethod.

// SPR-11692
@Test
@SuppressWarnings("unchecked")
public void expressionIsCacheBasedOnActualMethod() {
    ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(SharedConfig.class, Spr11692Config.class);
    BaseDao<User> userDao = (BaseDao<User>) context.getBean("userDao");
    BaseDao<Order> orderDao = (BaseDao<Order>) context.getBean("orderDao");
    userDao.persist(new User("1"));
    orderDao.persist(new Order("2"));
    context.close();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Test(org.junit.Test)

Example 53 with ConfigurableApplicationContext

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

the class EnableJmsTests method defaultContainerFactory.

@Override
@Test
public void defaultContainerFactory() {
    ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(EnableJmsDefaultContainerFactoryConfig.class, DefaultBean.class);
    testDefaultContainerFactoryConfiguration(context);
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Test(org.junit.Test)

Example 54 with ConfigurableApplicationContext

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

the class EnableJmsTests method lazyComponent.

@Test
public void lazyComponent() {
    ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(EnableJmsDefaultContainerFactoryConfig.class, LazyBean.class);
    JmsListenerContainerTestFactory defaultFactory = context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class);
    assertEquals(0, defaultFactory.getListenerContainers().size());
    // trigger lazy resolution
    context.getBean(LazyBean.class);
    assertEquals(1, defaultFactory.getListenerContainers().size());
    MessageListenerTestContainer container = defaultFactory.getListenerContainers().get(0);
    assertTrue("Should have been started " + container, container.isStarted());
    // close and stop the listeners
    context.close();
    assertTrue("Should have been stopped " + container, container.isStopped());
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) MessageListenerTestContainer(org.springframework.jms.config.MessageListenerTestContainer) JmsListenerContainerTestFactory(org.springframework.jms.config.JmsListenerContainerTestFactory) Test(org.junit.Test)

Example 55 with ConfigurableApplicationContext

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

the class EnableJmsTests method customConfiguration.

@Override
@Test
public void customConfiguration() {
    ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(EnableJmsCustomConfig.class, CustomBean.class);
    testCustomConfiguration(context);
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Test(org.junit.Test)

Aggregations

ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)177 Test (org.junit.Test)110 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)42 SpringApplicationBuilder (org.springframework.boot.builder.SpringApplicationBuilder)17 ApplicationContext (org.springframework.context.ApplicationContext)17 SpringApplication (org.springframework.boot.SpringApplication)14 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)13 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)13 DataSource (javax.sql.DataSource)8 ConfigurableEnvironment (org.springframework.core.env.ConfigurableEnvironment)7 JmsListenerContainerTestFactory (org.springframework.jms.config.JmsListenerContainerTestFactory)7 MBeanServer (javax.management.MBeanServer)6 ConfigurableListableBeanFactory (org.springframework.beans.factory.config.ConfigurableListableBeanFactory)6 Statement (java.sql.Statement)5 ArrayList (java.util.ArrayList)5 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)5 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)5 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)5 GenericXmlApplicationContext (org.springframework.context.support.GenericXmlApplicationContext)5 ObjectName (javax.management.ObjectName)4