use of org.apache.sling.discovery.commons.providers.DummyTopologyView in project sling by apache.
the class TestViewStateManager method testBindActivateChangedDeactivateChangingActivateChanged.
@Test
public void testBindActivateChangedDeactivateChangingActivateChanged() throws Exception {
final DummyListener listener = new DummyListener();
mgr.bind(listener);
TestHelper.assertNoEvents(listener);
mgr.handleActivated();
TestHelper.assertNoEvents(listener);
final BaseTopologyView view1 = new DummyTopologyView().addInstance();
mgr.handleNewView(view1);
assertEvents(listener, EventHelper.newInitEvent(view1));
mgr.handleDeactivated();
TestHelper.assertNoEvents(listener);
mgr.handleChanging();
TestHelper.assertNoEvents(listener);
// need to bind again after deactivate
mgr.bind(listener);
mgr.handleActivated();
TestHelper.assertNoEvents(listener);
final BaseTopologyView view2 = new DummyTopologyView().addInstance();
mgr.handleNewView(view2);
assertEvents(listener, EventHelper.newInitEvent(view2));
}
use of org.apache.sling.discovery.commons.providers.DummyTopologyView in project sling by apache.
the class TestMinEventDelayHandler method testFailedDelaying.
//TODO test takes env 45sec
@Category(Slow.class)
@Test
public void testFailedDelaying() throws Exception {
scheduler.failMode();
final DummyListener listener = new DummyListener();
// first activate
mgr.handleActivated();
// paranoia
assertNoEvents(listener);
// then bind
mgr.bind(listener);
// there was no changing or changed yet
assertNoEvents(listener);
mgr.handleChanging();
assertNoEvents(listener);
final BaseTopologyView view = new DummyTopologyView().addInstance();
mgr.handleNewView(view);
TestHelper.assertEvents(mgr, listener, EventHelper.newInitEvent(view));
for (int i = 0; i < 7; i++) {
TestHelper.randomEventLoop(mgr, sds, 100, -1, defaultRandom, listener);
Thread.sleep(1000);
}
}
use of org.apache.sling.discovery.commons.providers.DummyTopologyView 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);
}
}
use of org.apache.sling.discovery.commons.providers.DummyTopologyView 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);
}
use of org.apache.sling.discovery.commons.providers.DummyTopologyView 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);
}
Aggregations