Search in sources :

Example 6 with NotificationListener

use of org.mule.runtime.api.notification.NotificationListener 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

NotificationListener (org.mule.runtime.api.notification.NotificationListener)6 Test (org.junit.Test)4 CustomNotificationListener (org.mule.runtime.api.notification.CustomNotificationListener)4 Notification (org.mule.runtime.api.notification.Notification)4 CustomNotification (org.mule.runtime.api.notification.CustomNotification)3 MuleContext (org.mule.runtime.core.api.MuleContext)2 ListenerSubscriptionPair (org.mule.runtime.core.api.context.notification.ListenerSubscriptionPair)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Callable (java.util.concurrent.Callable)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 AsyncMessageNotificationListener (org.mule.runtime.api.notification.AsyncMessageNotificationListener)1 ClusterNodeNotificationListener (org.mule.runtime.api.notification.ClusterNodeNotificationListener)1 ConnectionNotificationListener (org.mule.runtime.api.notification.ConnectionNotificationListener)1 ExceptionNotificationListener (org.mule.runtime.api.notification.ExceptionNotificationListener)1 ManagementNotificationListener (org.mule.runtime.api.notification.ManagementNotificationListener)1 PipelineMessageNotificationListener (org.mule.runtime.api.notification.PipelineMessageNotificationListener)1 RoutingNotificationListener (org.mule.runtime.api.notification.RoutingNotificationListener)1 SecurityNotificationListener (org.mule.runtime.api.notification.SecurityNotificationListener)1