List of usage examples for org.springframework.mock.web.test MockServletContext addInitParameter
public void addInitParameter(String name, String value)
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"); }/*from w ww .ja v a 2 s. 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 ww w. ja va2s . co m*/ assertLogOutput(); } finally { listener.contextDestroyed(new ServletContextEvent(sc)); } assertTrue(MockLog4jAppender.closeCalled); }