@Test
public void testInstall() {
ConfigurationManager.getConfigInstance().setProperty("prop1", "abc");
assertEquals("abc", ConfigurationManager.getConfigInstance().getProperty("prop1"));
assertEquals("abc", prop1.get());
BaseConfiguration newConfig = new BaseConfiguration();
newConfig.setProperty("prop1", "fromNewConfig");
ConfigurationManager.install(newConfig);
assertEquals("fromNewConfig", ConfigurationManager.getConfigInstance().getProperty("prop1"));
assertEquals("fromNewConfig", prop1.get());
newConfig.setProperty("prop1", "changed");
assertEquals("changed", ConfigurationManager.getConfigInstance().getProperty("prop1"));
assertEquals("changed", prop1.get());
try {
ConfigurationManager.install(new BaseConfiguration());
fail("IllegalStateExceptionExpected");
} catch (IllegalStateException e) {
assertNotNull(e);
}
try {
DynamicPropertyFactory.initWithConfigurationSource(new BaseConfiguration());
fail("IllegalStateExceptionExpected");
} catch (IllegalStateException e) {
assertNotNull(e);
}
}