Search in sources :

Example 21 with BaseTopologyView

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

the class TestViewStateManager method testBindChangingActivateChanged.

@Test
public void testBindChangingActivateChanged() throws Exception {
    final DummyListener listener = new DummyListener();
    mgr.bind(listener);
    TestHelper.assertNoEvents(listener);
    mgr.handleChanging();
    TestHelper.assertNoEvents(listener);
    mgr.handleActivated();
    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 22 with BaseTopologyView

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

the class TestViewStateManager method testBindActivateChangedChanged.

@Test
public void testBindActivateChangedChanged() throws Exception {
    final DummyListener listener = new DummyListener();
    mgr.handleActivated();
    TestHelper.assertNoEvents(listener);
    mgr.bind(listener);
    TestHelper.assertNoEvents(listener);
    mgr.handleChanging();
    TestHelper.assertNoEvents(listener);
    final BaseTopologyView view1 = new DummyTopologyView().addInstance();
    mgr.handleNewView(view1);
    assertEvents(listener, EventHelper.newInitEvent(view1));
    final BaseTopologyView view2 = new DummyTopologyView().addInstance();
    mgr.handleNewView(view2);
    assertEvents(listener, EventHelper.newChangingEvent(view1), EventHelper.newChangedEvent(view1, view2));
    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 23 with BaseTopologyView

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

the class TestViewStateManager method testBindChangedChangingActivate.

@Test
public void testBindChangedChangingActivate() throws Exception {
    final DummyListener listener = new DummyListener();
    mgr.bind(listener);
    TestHelper.assertNoEvents(listener);
    final BaseTopologyView view = new DummyTopologyView().addInstance();
    mgr.handleNewView(view);
    TestHelper.assertNoEvents(listener);
    mgr.handleChanging();
    TestHelper.assertNoEvents(listener);
    mgr.handleActivated();
    TestHelper.assertNoEvents(listener);
    final BaseTopologyView view2 = new DummyTopologyView().addInstance();
    mgr.handleNewView(view2);
    assertEvents(listener, EventHelper.newInitEvent(view2));
    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