@Test
public void testRebuildNode() throws Exception
{

    Timing timing = new Timing();
    PathChildrenCache cache = null;
    CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1));
    try
    {
        client.start();
        client.create().creatingParentsIfNeeded().forPath("/test/one", "one".getBytes());
        final CountDownLatch latch = new CountDownLatch(1);
        final AtomicInteger counter = new AtomicInteger();
        final Semaphore semaphore = new Semaphore(1);
        cache = new PathChildrenCache(client, "/test", true)
        {
            @Override
            void getDataAndStat(String fullPath) throws Exception
            {
                semaphore.acquire();
                counter.incrementAndGet();
                super.getDataAndStat(fullPath);
                latch.countDown();
            }
        };
        cache.start(PathChildrenCache.StartMode.BUILD_INITIAL_CACHE);
        Assert.assertTrue(timing.awaitLatch(latch));
        int saveCounter = counter.get();
        client.setData().forPath("/test/one", "alt".getBytes());
        cache.rebuildNode("/test/one");
        Assert.assertEquals(cache.getCurrentData("/test/one").getData(), "alt".getBytes());
        Assert.assertEquals(saveCounter, counter.get());
        semaphore.release(1000);
        timing.sleepABit();
    }
    finally
    {
        CloseableUtils.closeQuietly(cache);
        TestCleanState.closeAndTestClean(client);
    }
}