use of com.kixeye.chassis.bootstrap.configuration.DefaultPropertyFilter in project chassis by Kixeye.
the class ZookeeperConfigurationProvider method writeApplicationConfiguration.
@Override
public void writeApplicationConfiguration(String environment, String applicationName, String applicationVersion, AbstractConfiguration configuration, boolean allowOverwrite) {
ZookeeperConfigurationWriter writer = new ZookeeperConfigurationWriter(applicationName, environment, applicationVersion, curatorFramework, allowOverwrite);
writer.write(configuration, new DefaultPropertyFilter());
}
use of com.kixeye.chassis.bootstrap.configuration.DefaultPropertyFilter in project chassis by Kixeye.
the class ZookeeperConfigurationWriterTest method noBasePathExists.
@Test
public void noBasePathExists() throws Exception {
Assert.assertNull(curatorFramework.checkExists().forPath(base));
try (CuratorFramework zkCurator = createCuratorFramework()) {
ZookeeperConfigurationWriter writer = new ZookeeperConfigurationWriter(applicationName, environmentName, version, zkCurator, false);
writer.write(new MapConfiguration(props), new DefaultPropertyFilter());
Assert.assertEquals(val1, new String(curatorFramework.getData().forPath(base + "/" + key1)));
}
}
use of com.kixeye.chassis.bootstrap.configuration.DefaultPropertyFilter in project chassis by Kixeye.
the class ZookeeperConfigurationWriterTest method partialBasePathExists.
@Test
public void partialBasePathExists() throws Exception {
Assert.assertNull(curatorFramework.checkExists().forPath(base));
curatorFramework.create().forPath("/" + environmentName);
Assert.assertNotNull(curatorFramework.checkExists().forPath("/" + environmentName));
try (CuratorFramework zkCurator = createCuratorFramework()) {
ZookeeperConfigurationWriter writer = new ZookeeperConfigurationWriter(applicationName, environmentName, version, zkCurator, false);
writer.write(new MapConfiguration(props), new DefaultPropertyFilter());
Assert.assertEquals(val1, new String(curatorFramework.getData().forPath(base + "/" + key1)));
}
}
use of com.kixeye.chassis.bootstrap.configuration.DefaultPropertyFilter in project chassis by Kixeye.
the class ZookeeperConfigurationWriterTest method basePathExists_overwrite.
@Test
public void basePathExists_overwrite() throws Exception {
Assert.assertNull(curatorFramework.checkExists().forPath(base));
try (CuratorFramework zkCurator = createCuratorFramework()) {
ZookeeperConfigurationWriter writer = new ZookeeperConfigurationWriter(applicationName, environmentName, version, zkCurator, true);
writer.write(new MapConfiguration(props), new DefaultPropertyFilter());
Assert.assertEquals(val1, new String(curatorFramework.getData().forPath(base + "/" + key1)));
Assert.assertEquals(val2, new String(curatorFramework.getData().forPath(base + "/" + key2)));
String key3 = RandomUtils.nextInt() + "";
String val3 = RandomUtils.nextInt() + "";
String newVal1 = RandomUtils.nextInt() + "";
props.clear();
//updates key1
props.put(key1, newVal1);
//adds key3
props.put(key3, val3);
//key2 should be deleted
writer.write(new MapConfiguration(props), new DefaultPropertyFilter());
Assert.assertEquals(newVal1, new String(curatorFramework.getData().forPath(base + "/" + key1)));
Assert.assertEquals(val3, new String(curatorFramework.getData().forPath(base + "/" + key3)));
Assert.assertNull(curatorFramework.checkExists().forPath(base + "/" + key2));
}
}
use of com.kixeye.chassis.bootstrap.configuration.DefaultPropertyFilter in project chassis by Kixeye.
the class ZookeeperConfigurationWriterTest method basePathExists_noOverwrite.
@Test
public void basePathExists_noOverwrite() throws Exception {
Assert.assertNull(curatorFramework.checkExists().forPath(base));
try (CuratorFramework zkCurator = createCuratorFramework()) {
ZookeeperConfigurationWriter writer = new ZookeeperConfigurationWriter(applicationName, environmentName, version, zkCurator, false);
writer.write(new MapConfiguration(props), new DefaultPropertyFilter());
Assert.assertEquals(val1, new String(curatorFramework.getData().forPath(base + "/" + key1)));
Assert.assertEquals(val2, new String(curatorFramework.getData().forPath(base + "/" + key2)));
try {
writer.write(new MapConfiguration(props), new DefaultPropertyFilter());
Assert.fail();
} catch (BootstrapException e) {
//expected
}
}
}
Aggregations