use of org.springframework.web.context.ContextLoaderListener in project spring-framework by spring-projects.
the class Spr8510Tests method annotationConfigWAC.
/**
* Ensure that ContextLoaderListener and AnnotationConfigApplicationContext interact nicely.
*/
@Test
public void annotationConfigWAC() {
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
ctx.scan("does.not.matter");
ContextLoaderListener cll = new ContextLoaderListener(ctx);
cll.contextInitialized(new ServletContextEvent(new MockServletContext()));
}
use of org.springframework.web.context.ContextLoaderListener in project opennms by OpenNMS.
the class HttpRemotingContextIT method testLoadContext.
public void testLoadContext() throws Throwable {
DaoTestConfigBean bean = new DaoTestConfigBean();
bean.afterPropertiesSet();
MockDatabase db = new MockDatabase(true);
DataSourceFactory.setInstance(db);
servletContext = new MockServletContext("file:src/main/webapp");
servletContext.addInitParameter("contextConfigLocation", "classpath:/META-INF/opennms/applicationContext-commonConfigs.xml " + "classpath:/META-INF/opennms/applicationContext-soa.xml " + "classpath:/META-INF/opennms/applicationContext-mockDao.xml " + "classpath*:/META-INF/opennms/component-service.xml " + "classpath*:/META-INF/opennms/component-dao.xml " + // Contexts within this project
"/WEB-INF/applicationContext-common.xml " + "/WEB-INF/applicationContext-serviceRegistryRemoting.xml " + "/WEB-INF/applicationContext-spring-security.xml " + "/WEB-INF/applicationContext-svclayer.xml ");
servletContext.addInitParameter("parentContextKey", "daoContext");
ServletContextEvent e = new ServletContextEvent(servletContext);
contextListener = new ContextLoaderListener();
contextListener.contextInitialized(e);
servletContext.setContextPath(contextPath);
servletConfig = new MockServletConfig(servletContext, "dispatcher");
servletConfig.addInitParameter("com.sun.jersey.config.property.resourceConfigClass", "com.sun.jersey.api.core.PackagesResourceConfig");
servletConfig.addInitParameter("com.sun.jersey.config.property.packages", "org.opennms.web.rest");
try {
MockFilterConfig filterConfig = new MockFilterConfig(servletContext, "openSessionInViewFilter");
filter = new OpenSessionInViewFilter();
filter.init(filterConfig);
} catch (ServletException se) {
throw se.getRootCause();
}
}
Aggregations