use of org.apache.sling.commons.scheduler.Scheduler in project sling by apache.
the class VirtualInstanceBuilder method getSingletonScheduler.
public static Scheduler getSingletonScheduler() throws Exception {
if (singletonScheduler != null) {
return singletonScheduler;
}
final Scheduler newscheduler = new QuartzScheduler();
final ThreadPoolManager tpm = new DefaultThreadPoolManager(null, null);
try {
PrivateAccessor.invoke(newscheduler, "bindThreadPoolManager", new Class[] { ThreadPoolManager.class }, new Object[] { tpm });
} catch (Throwable e1) {
org.junit.Assert.fail(e1.toString());
}
OSGiMock.activate(newscheduler);
singletonScheduler = newscheduler;
return singletonScheduler;
}
use of org.apache.sling.commons.scheduler.Scheduler in project sling by apache.
the class TestInitDelayingTopologyEventListener method testDisposing.
@Test
public void testDisposing() throws Exception {
final TestListener delegate = new TestListener();
final Scheduler scheduler = createScheduler();
InitDelayingTopologyEventListener listener = new InitDelayingTopologyEventListener(1, delegate, scheduler, logger);
listener.handleTopologyEvent(createEvent(Type.TOPOLOGY_INIT));
delegate.waitForEventCnt(1, 5000);
// test framework testing :)
delegate.assureEventCnt(1, 500);
listener = new InitDelayingTopologyEventListener(1, delegate, scheduler, logger);
listener.handleTopologyEvent(createEvent(Type.TOPOLOGY_INIT));
listener.dispose();
delegate.assureEventCnt(1, 1000);
delegate.assureEventCnt(1, 500);
}
use of org.apache.sling.commons.scheduler.Scheduler in project sling by apache.
the class TestInitDelayingTopologyEventListener method testChanging1.
@Test
public void testChanging1() throws Exception {
final TestListener delegate = new TestListener();
final Scheduler scheduler = createScheduler();
InitDelayingTopologyEventListener listener = new InitDelayingTopologyEventListener(1, delegate, scheduler, logger);
listener.handleTopologyEvent(createEvent(Type.TOPOLOGY_INIT));
listener.handleTopologyEvent(createEvent(Type.TOPOLOGY_CHANGING));
listener.handleTopologyEvent(createEvent(Type.TOPOLOGY_CHANGED));
listener.handleTopologyEvent(createEvent(Type.TOPOLOGY_CHANGING));
listener.handleTopologyEvent(createEvent(Type.TOPOLOGY_CHANGED));
listener.handleTopologyEvent(createEvent(Type.TOPOLOGY_CHANGING));
delegate.assureEventCnt(0, 1000);
listener.handleTopologyEvent(createEvent(Type.TOPOLOGY_CHANGED));
delegate.waitForEventCnt(1, 5000);
assertEquals(delegate.getEvents().get(0).getType(), Type.TOPOLOGY_INIT);
doTestAdditionalEventsAfterInit(delegate, listener);
}
use of org.apache.sling.commons.scheduler.Scheduler in project sling by apache.
the class TestInitDelayingTopologyEventListener method testChanged.
@Test
public void testChanged() throws Exception {
final TestListener delegate = new TestListener();
final Scheduler scheduler = createScheduler();
InitDelayingTopologyEventListener listener = new InitDelayingTopologyEventListener(1, delegate, scheduler, logger);
listener.handleTopologyEvent(createEvent(Type.TOPOLOGY_INIT));
listener.handleTopologyEvent(createEvent(Type.TOPOLOGY_CHANGING));
listener.handleTopologyEvent(createEvent(Type.TOPOLOGY_CHANGED));
delegate.waitForEventCnt(1, 5000);
assertEquals(delegate.getEvents().get(0).getType(), Type.TOPOLOGY_INIT);
doTestAdditionalEventsAfterInit(delegate, listener);
}
Aggregations