CuratorZookeeperClient extends AbstractZookeeperClient<CuratorZookeeperClient.CuratorWatcherImpl, CuratorZookeeperClient.CuratorWatcherImpl> { @Override public boolean checkExists(String path) { try { if (client.checkExists().forPath(path) != null) { return true; } } catch (Exception e) { } return false; } CuratorZookeeperClient(URL url); @Override void createPersistent(String path); @Override void createEphemeral(String path); @Override List<String> getChildren(String path); @Override boolean checkExists(String path); @Override boolean isConnected(); @Override String doGetContent(String path); @Override void doClose(); @Override CuratorZookeeperClient.CuratorWatcherImpl createTargetChildListener(String path, ChildListener listener); @Override List<String> addTargetChildListener(String path, CuratorWatcherImpl listener); @Override void removeTargetChildListener(String path, CuratorWatcherImpl listener);  }
@Test public void testCheckExists() { String path = "/dubbo/org.apache.dubbo.demo.DemoService/providers"; curatorClient.create(path, false); assertThat(curatorClient.checkExists(path), is(true)); assertThat(curatorClient.checkExists(path + "/noneexits"), is(false)); }
@Test public void testCreateContent4Persistent() { String path = "/curatorTest4CrContent/content.data"; String content = "createContentTest"; curatorClient.delete(path); assertThat(curatorClient.checkExists(path), is(false)); assertNull(curatorClient.getContent(path)); curatorClient.create(path, content, false); assertThat(curatorClient.checkExists(path), is(true)); assertEquals(curatorClient.getContent(path), content); }
@Test public void testCreateContent4Temp() { String path = "/curatorTest4CrContent/content.data"; String content = "createContentTest"; curatorClient.delete(path); assertThat(curatorClient.checkExists(path), is(false)); assertNull(curatorClient.getContent(path)); curatorClient.create(path, content, true); assertThat(curatorClient.checkExists(path), is(true)); assertEquals(curatorClient.getContent(path), content); }