// creating the subtree for chRoot clients.
String chRoot = createNameSpace();
// checking the child version using chRoot client.
zk_chroot = createClient(this.hostPort + chRoot);
String childPath = "/myid";
Transaction transaction = zk_chroot.transaction();
transaction.create(childPath, new byte[0], Ids.OPEN_ACL_UNSAFE,
CreateMode.PERSISTENT);
transaction.check(childPath, 0);
transaction.setData(childPath, childPath.getBytes(), 0);
transaction.commit();
Assert.assertNotNull("zNode is not created under chroot:" + chRoot, zk
.exists(chRoot + childPath, false));
Assert.assertNotNull("zNode is not created under chroot:" + chRoot,
zk_chroot.exists(childPath, false));
Assert.assertNull("zNode is created directly under '/', ignored configured chroot",
zk.exists(childPath, false));
Assert.assertArrayEquals("zNode data not matching", childPath
.getBytes(), zk_chroot.getData(childPath, false, null));
transaction = zk_chroot.transaction();
// Deleting child using chRoot client.
transaction.delete(childPath, 1);
transaction.commit();
Assert.assertNull("chroot:" + chRoot + " exists after delete", zk
.exists(chRoot + "/myid", false));
Assert.assertNull("chroot:" + chRoot + " exists after delete",
zk_chroot.exists("/myid", false));