use of org.mule.runtime.api.scheduler.SchedulerService in project mule by mulesoft.
the class ExtensionMessageSourceTestCase method failedToCreateFlowTrigger.
@Test
public void failedToCreateFlowTrigger() throws Exception {
Exception e = new RuntimeException();
SchedulerService schedulerService = muleContext.getSchedulerService();
doThrow(e).when(schedulerService).cpuLightScheduler();
messageSource.initialise();
final Throwable throwable = catchThrowable(messageSource::start);
assertThat(throwable, is(instanceOf(LifecycleException.class)));
assertThat(throwable.getCause(), is(sameInstance(e)));
}
use of org.mule.runtime.api.scheduler.SchedulerService in project mule by mulesoft.
the class ExtensionMessageSourceTestCase method failedToCreateRetryScheduler.
@Test
public void failedToCreateRetryScheduler() throws Exception {
messageSource.initialise();
Exception e = new RuntimeException();
SchedulerService schedulerService = muleContext.getSchedulerService();
doThrow(e).when(schedulerService).cpuLightScheduler();
final Throwable throwable = catchThrowable(messageSource::start);
assertThat(throwable.getCause(), is(sameInstance(e)));
}
use of org.mule.runtime.api.scheduler.SchedulerService in project mule by mulesoft.
the class ServerNotificationsTestCase method testAsyncNotificationRejectedExecution.
@Test
public void testAsyncNotificationRejectedExecution() {
MuleContext muleContext = mock(MuleContext.class);
SchedulerService schedulerService = mock(SchedulerService.class);
Scheduler scheduler = mock(Scheduler.class);
when(muleContext.getSchedulerService()).thenReturn(schedulerService);
when(schedulerService.cpuLightScheduler()).thenReturn(scheduler);
when(scheduler.submit(any(Callable.class))).thenThrow(new RejectedExecutionException());
Notification notification = mock(CustomNotification.class);
when(notification.isSynchronous()).thenReturn(false);
NotificationListener notificationListener = mock(CustomNotificationListener.class);
ServerNotificationManager manager = new ServerNotificationManager();
manager.setMuleContext(muleContext);
manager.addInterfaceToType(CustomNotificationListener.class, CustomNotification.class);
manager.addListener(notificationListener);
manager.fireNotification(notification);
verify(notificationListener, never()).onNotification(notification);
}
Aggregations