final String layout1 = "layout-id-1";
final String layout2 = "layout-id-2";
BlockingQueue<Multimap<String, String>> usersQueue = Queues.newSynchronousQueue();
ZooKeeperMonitor zkMonitor =
new ZooKeeperMonitor(ZooKeeperClient.getZooKeeperClient(getZKAddress()));
UsersTracker tracker =
ZooKeeperUtils.newTableUsersTracker(mZKClient, tableURI)
.registerUpdateHandler(new QueueingUsersUpdateHandler(usersQueue));
try {
tracker.start();
Assert.assertEquals(ImmutableSetMultimap.<String, String>of(),
usersQueue.poll(5, TimeUnit.SECONDS));
ZooKeeperMonitor.TableUserRegistration userRegistration =
zkMonitor.newTableUserRegistration(userID, tableURI);
try {
userRegistration.updateRegisteredLayout(layout1);
Assert.assertEquals(ImmutableSetMultimap.of(userID, layout1),
usersQueue.poll(5, TimeUnit.SECONDS));