Search in sources :

Example 16 with BaseTopologyView

use of org.apache.sling.discovery.commons.providers.BaseTopologyView in project sling by apache.

the class TestMinEventDelayHandler method testNormalDelaying.

//TODO test takes env 50sec
@Category(Slow.class)
@Test
public void testNormalDelaying() throws Exception {
    final DummyListener listener = new DummyListener();
    // first activate
    logger.info("testNormalDelaying: calling handleActivated...");
    mgr.handleActivated();
    // paranoia
    assertNoEvents(listener);
    // then bind
    logger.info("testNormalDelaying: calling bind...");
    mgr.bind(listener);
    // there was no changing or changed yet
    assertNoEvents(listener);
    logger.info("testNormalDelaying: calling handleChanging...");
    mgr.handleChanging();
    assertNoEvents(listener);
    final BaseTopologyView view = new DummyTopologyView().addInstance();
    logger.info("testNormalDelaying: calling handleNewView...");
    mgr.handleNewView(view);
    TestHelper.assertEvents(mgr, listener, EventHelper.newInitEvent(view));
    for (int i = 0; i < 7; i++) {
        logger.info("testNormalDelaying: calling randomEventLoop...");
        TestHelper.randomEventLoop(mgr, sds, 4, 1500, defaultRandom, listener);
        Thread.sleep(1000);
    }
}
Also used : DummyTopologyView(org.apache.sling.discovery.commons.providers.DummyTopologyView) BaseTopologyView(org.apache.sling.discovery.commons.providers.BaseTopologyView) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 17 with BaseTopologyView

use of org.apache.sling.discovery.commons.providers.BaseTopologyView in project sling by apache.

the class TestViewStateManager method testActivateChangingChangedBind.

@Test
public void testActivateChangingChangedBind() throws Exception {
    final DummyListener listener = new DummyListener();
    // first activate
    mgr.handleActivated();
    // paranoia
    TestHelper.assertNoEvents(listener);
    mgr.handleChanging();
    // no listener yet
    TestHelper.assertNoEvents(listener);
    final BaseTopologyView view = new DummyTopologyView().addInstance();
    mgr.handleNewView(view);
    // no listener yet
    TestHelper.assertNoEvents(listener);
    // then bind
    mgr.bind(listener);
    assertEvents(listener, EventHelper.newInitEvent(view));
    randomEventLoop(defaultRandom, listener);
}
Also used : DummyTopologyView(org.apache.sling.discovery.commons.providers.DummyTopologyView) BaseTopologyView(org.apache.sling.discovery.commons.providers.BaseTopologyView) Test(org.junit.Test)

Example 18 with BaseTopologyView

use of org.apache.sling.discovery.commons.providers.BaseTopologyView in project sling by apache.

the class TestViewStateManager method testBindActivateChangingBindChanged.

@Test
public void testBindActivateChangingBindChanged() throws Exception {
    final DummyListener listener1 = new DummyListener();
    final DummyListener listener2 = new DummyListener();
    mgr.bind(listener1);
    TestHelper.assertNoEvents(listener1);
    mgr.handleActivated();
    TestHelper.assertNoEvents(listener1);
    mgr.handleChanging();
    TestHelper.assertNoEvents(listener1);
    mgr.bind(listener2);
    TestHelper.assertNoEvents(listener1);
    TestHelper.assertNoEvents(listener2);
    final BaseTopologyView view = new DummyTopologyView().addInstance();
    mgr.handleNewView(view);
    assertEvents(listener1, EventHelper.newInitEvent(view));
    assertEvents(listener2, EventHelper.newInitEvent(view));
    randomEventLoop(defaultRandom, listener1, listener2);
}
Also used : DummyTopologyView(org.apache.sling.discovery.commons.providers.DummyTopologyView) BaseTopologyView(org.apache.sling.discovery.commons.providers.BaseTopologyView) Test(org.junit.Test)

Example 19 with BaseTopologyView

use of org.apache.sling.discovery.commons.providers.BaseTopologyView in project sling by apache.

the class TestViewStateManager method testBindActivateChangingChanged.

@Test
public void testBindActivateChangingChanged() throws Exception {
    final DummyListener listener = new DummyListener();
    mgr.bind(listener);
    TestHelper.assertNoEvents(listener);
    mgr.handleActivated();
    TestHelper.assertNoEvents(listener);
    mgr.handleChanging();
    TestHelper.assertNoEvents(listener);
    final BaseTopologyView view = new DummyTopologyView().addInstance();
    mgr.handleNewView(view);
    assertEvents(listener, EventHelper.newInitEvent(view));
    randomEventLoop(defaultRandom, listener);
}
Also used : DummyTopologyView(org.apache.sling.discovery.commons.providers.DummyTopologyView) BaseTopologyView(org.apache.sling.discovery.commons.providers.BaseTopologyView) Test(org.junit.Test)

Example 20 with BaseTopologyView

use of org.apache.sling.discovery.commons.providers.BaseTopologyView in project sling by apache.

the class TestViewStateManager method testActivateBindChangingChanged.

@Test
public void testActivateBindChangingChanged() throws Exception {
    final DummyListener listener = new DummyListener();
    // first activate
    mgr.handleActivated();
    // paranoia
    TestHelper.assertNoEvents(listener);
    // then bind
    mgr.bind(listener);
    // there was no changing or changed yet
    TestHelper.assertNoEvents(listener);
    mgr.handleChanging();
    TestHelper.assertNoEvents(listener);
    final BaseTopologyView view = new DummyTopologyView().addInstance();
    mgr.handleNewView(view);
    assertEvents(listener, EventHelper.newInitEvent(view));
    randomEventLoop(defaultRandom, listener);
}
Also used : DummyTopologyView(org.apache.sling.discovery.commons.providers.DummyTopologyView) BaseTopologyView(org.apache.sling.discovery.commons.providers.BaseTopologyView) Test(org.junit.Test)

Aggregations

BaseTopologyView (org.apache.sling.discovery.commons.providers.BaseTopologyView)23 DummyTopologyView (org.apache.sling.discovery.commons.providers.DummyTopologyView)19 Test (org.junit.Test)19 ReentrantLock (java.util.concurrent.locks.ReentrantLock)4 ClusterSyncService (org.apache.sling.discovery.commons.providers.spi.ClusterSyncService)4 ViewStateManagerImpl (org.apache.sling.discovery.commons.providers.base.ViewStateManagerImpl)3 Random (java.util.Random)2 Before (org.junit.Before)2 Category (org.junit.experimental.categories.Category)2 LinkedList (java.util.LinkedList)1 ClusterView (org.apache.sling.discovery.ClusterView)1 DiscoveryService (org.apache.sling.discovery.DiscoveryService)1 InstanceDescription (org.apache.sling.discovery.InstanceDescription)1 TopologyView (org.apache.sling.discovery.TopologyView)1 DefaultClusterView (org.apache.sling.discovery.commons.providers.DefaultClusterView)1 DefaultInstanceDescription (org.apache.sling.discovery.commons.providers.DefaultInstanceDescription)1