public void testRingStateListener() throws Exception { Ring ring = ZkRing.create(getZk(), coordinator, getRoot(), 1, null, 1); MockListener mockListener = new MockListener(); ring.setStateChangeListener(mockListener); synchronized (mockListener) { mockListener.wait(1000); } assertNull(mockListener.calledWith); ring.setState(RingState.CLOSED); synchronized (mockListener) { mockListener.wait(1000); } assertEquals(ring, mockListener.calledWith); }
public void testRingStateListener() throws Exception { Ring rc = ZkRing.create(getZk(), getRoot(), 1, null, 1); MockListener mockListener = new MockListener(); rc.setStateChangeListener(mockListener); synchronized (mockListener) { mockListener.wait(1000); } assertNull(mockListener.calledWith); rc.setState(RingState.DOWN); synchronized (mockListener) { mockListener.wait(1000); } assertEquals(rc, mockListener.calledWith); }