@Test public void testCustomNotifications() throws Exception { final CountDownLatch latch = new CountDownLatch(2); getNotificationListenerRegistry().registerListener((DummyNotificationListener) notification -> { if (new IntegerAction(EVENT_RECEIVED).equals(notification.getAction())) { customNotificationCount.incrementAndGet(); assertEquals("hello", ((EventObject) notification).getSource()); latch.countDown(); } }); getNotificationDispatcher().dispatch(new DummyNotification("hello", EVENT_RECEIVED)); getNotificationDispatcher().dispatch(new DummyNotification("hello", EVENT_RECEIVED)); // Wait for the notifcation event to be fired as they are queued latch.await(2000, MILLISECONDS); assertEquals(2, customNotificationCount.get()); }
private NotificationListenerRegistry getNotificationListenerRegistry() throws RegistrationException { return getResgistry().lookupObject(NotificationListenerRegistry.class); }
public ServerNotificationsTestCase() { setStartContext(true); }
@Test public void testMismatchingUnregistrations() throws Exception { // this has changed in 2.x. now, unregistering removes all related entries getNotificationListenerRegistry().registerListener(this); DummyListener dummy = new DummyListener(); getNotificationListenerRegistry().registerListener(dummy); getNotificationListenerRegistry().registerListener(dummy); getNotificationListenerRegistry().unregisterListener(dummy); muleContext.stop(); assertTrue(managerStopped.get()); assertEquals(1, managerStoppedEvents.get()); }
@Test public void testUnregistering() throws Exception { getNotificationListenerRegistry().registerListener(this); getNotificationListenerRegistry().unregisterListener(this); muleContext.stop(); // these should still be false because we unregistered ourselves assertFalse(managerStopped.get()); }
@Test public void testMultipleRegistrations() throws Exception { getNotificationListenerRegistry().registerListener(this); getNotificationListenerRegistry().registerListener(this); muleContext.stop(); assertTrue(managerStopped.get()); assertEquals(1, managerStoppedEvents.get()); }
@Test public void testCustomNotifications() throws Exception { final CountDownLatch latch = new CountDownLatch(2); getNotificationListenerRegistry().registerListener((DummyNotificationListener) notification -> { if (new IntegerAction(EVENT_RECEIVED).equals(notification.getAction())) { customNotificationCount.incrementAndGet(); assertEquals("hello", ((EventObject) notification).getSource()); latch.countDown(); } }); getNotificationDispatcher().dispatch(new DummyNotification("hello", EVENT_RECEIVED)); getNotificationDispatcher().dispatch(new DummyNotification("hello", EVENT_RECEIVED)); // Wait for the notifcation event to be fired as they are queued latch.await(2000, MILLISECONDS); assertEquals(2, customNotificationCount.get()); }
private NotificationListenerRegistry getNotificationListenerRegistry() throws RegistrationException { return getResgistry().lookupObject(NotificationListenerRegistry.class); }
public ServerNotificationsTestCase() { setStartContext(true); }
@Test public void testStandardNotifications() throws Exception { getNotificationListenerRegistry().registerListener(this); muleContext.stop(); assertTrue(managerStopped.get()); }
@Test public void testMismatchingUnregistrations() throws Exception { // this has changed in 2.x. now, unregistering removes all related entries getNotificationListenerRegistry().registerListener(this); DummyListener dummy = new DummyListener(); getNotificationListenerRegistry().registerListener(dummy); getNotificationListenerRegistry().registerListener(dummy); getNotificationListenerRegistry().unregisterListener(dummy); muleContext.stop(); assertTrue(managerStopped.get()); assertEquals(1, managerStoppedEvents.get()); }
@Test public void testUnregistering() throws Exception { getNotificationListenerRegistry().registerListener(this); getNotificationListenerRegistry().unregisterListener(this); muleContext.stop(); // these should still be false because we unregistered ourselves assertFalse(managerStopped.get()); }
@Test public void testMultipleRegistrations() throws Exception { getNotificationListenerRegistry().registerListener(this); getNotificationListenerRegistry().registerListener(this); muleContext.stop(); assertTrue(managerStopped.get()); assertEquals(1, managerStoppedEvents.get()); }
@Test public void testStandardNotifications() throws Exception { getNotificationListenerRegistry().registerListener(this); muleContext.stop(); assertTrue(managerStopped.get()); }