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();
}
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();
}
use of org.springframework.context.ConfigurableApplicationContext in project spring-boot by spring-projects.
the class Restarter method stop.
/**
* Stop the application.
* @throws Exception in case of errors
*/
protected void stop() throws Exception {
this.logger.debug("Stopping application");
this.stopLock.lock();
try {
for (ConfigurableApplicationContext context : this.rootContexts) {
context.close();
this.rootContexts.remove(context);
}
cleanupCaches();
if (this.forceReferenceCleanup) {
forceReferenceCleanup();
}
} finally {
this.stopLock.unlock();
}
System.gc();
System.runFinalization();
}
use of org.springframework.context.ConfigurableApplicationContext in project spring-boot by spring-projects.
the class AbstractDevToolsDataSourceAutoConfigurationTests method singleManuallyConfiguredDataSourceIsNotClosed.
@Test
public void singleManuallyConfiguredDataSourceIsNotClosed() throws SQLException {
ConfigurableApplicationContext context = createContext(DataSourcePropertiesConfiguration.class, SingleDataSourceConfiguration.class);
DataSource dataSource = context.getBean(DataSource.class);
Statement statement = configureDataSourceBehaviour(dataSource);
verify(statement, times(0)).execute("SHUTDOWN");
}
use of org.springframework.context.ConfigurableApplicationContext in project spring-boot by spring-projects.
the class AbstractDevToolsDataSourceAutoConfigurationTests method multipleDataSourcesAreIgnored.
@Test
public void multipleDataSourcesAreIgnored() throws SQLException {
ConfigurableApplicationContext context = createContext(DataSourcePropertiesConfiguration.class, MultipleDataSourcesConfiguration.class);
Collection<DataSource> dataSources = context.getBeansOfType(DataSource.class).values();
for (DataSource dataSource : dataSources) {
Statement statement = configureDataSourceBehaviour(dataSource);
verify(statement, times(0)).execute("SHUTDOWN");
}
}
Aggregations