use of com.kixeye.chassis.bootstrap.configuration.zookeeper.ZookeeperConfigurationProvider in project chassis by Kixeye.
the class ConfigurationBuilderTest method zookeeperHappy.
@Test
public void zookeeperHappy() throws Exception {
String key = ZOOKEEPER_CONFIG_ROOT + "/" + MODULE_1_KEY_1;
curatorFramework.create().creatingParentsIfNeeded().forPath(key, MODULE_1_VALUE_1.getBytes());
Assert.assertEquals(MODULE_1_VALUE_1, new String(curatorFramework.getData().forPath(key)));
configurationBuilder.withConfigurationProvider(new ZookeeperConfigurationProvider(zookeeperServer.getConnectString()));
Configuration configuration = configurationBuilder.build();
Assert.assertEquals(MODULE_1_VALUE_1, configuration.getString(MODULE_1_KEY_1));
}
use of com.kixeye.chassis.bootstrap.configuration.zookeeper.ZookeeperConfigurationProvider in project chassis by Kixeye.
the class ConfigurationBuilderTest method missingZookeeperConfig_writeDefaultsEnvironmentFileOverride.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void missingZookeeperConfig_writeDefaultsEnvironmentFileOverride() throws Exception {
TestUtils.writePropertiesToFile(TEST_APP_CONFIG_PROPERTIES, filesCreated, new SimpleEntry(BootstrapConfigKeys.PUBLISH_DEFAULTS_KEY.getPropertyName(), "false"));
TestUtils.writePropertiesToFile(TEST_APP_CONFIG_PROPERTIES.replace(".properties", "." + ENVIRONMENT + ".properties"), filesCreated, new SimpleEntry(BootstrapConfigKeys.PUBLISH_DEFAULTS_KEY.getPropertyName(), "true"));
TestUtils.deleteAll(curatorFramework);
Assert.assertNull(curatorFramework.checkExists().forPath(ZOOKEEPER_CONFIG_ROOT));
configurationBuilder.withConfigurationProvider(new ZookeeperConfigurationProvider(zookeeperServer.getConnectString()));
configurationBuilder.withApplicationProperties("file://" + TEST_APP_CONFIG_PROPERTIES);
configurationBuilder.build();
Assert.assertNotNull(curatorFramework.checkExists().forPath(ZOOKEEPER_CONFIG_ROOT));
Assert.assertEquals(MODULE_1_VALUE_1, new String(curatorFramework.getData().forPath(ZOOKEEPER_CONFIG_ROOT + "/" + MODULE_1_KEY_1)));
Assert.assertEquals(MODULE_1_VALUE_2, new String(curatorFramework.getData().forPath(ZOOKEEPER_CONFIG_ROOT + "/" + MODULE_1_KEY_2)));
Assert.assertEquals(MODULE_1_VALUE_3, new String(curatorFramework.getData().forPath(ZOOKEEPER_CONFIG_ROOT + "/" + MODULE_1_KEY_3)));
Assert.assertEquals(MODULE_2_VALUE_1, new String(curatorFramework.getData().forPath(ZOOKEEPER_CONFIG_ROOT + "/" + MODULE_2_KEY_1)));
Assert.assertEquals(4, curatorFramework.getChildren().forPath(ZOOKEEPER_CONFIG_ROOT).size());
}
use of com.kixeye.chassis.bootstrap.configuration.zookeeper.ZookeeperConfigurationProvider in project chassis by Kixeye.
the class ConfigurationBuilderTest method missingZookeeperConfig_writeDefaults.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void missingZookeeperConfig_writeDefaults() throws Exception {
TestUtils.writePropertiesToFile(TEST_APP_CONFIG_PROPERTIES, filesCreated, new SimpleEntry(BootstrapConfigKeys.PUBLISH_DEFAULTS_KEY.getPropertyName(), "true"));
TestUtils.deleteAll(curatorFramework);
Assert.assertNull(curatorFramework.checkExists().forPath(ZOOKEEPER_CONFIG_ROOT));
configurationBuilder.withConfigurationProvider(new ZookeeperConfigurationProvider(zookeeperServer.getConnectString()));
configurationBuilder.withApplicationProperties("file://" + TEST_APP_CONFIG_PROPERTIES);
configurationBuilder.build();
Assert.assertNotNull(curatorFramework.checkExists().forPath(ZOOKEEPER_CONFIG_ROOT));
Assert.assertEquals(MODULE_1_VALUE_1, new String(curatorFramework.getData().forPath(ZOOKEEPER_CONFIG_ROOT + "/" + MODULE_1_KEY_1)));
Assert.assertEquals(MODULE_1_VALUE_2, new String(curatorFramework.getData().forPath(ZOOKEEPER_CONFIG_ROOT + "/" + MODULE_1_KEY_2)));
Assert.assertEquals(MODULE_1_VALUE_3, new String(curatorFramework.getData().forPath(ZOOKEEPER_CONFIG_ROOT + "/" + MODULE_1_KEY_3)));
Assert.assertEquals(MODULE_2_VALUE_1, new String(curatorFramework.getData().forPath(ZOOKEEPER_CONFIG_ROOT + "/" + MODULE_2_KEY_1)));
Assert.assertEquals(4, curatorFramework.getChildren().forPath(ZOOKEEPER_CONFIG_ROOT).size());
}
use of com.kixeye.chassis.bootstrap.configuration.zookeeper.ZookeeperConfigurationProvider in project chassis by Kixeye.
the class ConfigurationBuilderTest method missingZookeeperConfig_writeDefaultsDisabledInConfig.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test(expected = ApplicationConfigurationNotFoundException.class)
public void missingZookeeperConfig_writeDefaultsDisabledInConfig() throws Exception {
TestUtils.writePropertiesToFile(TEST_APP_CONFIG_PROPERTIES, filesCreated, new SimpleEntry(BootstrapConfigKeys.PUBLISH_DEFAULTS_KEY.getPropertyName(), "false"));
TestUtils.deleteAll(curatorFramework);
Assert.assertNull(curatorFramework.checkExists().forPath(ZOOKEEPER_CONFIG_ROOT));
configurationBuilder.withConfigurationProvider(new ZookeeperConfigurationProvider(zookeeperServer.getConnectString()));
configurationBuilder.withApplicationProperties("file://" + TEST_APP_CONFIG_PROPERTIES);
configurationBuilder.build();
}
use of com.kixeye.chassis.bootstrap.configuration.zookeeper.ZookeeperConfigurationProvider in project chassis by Kixeye.
the class ConfigurationBuilderTest method missingZookeeperConfig.
@Test(expected = ApplicationConfigurationNotFoundException.class)
public void missingZookeeperConfig() throws Exception {
TestUtils.deleteAll(curatorFramework);
Assert.assertNull(curatorFramework.checkExists().forPath(ZOOKEEPER_CONFIG_ROOT));
configurationBuilder.withConfigurationProvider(new ZookeeperConfigurationProvider(zookeeperServer.getConnectString()));
configurationBuilder.build();
}
Aggregations