@Test
  public void testCoordinateListenerStolenCoordinate() throws Exception {

    final CountDownLatch connectedLatch1 = new CountDownLatch(1);
    final CountDownLatch connectedLatch2 = new CountDownLatch(2);
    TestCoordinateListener listener = setUpListenerEnvironment(connectedLatch1, connectedLatch2);
    assertTrue(connectedLatch1.await(20, TimeUnit.SECONDS));
    log.info("Killing zookeeper");
    assertTrue(zk.getState() == ZooKeeper.States.CONNECTED);

    log.info("Killing connection");
    forwarder.terminate();

    zk.delete("/cn/cell/user/service/1/status", -1);
    Util.mkdir(zk, "/cn/cell/user/service/1/status", ZooDefs.Ids.OPEN_ACL_UNSAFE);

    forwarder = new PortForwarder(forwarderPort, "127.0.0.1", zkport);

    assertTrue(connectedLatch2.await(6, TimeUnit.SECONDS));

    int i = 0;
    int q = -1;
    while (true) {
      if (q != listener.events.size()) {
        q = listener.events.size();
      }
      if (listener.events.get(listener.events.size() - 1) == CoordinateListener.Event.NOT_OWNER) {
        break;
      }

      Thread.sleep(10);
      ++i;
      if (i > 1000) {
        fail("Did not get NOT_OWNER");
      }
    }

    // cn2.close();
    // We use the same path for the new ezk, so it reads up the old state, and hence the coordinate
    // is ok.
    //        assertEquals(CoordinateListener.Event.COORDINATE_OK, listener.events.get(2));
    forwarder.terminate();
  }