use of org.mule.runtime.core.internal.source.scheduler.DefaultSchedulerMessageSource in project mule by mulesoft.
the class DefaultSchedulerMessageSourceTestCase method createMessageSource.
private DefaultSchedulerMessageSource createMessageSource() throws Exception {
createAndRegisterFlow(muleContext, APPLE_FLOW, componentLocator);
schedulerMessageSource = new DefaultSchedulerMessageSource(muleContext, scheduler(), false);
schedulerMessageSource.setAnnotations(getAppleFlowComponentLocationAnnotations());
schedulerMessageSource.initialise();
return schedulerMessageSource;
}
use of org.mule.runtime.core.internal.source.scheduler.DefaultSchedulerMessageSource in project mule by mulesoft.
the class DefaultSchedulerMessageSourceTestCase method simplePoll.
@Test
public void simplePoll() throws Exception {
DefaultSchedulerMessageSource schedulerMessageSource = createMessageSource();
SensingNullMessageProcessor flow = getSensingNullMessageProcessor();
schedulerMessageSource.setListener(flow);
schedulerMessageSource.setAnnotations(singletonMap(LOCATION_KEY, TEST_CONNECTOR_LOCATION));
schedulerMessageSource.trigger();
new PollingProber(RECEIVE_TIMEOUT, 100).check(new Probe() {
@Override
public boolean isSatisfied() {
return flow.event != null;
}
@Override
public String describeFailure() {
return "flow event never set by the source flow";
}
});
}
use of org.mule.runtime.core.internal.source.scheduler.DefaultSchedulerMessageSource in project mule by mulesoft.
the class DefaultSchedulerMessageSourceTestCase method disposeScheduler.
@Test
public void disposeScheduler() throws Exception {
SchedulerService schedulerService = muleContext.getSchedulerService();
reset(schedulerService);
AtomicReference<Scheduler> pollScheduler = new AtomicReference<>();
doAnswer(invocation -> {
Scheduler scheduler = (Scheduler) invocation.callRealMethod();
pollScheduler.set(scheduler);
return scheduler;
}).when(schedulerService).cpuLightScheduler();
DefaultSchedulerMessageSource schedulerMessageSource = createMessageSource();
verify(schedulerService).cpuLightScheduler();
schedulerMessageSource.start();
verify(pollScheduler.get()).scheduleAtFixedRate(any(), anyLong(), anyLong(), any());
schedulerMessageSource.stop();
schedulerMessageSource.dispose();
verify(pollScheduler.get()).stop();
}
Aggregations