use of org.mule.runtime.api.notification.AbstractServerNotification.TYPE_ERROR in project mule by mulesoft.
the class DefaultExceptionStrategyTestCase method testExceptionNotifications.
// MULE-1627
@Test
public void testExceptionNotifications() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
final AtomicInteger notificationCount = new AtomicInteger(0);
((MuleContextWithRegistries) muleContext).getRegistry().lookupObject(NotificationListenerRegistry.class).registerListener((ExceptionNotificationListener) notification -> {
if (new IntegerAction(EXCEPTION_ACTION).equals(notification.getAction())) {
assertEquals("exception", notification.getActionName());
assertEquals("Wrong info type", TYPE_ERROR, notification.getType());
notificationCount.incrementAndGet();
latch.countDown();
}
});
// throwing exception
InstrumentedExceptionStrategy strategy = new InstrumentedExceptionStrategy(muleContext);
strategy.setAnnotations(singletonMap(LOCATION_KEY, TEST_CONNECTOR_LOCATION));
strategy.setMuleContext(muleContext);
strategy.setNotificationFirer(((MuleContextWithRegistries) muleContext).getRegistry().lookupObject(NotificationDispatcher.class));
strategy.handleException(new IllegalArgumentException("boom"));
// Wait for the notifcation event to be fired as they are queue
latch.await(2000, MILLISECONDS);
assertEquals(1, notificationCount.get());
}
Aggregations