  @Test
  public void testFactory() throws Exception {

    String name = "factory.ini";
    File f = factory.getPath().resolve(name).toFile();
    TestHelper.writeFile(ZookeeperUtil.newBytes("a=-1"), f);
    ProcessInfo info = factory.getInfo();
    String path = ZKPaths.makePath(info.getPath(), name, info.getProfile());
    final AtomicInteger num = new AtomicInteger(0);
    RemoteConfigWithCache c = (RemoteConfigWithCache) factory.getConfig(name);
    //设定延迟1s启动zkClient
    c.setDelaySeconds(1);
    c.addListener(new IChangeListener() {
      @Override
      public void changed(IConfig config) {
        num.incrementAndGet();
      }
    }, false);
    assertThat(c.getInt("a"), is(-1));
    Thread.sleep(2000);
    ZookeeperUtil.create(factory.getClient(), path, ZookeeperUtil.newBytes("a=1"));
    TestHelper.busyWait(num);
    assertThat(c.getInt("a"), is(1));

    num.set(0);
    ZookeeperUtil.setData(factory.getClient(), path, ZookeeperUtil.newBytes("a=2"));
    TestHelper.busyWait(num);
    assertThat(c.getInt("a"), is(2));
    TestHelper.deleteFile(f);
  }