Examples of AssertingTopologyEventListener


Examples of org.apache.sling.discovery.impl.cluster.helpers.AssertingTopologyEventListener

        assertEquals(2, instance1.getClusterViewService().getClusterView()
                .getInstances().size());
        assertEquals(2, instance2.getClusterViewService().getClusterView()
                .getInstances().size());

        AssertingTopologyEventListener assertingTopologyEventListener = new AssertingTopologyEventListener();
        assertingTopologyEventListener.addExpected(Type.TOPOLOGY_INIT);
        assertEquals(1, assertingTopologyEventListener.getRemainingExpectedCount());
        instance1.bindTopologyEventListener(assertingTopologyEventListener);
        assertEquals(0, assertingTopologyEventListener.getRemainingExpectedCount());

        // startup instance 3
        AcceptsMultiple acceptsMultiple = new AcceptsMultiple(
                Type.TOPOLOGY_CHANGING, Type.TOPOLOGY_CHANGED);
        assertingTopologyEventListener.addExpected(acceptsMultiple);
        assertingTopologyEventListener.addExpected(acceptsMultiple);
        instance3 = Instance.newClusterInstance("thirdInstance", instance1,
                false);
        instance1.runHeartbeatOnce();
        instance2.runHeartbeatOnce();
        instance3.runHeartbeatOnce();
View Full Code Here

Examples of org.apache.sling.discovery.impl.cluster.helpers.AssertingTopologyEventListener

        Thread.sleep(2000);
        instance.runHeartbeatOnce();
        logger.info("testTopologyEventListeners: 2nd sleep 2s");
        Thread.sleep(2000);

        AssertingTopologyEventListener assertingTopologyEventListener = new AssertingTopologyEventListener();
        assertingTopologyEventListener.addExpected(Type.TOPOLOGY_INIT);
        instance.bindTopologyEventListener(assertingTopologyEventListener);
        assertEquals(0, assertingTopologyEventListener.getRemainingExpectedCount());

        final String propertyName = UUID.randomUUID().toString();
        propertyValue = UUID.randomUUID().toString();
        PropertyProviderImpl pp = new PropertyProviderImpl();
        pp.setProperty(propertyName, propertyValue);

        assertingTopologyEventListener.addExpected(Type.PROPERTIES_CHANGED);

        assertEquals(1, assertingTopologyEventListener.getRemainingExpectedCount());
        assertEquals(0, pp.getGetCnt());
        instance.bindPropertyProvider(pp, propertyName);
        logger.info("testTopologyEventListeners: 3rd sleep 1.5s");
        Thread.sleep(1500);
        assertEquals(0, assertingTopologyEventListener.getRemainingExpectedCount());
        // we can only assume that the getProperty was called at least once - it
        // could be called multiple times though..
        assertTrue(pp.getGetCnt() > 0);

        assertingTopologyEventListener.addExpected(Type.PROPERTIES_CHANGED);

        assertEquals(1, assertingTopologyEventListener.getRemainingExpectedCount());
        pp.setGetCnt(0);
        propertyValue = UUID.randomUUID().toString();
        pp.setProperty(propertyName, propertyValue);
        assertEquals(0, pp.getGetCnt());
        instance.runHeartbeatOnce();
        logger.info("testTopologyEventListeners: 4th sleep 2s");
        Thread.sleep(2000);
        assertEquals(0, assertingTopologyEventListener.getRemainingExpectedCount());
        assertEquals(2, pp.getGetCnt());

        // a heartbeat repeat should not result in another call though
        instance.runHeartbeatOnce();
        logger.info("testTopologyEventListeners: 5th sleep 2s");
        Thread.sleep(2000);
        assertEquals(0, assertingTopologyEventListener.getRemainingExpectedCount());
        assertEquals(3, pp.getGetCnt());
        logger.info("testTopologyEventListeners: done");
    }
View Full Code Here

Examples of org.apache.sling.discovery.impl.cluster.helpers.AssertingTopologyEventListener

        logger.info("testBootstrap: start");
        ClusterView initialClusterView = instance.getClusterViewService()
                .getClusterView();
        assertNotNull(initialClusterView);

        AssertingTopologyEventListener ada = new AssertingTopologyEventListener();
        ada.addExpected(Type.TOPOLOGY_INIT);
        instance.bindTopologyEventListener(ada);
        assertEquals(1, ada.getEvents().size());
        TopologyEvent initEvent = ada.getEvents().remove(0);
        assertNotNull(initEvent);

        assertEquals(initialClusterView.getId(), initEvent.getNewView()
                .getClusterViews().iterator().next().getId());
        assertEquals(initialClusterView.getInstances().get(0).getSlingId(),
                initEvent.getNewView().getLocalInstance().getSlingId());

        // hard assumption that the class we get is an
        // IsolatedInstanceDescription
        // this is because we dont have any established clusterview yet - hence
        // still entirely isolated
        assertEquals(IsolatedInstanceDescription.class, initialClusterView
                .getInstances().get(0).getClass());
        assertEquals(IsolatedInstanceDescription.class, instance
                .getClusterViewService().getClusterView().getInstances().get(0)
                .getClass());
        instance.runHeartbeatOnce();
        Thread.sleep(1000);
        instance.runHeartbeatOnce();
        Thread.sleep(1000);
        assertEquals(0, ada.getEvents().size());

        // after the view was established though, we expect it to be a normal
        // ResourceInstanceDescription
        assertEquals(EstablishedInstanceDescription.class, instance
                .getClusterViewService().getClusterView().getInstances().get(0)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.