EventBus { public void publish(final JVoiceXMLEvent event) { final String type = event.getEventType(); synchronized (subscriptions) { for (EventSubscription subscription : subscriptions) { if (subscription.matches(type)) { subscription.publish(event); } } } } EventBus(); void subscribe(final String type, final EventSubscriber subscriber); boolean unsubscribe(final String type,
            final EventSubscriber subscriber); void publish(final JVoiceXMLEvent event);  }
@Test public void testPublish() { final MockEventSubscriber subscriber = new MockEventSubscriber(); final EventBus bus = new EventBus(); final String type = BadFetchError.EVENT_TYPE; bus.subscribe(type, subscriber); final JVoiceXMLEvent event = new BadFetchError("test message"); bus.publish(event); Assert.assertEquals(event, subscriber.getEvent()); }