use of org.apache.sling.discovery.impl.topology.TopologyViewImpl in project sling by apache.
the class TopologyHandlerTest method testHandleTopologyEvent.
@Test
public void testHandleTopologyEvent() {
TopologyView oldView = new TopologyViewImpl();
TopologyView newView = newViewWithInstanceDescription(true);
TopologyEvent event = new TopologyEvent(TopologyEvent.Type.PROPERTIES_CHANGED, oldView, newView);
underTest.handleTopologyEvent(event);
assertTrue(QuartzJobExecutor.IS_LEADER.get());
assertFalse(QuartzJobExecutor.DISCOVERY_INFO_AVAILABLE.get());
event = new TopologyEvent(TopologyEvent.Type.TOPOLOGY_INIT, null, newView);
underTest.handleTopologyEvent(event);
assertTrue(QuartzJobExecutor.IS_LEADER.get());
assertTrue(QuartzJobExecutor.DISCOVERY_INFO_AVAILABLE.get());
event = new TopologyEvent(TopologyEvent.Type.TOPOLOGY_CHANGED, oldView, newView);
underTest.handleTopologyEvent(event);
assertTrue(QuartzJobExecutor.IS_LEADER.get());
assertTrue(QuartzJobExecutor.DISCOVERY_INFO_AVAILABLE.get());
newView = newViewWithInstanceDescription(false);
event = new TopologyEvent(TopologyEvent.Type.TOPOLOGY_CHANGED, oldView, newView);
underTest.handleTopologyEvent(event);
assertFalse(QuartzJobExecutor.IS_LEADER.get());
assertTrue(QuartzJobExecutor.DISCOVERY_INFO_AVAILABLE.get());
event = new TopologyEvent(TopologyEvent.Type.TOPOLOGY_CHANGING, oldView, null);
underTest.handleTopologyEvent(event);
assertFalse(QuartzJobExecutor.IS_LEADER.get());
assertFalse(QuartzJobExecutor.DISCOVERY_INFO_AVAILABLE.get());
}
Aggregations