Search in sources :

Example 6 with ZookeeperConfigurationProvider

use of com.kixeye.chassis.bootstrap.configuration.zookeeper.ZookeeperConfigurationProvider in project chassis by Kixeye.

the class ConfigurationBuilderTest method zookeeperOverridesApplicationProperties.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void zookeeperOverridesApplicationProperties() throws Exception {
    String key1 = UUID.randomUUID().toString();
    String value1 = UUID.randomUUID().toString();
    String key2 = UUID.randomUUID().toString();
    String value2 = UUID.randomUUID().toString();
    TestUtils.writePropertiesToFile(TEST_APP_CONFIG_PROPERTIES, filesCreated, new SimpleEntry(key1, value1), new SimpleEntry(key2, value2));
    curatorFramework.create().creatingParentsIfNeeded().forPath(ZOOKEEPER_CONFIG_ROOT + "/" + key1, "zookeepervalue".getBytes());
    configurationBuilder.withConfigurationProvider(new ZookeeperConfigurationProvider(zookeeperServer.getConnectString()));
    configurationBuilder.withApplicationProperties(TEST_APP_CONFIG_PROPERTIES_SPRING_PATH);
    Configuration configuration = configurationBuilder.build();
    //assert that the zookeeper config overrode the app properties config
    Assert.assertEquals("zookeepervalue", configuration.getString(key1));
    //assert that the proper which exists in app properties but not in zookeeper is found.
    Assert.assertEquals(value2, configuration.getString(key2));
}
Also used : Configuration(org.apache.commons.configuration.Configuration) SimpleEntry(java.util.AbstractMap.SimpleEntry) ZookeeperConfigurationProvider(com.kixeye.chassis.bootstrap.configuration.zookeeper.ZookeeperConfigurationProvider) Test(org.junit.Test)

Aggregations

ZookeeperConfigurationProvider (com.kixeye.chassis.bootstrap.configuration.zookeeper.ZookeeperConfigurationProvider)6 Test (org.junit.Test)6 SimpleEntry (java.util.AbstractMap.SimpleEntry)4 Configuration (org.apache.commons.configuration.Configuration)2