Search in sources :

Example 11 with Scheduler

use of org.mule.runtime.api.scheduler.Scheduler 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);
}
Also used : MuleContext(org.mule.runtime.core.api.MuleContext) SchedulerService(org.mule.runtime.api.scheduler.SchedulerService) Scheduler(org.mule.runtime.api.scheduler.Scheduler) Callable(java.util.concurrent.Callable) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) Notification(org.mule.runtime.api.notification.Notification) CustomNotification(org.mule.runtime.api.notification.CustomNotification) CustomNotificationListener(org.mule.runtime.api.notification.CustomNotificationListener) NotificationListener(org.mule.runtime.api.notification.NotificationListener) Test(org.junit.Test)

Aggregations

Scheduler (org.mule.runtime.api.scheduler.Scheduler)11 Test (org.junit.Test)6 Description (io.qameta.allure.Description)4 Callable (java.util.concurrent.Callable)3 InitialisationException (org.mule.runtime.api.lifecycle.InitialisationException)2 SchedulerService (org.mule.runtime.api.scheduler.SchedulerService)2 PartitionableExpirableObjectStore (org.mule.runtime.api.store.PartitionableExpirableObjectStore)2 ProactorStreamProcessingStrategy (org.mule.runtime.core.internal.processor.strategy.ProactorStreamProcessingStrategyFactory.ProactorStreamProcessingStrategy)2 Thread.currentThread (java.lang.Thread.currentThread)1 Thread.sleep (java.lang.Thread.sleep)1 Duration (java.time.Duration)1 ZERO (java.time.Duration.ZERO)1 Duration.ofMillis (java.time.Duration.ofMillis)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 TimeUnit (java.util.concurrent.TimeUnit)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Lock (java.util.concurrent.locks.Lock)1 Consumer (java.util.function.Consumer)1 Function (java.util.function.Function)1