Log4jContextListener listener = new Log4jContextListener();
ServletContextEvent event = new ServletContextEvent(context);
listener.contextInitialized(event);
Logger logger = LogManager.getLogger("org.apache.test.TestConfigurator");
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config = ctx.getConfiguration();
assertNotNull("No configuration", config);
assertTrue("Incorrect Configuration. Expected " + CONFIG_NAME + " but found " + config.getName(),
CONFIG_NAME.equals(config.getName()));
Map<String, Appender> map = config.getAppenders();
assertNotNull("No Appenders", map != null && map.size() > 0);
assertTrue("Wrong configuration", map.containsKey("List"));
listener.contextDestroyed(event);
config = ctx.getConfiguration();
assertTrue("Incorrect Configuration. Expected " + DefaultConfiguration.DEFAULT_NAME + " but found " +
config.getName(), DefaultConfiguration.DEFAULT_NAME.equals(config.getName()));
}