childBuilder instanceof ReloadingControllerSupport);
ReloadingController ctrl =
((ReloadingControllerSupport) childBuilder)
.getReloadingController();
ctrl.checkForReloading(null); // initialize reloading
BuilderEventListenerImpl l = new BuilderEventListenerImpl();
childBuilder.addEventListener(ConfigurationBuilderEvent.RESET, l);
reloadConfig.setProperty(key, "yes");
handler.save();
int attempts = 10;
boolean changeDetected;
do
{
changeDetected = ctrl.checkForReloading(null);
if (!changeDetected)
{
Thread.sleep(1000);
handler.save(outFile);
}
} while (!changeDetected && --attempts > 0);
assertTrue("No change detected", changeDetected);
assertEquals("Wrong updated property", "yes", builder
.getConfiguration().getString(key));
ConfigurationBuilderEvent event = l.nextEvent(ConfigurationBuilderEvent.RESET);
l.assertNoMoreEvents();
BasicConfigurationBuilder<? extends Configuration> multiBuilder =
(BasicConfigurationBuilder<? extends Configuration>) event.getSource();
childBuilder.removeEventListener(ConfigurationBuilderEvent.RESET, l);
multiBuilder.resetResult();
l.assertNoMoreEvents();
}
finally
{
assertTrue("Output file could not be deleted", outFile.delete());
}