use of com.kixeye.chassis.bootstrap.configuration.zookeeper.DynamicZookeeperConfigurationSource in project chassis by Kixeye.
the class DynamicZookeeperConfigurationSourceTest method instanceConfigDeletedAfterStartup.
@Test
public void instanceConfigDeletedAfterStartup() throws Exception {
curatorFramework.create().forPath(CONFIG_BASE_PATH + "/" + node);
config.addConfiguration(new DynamicWatchedConfiguration(new DynamicZookeeperConfigurationSource(curatorFramework, CONFIG_BASE_PATH, node)));
config.addConfiguration(defaultConfiguration);
Assert.assertEquals(DEF_VAL1, config.getString(DEF_KEY1));
curatorFramework.create().forPath(CONFIG_BASE_PATH + "/" + node + "/" + DEF_KEY1, "override".getBytes());
Thread.sleep(1000);
Assert.assertEquals("override", config.getString(DEF_KEY1));
curatorFramework.delete().forPath(CONFIG_BASE_PATH + "/" + node + "/" + DEF_KEY1);
curatorFramework.delete().forPath(CONFIG_BASE_PATH + "/" + node);
Thread.sleep(1000);
Assert.assertEquals(DEF_VAL1, config.getString(DEF_KEY1));
}
use of com.kixeye.chassis.bootstrap.configuration.zookeeper.DynamicZookeeperConfigurationSource in project chassis by Kixeye.
the class DynamicZookeeperConfigurationSourceTest method instanceConfigPropertyUpdated.
@Test
public void instanceConfigPropertyUpdated() throws Exception {
curatorFramework.create().forPath(CONFIG_BASE_PATH + "/" + node);
config.addConfiguration(new DynamicWatchedConfiguration(new DynamicZookeeperConfigurationSource(curatorFramework, CONFIG_BASE_PATH, node)));
config.addConfiguration(defaultConfiguration);
Assert.assertEquals(DEF_VAL1, config.getString(DEF_KEY1));
curatorFramework.create().forPath(CONFIG_BASE_PATH + "/" + node + "/" + DEF_KEY1, "override".getBytes());
Thread.sleep(1000);
Assert.assertEquals("override", config.getString(DEF_KEY1));
curatorFramework.setData().forPath(CONFIG_BASE_PATH + "/" + node + "/" + DEF_KEY1, "override2".getBytes());
Thread.sleep(1000);
Assert.assertEquals("override2", config.getString(DEF_KEY1));
}
use of com.kixeye.chassis.bootstrap.configuration.zookeeper.DynamicZookeeperConfigurationSource in project chassis by Kixeye.
the class DynamicZookeeperConfigurationSourceTest method instanceConfigPropertyAdded.
@Test
public void instanceConfigPropertyAdded() throws Exception {
curatorFramework.create().forPath(CONFIG_BASE_PATH + "/" + node);
config.addConfiguration(new DynamicWatchedConfiguration(new DynamicZookeeperConfigurationSource(curatorFramework, CONFIG_BASE_PATH, node)));
config.addConfiguration(defaultConfiguration);
Assert.assertEquals(DEF_VAL1, config.getString(DEF_KEY1));
curatorFramework.create().forPath(CONFIG_BASE_PATH + "/" + node + "/" + DEF_KEY1, "override".getBytes());
Thread.sleep(1000);
Assert.assertEquals("override", config.getString(DEF_KEY1));
}
use of com.kixeye.chassis.bootstrap.configuration.zookeeper.DynamicZookeeperConfigurationSource in project chassis by Kixeye.
the class DynamicZookeeperConfigurationSourceTest method instanceConfigDeletedAndReadded.
@Test
public void instanceConfigDeletedAndReadded() throws Exception {
curatorFramework.create().forPath(CONFIG_BASE_PATH + "/" + node);
config.addConfiguration(new DynamicWatchedConfiguration(new DynamicZookeeperConfigurationSource(curatorFramework, CONFIG_BASE_PATH, node)));
config.addConfiguration(defaultConfiguration);
Assert.assertEquals(DEF_VAL1, config.getString(DEF_KEY1));
curatorFramework.create().forPath(CONFIG_BASE_PATH + "/" + node + "/" + DEF_KEY1, "override".getBytes());
Thread.sleep(1000);
Assert.assertEquals("override", config.getString(DEF_KEY1));
curatorFramework.delete().forPath(CONFIG_BASE_PATH + "/" + node + "/" + DEF_KEY1);
curatorFramework.delete().forPath(CONFIG_BASE_PATH + "/" + node);
Thread.sleep(1000);
Assert.assertEquals(DEF_VAL1, config.getString(DEF_KEY1));
curatorFramework.create().forPath(CONFIG_BASE_PATH + "/" + node);
Thread.sleep(1000);
curatorFramework.create().forPath(CONFIG_BASE_PATH + "/" + node + "/" + DEF_KEY1, "override".getBytes());
Thread.sleep(1000);
Assert.assertEquals("override", config.getString(DEF_KEY1));
}
use of com.kixeye.chassis.bootstrap.configuration.zookeeper.DynamicZookeeperConfigurationSource in project chassis by Kixeye.
the class DynamicZookeeperConfigurationSourceTest method instanceConfigAddedAfterStartup.
@Test
public void instanceConfigAddedAfterStartup() throws Exception {
String instanceConfigNode = CONFIG_BASE_PATH + "/" + node;
Assert.assertNull(curatorFramework.checkExists().forPath(instanceConfigNode));
config.addConfiguration(new DynamicWatchedConfiguration(new DynamicZookeeperConfigurationSource(curatorFramework, CONFIG_BASE_PATH, node)));
config.addConfiguration(defaultConfiguration);
Assert.assertEquals(DEF_VAL1, config.getString(DEF_KEY1));
Assert.assertEquals(DEF_VAL2, config.getString(DEF_KEY2));
//create the instance node
curatorFramework.create().forPath(instanceConfigNode);
Thread.sleep(1000);
Assert.assertEquals(DEF_VAL1, config.getString(DEF_KEY1));
Assert.assertEquals(DEF_VAL2, config.getString(DEF_KEY2));
//create a property
String key = instanceConfigNode + "/" + DEF_KEY1;
String val = DEF_VAL1 + "--override";
curatorFramework.create().forPath(key, val.getBytes());
Thread.sleep(1000);
Assert.assertEquals(val, config.getString(DEF_KEY1));
Assert.assertEquals(DEF_VAL2, config.getString(DEF_KEY2));
}
Aggregations