@Test
public void testReconfiguration() throws Exception {
final File file = new File("target/test-classes/log4j2-config.xml");
file.setLastModified(System.currentTimeMillis() - 120000);
final LoggerContext ctx = Configurator.initialize("Test1", null, "target/test-classes/log4j2-config.xml");
final Logger logger = LogManager.getLogger("org.apache.test.TestConfigurator");
Configuration config = ctx.getConfiguration();
assertNotNull("No configuration", config);
assertTrue("Incorrect Configuration. Expected " + CONFIG_NAME + " but found " + config.getName(),
CONFIG_NAME.equals(config.getName()));
final Map<String, Appender<?>> map = config.getAppenders();
assertNotNull("No Appenders", map != null && map.size() > 0);
assertTrue("Wrong configuration", map.containsKey("List"));
Thread.sleep(500);
file.setLastModified(System.currentTimeMillis());
for (int i = 0; i < 17; ++i) {
logger.debug("Test message " + i);
}
final Configuration newConfig = ctx.getConfiguration();
assertTrue("Configuration not reset", newConfig != config);
Configurator.shutdown(ctx);
config = ctx.getConfiguration();