Search in sources :

Example 1 with TopologyViewImpl

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());
}
Also used : TopologyViewImpl(org.apache.sling.discovery.impl.topology.TopologyViewImpl) TopologyEvent(org.apache.sling.discovery.TopologyEvent) TopologyView(org.apache.sling.discovery.TopologyView) Test(org.junit.Test)

Aggregations

TopologyEvent (org.apache.sling.discovery.TopologyEvent)1 TopologyView (org.apache.sling.discovery.TopologyView)1 TopologyViewImpl (org.apache.sling.discovery.impl.topology.TopologyViewImpl)1 Test (org.junit.Test)1