@Test public void testSyncNotificationException() { ServerNotificationManager manager = new ServerNotificationManager(); manager.setMuleContext(muleContext); manager.addInterfaceToType(CustomNotificationListener.class, CustomNotification.class); Notification notification = mock(CustomNotification.class); when(notification.isSynchronous()).thenReturn(true); NotificationListener notificationListener = mock(CustomNotificationListener.class); doThrow(new IllegalArgumentException()).when(notificationListener).onNotification(any(CustomNotification.class)); manager.addListener(notificationListener); manager.fireNotification(notification); verify(notificationListener, times(1)).onNotification(notification); }
@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); }
@Test public void testSyncNotificationError() { ServerNotificationManager manager = new ServerNotificationManager(); manager.setMuleContext(muleContext); manager.addInterfaceToType(CustomNotificationListener.class, CustomNotification.class); Notification notification = mock(CustomNotification.class); when(notification.isSynchronous()).thenReturn(true); NotificationListener notificationListener = mock(CustomNotificationListener.class); doThrow(new LinkageError()).when(notificationListener).onNotification(any(CustomNotification.class)); manager.addListener(notificationListener); manager.fireNotification(notification); verify(notificationListener, times(1)).onNotification(notification); }
@Test public void testSyncNotificationException() { ServerNotificationManager manager = new ServerNotificationManager(); manager.setMuleContext(muleContext); manager.addInterfaceToType(CustomNotificationListener.class, CustomNotification.class); Notification notification = mock(CustomNotification.class); when(notification.isSynchronous()).thenReturn(true); NotificationListener notificationListener = mock(CustomNotificationListener.class); doThrow(new IllegalArgumentException()).when(notificationListener).onNotification(any(CustomNotification.class)); manager.addListener(notificationListener); manager.fireNotification(notification); verify(notificationListener, times(1)).onNotification(notification); }
@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); }
@Test public void testSyncNotificationError() { ServerNotificationManager manager = new ServerNotificationManager(); manager.setMuleContext(muleContext); manager.addInterfaceToType(CustomNotificationListener.class, CustomNotification.class); Notification notification = mock(CustomNotification.class); when(notification.isSynchronous()).thenReturn(true); NotificationListener notificationListener = mock(CustomNotificationListener.class); doThrow(new LinkageError()).when(notificationListener).onNotification(any(CustomNotification.class)); manager.addListener(notificationListener); manager.fireNotification(notification); verify(notificationListener, times(1)).onNotification(notification); }