List of usage examples for org.springframework.mock.web.test MockServletContext MockServletContext
public MockServletContext(String resourceBasePath, @Nullable ResourceLoader resourceLoader)
From source file:org.springframework.web.util.Log4jWebConfigurerTests.java
private void initLogging(String location, boolean refreshInterval) { MockServletContext sc = new MockServletContext("", new FileSystemResourceLoader()); sc.addInitParameter(Log4jWebConfigurer.CONFIG_LOCATION_PARAM, location); if (refreshInterval) { sc.addInitParameter(Log4jWebConfigurer.REFRESH_INTERVAL_PARAM, "10"); }//w w w .j a v a 2s . co m Log4jWebConfigurer.initLogging(sc); try { assertLogOutput(); } finally { Log4jWebConfigurer.shutdownLogging(sc); } assertTrue(MockLog4jAppender.closeCalled); }
From source file:org.springframework.web.util.Log4jWebConfigurerTests.java
@Test public void testLog4jConfigListener() { Log4jConfigListener listener = new Log4jConfigListener(); MockServletContext sc = new MockServletContext("", new FileSystemResourceLoader()); sc.addInitParameter(Log4jWebConfigurer.CONFIG_LOCATION_PARAM, RELATIVE_PATH); listener.contextInitialized(new ServletContextEvent(sc)); try {/*from w ww . j av a 2 s. c o m*/ assertLogOutput(); } finally { listener.contextDestroyed(new ServletContextEvent(sc)); } assertTrue(MockLog4jAppender.closeCalled); }