public void testGetRingState() throws Exception { Ring ring = ZkRing.create(getZk(), coordinator, getRoot(), 1, null, 1); assertEquals(RingState.CLOSED, ring.getState()); ring.setState(RingState.OPEN); assertEquals(RingState.OPEN, ring.getState()); ring = new ZkRing(getZk(), ZkPath.append(getRoot(), "ring-1"), null, coordinator); assertEquals(RingState.OPEN, ring.getState()); }
public void testGetRingState() throws Exception { Ring rc = ZkRing.create(getZk(), getRoot(), 1, null, 1); assertEquals(RingState.DOWN, rc.getState()); rc.setState(RingState.UP); assertEquals(RingState.UP, rc.getState()); rc = new ZkRing(getZk(), getRoot() + "/ring-1", null); assertEquals(RingState.UP, rc.getState()); }
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); }