use of org.springframework.context.ConfigurableApplicationContext in project spring-framework by spring-projects.
the class AsyncAnnotationBeanPostProcessorTests method handleExceptionWithListenableFuture.
@Test
public void handleExceptionWithListenableFuture() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(ConfigWithExceptionHandler.class);
ITestBean testBean = context.getBean("target", ITestBean.class);
TestableAsyncUncaughtExceptionHandler exceptionHandler = context.getBean("exceptionHandler", TestableAsyncUncaughtExceptionHandler.class);
assertFalse("handler should not have been called yet", exceptionHandler.isCalled());
Future<Object> result = testBean.failWithListenableFuture();
assertFutureWithException(result, exceptionHandler);
}
use of org.springframework.context.ConfigurableApplicationContext in project spring-framework by spring-projects.
the class AsyncAnnotationBeanPostProcessorTests method handleExceptionWithCustomExceptionHandler.
@Test
public void handleExceptionWithCustomExceptionHandler() {
Method m = ReflectionUtils.findMethod(TestBean.class, "failWithVoid");
TestableAsyncUncaughtExceptionHandler exceptionHandler = new TestableAsyncUncaughtExceptionHandler();
BeanDefinition processorDefinition = new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.class);
processorDefinition.getPropertyValues().add("exceptionHandler", exceptionHandler);
ConfigurableApplicationContext context = initContext(processorDefinition);
ITestBean testBean = context.getBean("target", ITestBean.class);
assertFalse("Handler should not have been called", exceptionHandler.isCalled());
testBean.failWithVoid();
exceptionHandler.await(3000);
exceptionHandler.assertCalledWith(m, UnsupportedOperationException.class);
}
use of org.springframework.context.ConfigurableApplicationContext in project sakuli by ConSol.
the class BeanLoader method releaseContext.
/**
* Release the context and shuts the hole context down
*/
public static void releaseContext() {
loadBean(SakuliPropertyPlaceholderConfigurer.class).restoreProperties();
BeanFactory beanFactory = getBeanFactory();
if (beanFactory instanceof ConfigurableApplicationContext) {
((ConfigurableApplicationContext) beanFactory).close();
}
}
use of org.springframework.context.ConfigurableApplicationContext in project webservices-axiom by apache.
the class ScenarioTestCase method setUp.
@Override
protected void setUp() throws Exception {
server = new Server();
// Set up a custom thread pool to improve thread names (for logging purposes)
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setName("jetty");
server.setThreadPool(threadPool);
Connector connector = new SelectChannelConnector();
connector.setPort(0);
server.setConnectors(new Connector[] { connector });
ServletContextHandler handler = new ServletContextHandler(server, "/");
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setContextClass(GenericWebApplicationContext.class);
servlet.setContextInitializers(new ApplicationContextInitializer<ConfigurableApplicationContext>() {
public void initialize(ConfigurableApplicationContext applicationContext) {
configureContext((GenericWebApplicationContext) applicationContext, config.getServerMessageFactoryConfigurator(), new ClassPathResource("server.xml", ScenarioTestCase.this.getClass()));
}
});
ServletHolder servletHolder = new ServletHolder(servlet);
servletHolder.setName("spring-ws");
servletHolder.setInitOrder(1);
handler.addServlet(servletHolder, "/*");
server.start();
context = new GenericXmlApplicationContext();
MockPropertySource propertySource = new MockPropertySource("client-properties");
propertySource.setProperty("port", connector.getLocalPort());
context.getEnvironment().getPropertySources().replace(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, propertySource);
configureContext(context, config.getClientMessageFactoryConfigurator(), new ClassPathResource("client.xml", getClass()));
context.refresh();
}
use of org.springframework.context.ConfigurableApplicationContext in project dubbo by alibaba.
the class Spring3CompatibilityTest method startConsumer.
private static ConfigurableApplicationContext startConsumer() {
ConfigurableApplicationContext context = startupApplicationContext(ConsumerConfiguration.class);
System.out.println("Startup Consumer ...");
return context;
}
Aggregations