RemoteConfig extends ChangeableConfig { public void start() { initZookeeper(); } RemoteConfig(String name, String path, List<String> paths, CuratorFramework client); void start(); String getPath(); CuratorFramework getClient(); @Override String toString();  }
@Test public void testLoad() throws Exception { String basePath = "/auto/config/test"; ArrayList<String> paths = Lists.newArrayList("127.0.0.1:8080", "127.0.0.1", "profile", "appName"); RemoteConfig config = new RemoteConfig("application.properties", basePath, paths, client); config.start(); assertThat(config.getInt("a"), is(0)); String appPath = ZKPaths.makePath(basePath, "appName"); String s = "a=1"; create(client, appPath, newBytes(s)); assertThat(newString(getData(client, appPath)), is(s)); busyWait(); assertThat(config.getInt("a"), is(1)); String notUsed = ZKPaths.makePath(basePath, "notUsed"); create(client, notUsed, newBytes("null")); busyWait(); assertThat(config.getInt("a"), is(1)); delete(client, notUsed); busyWait(); assertThat(config.getInt("a"), is(1)); s = "a = 2"; String profilePath = ZKPaths.makePath(basePath, "profile"); create(client, profilePath, newBytes(s)); assertThat(newString(getData(client, profilePath)), is(s)); busyWait(); assertThat(config.getInt("a"), is(2)); s = "a = 3"; String ipPath = ZKPaths.makePath(basePath, "127.0.0.1"); create(client, ipPath, newBytes(s)); assertThat(newString(getData(client, ipPath)), is(s)); busyWait(); assertThat(config.getInt("a"), is(3)); s = "b = 4"; setData(client, profilePath, newBytes(s)); assertThat(newString(getData(client, profilePath)), is(s)); busyWait(); assertThat(config.getInt("a"), is(3)); assertThat(config.getInt("b"), is(0)); delete(client, ipPath); busyWait(); assertThat(config.getInt("a"), is(0)); assertThat(config.getInt("b"), is(4)); delete(client, profilePath); busyWait(); assertThat(config.getInt("a"), is(1)); assertThat(config.getInt("b"), is(0)); delete(client, basePath); busyWait(); assertThat(config.getInt("a"), is(0)); create(client, ipPath, newBytes(s)); busyWait(); assertThat(config.getInt("b"), is(4)); }