DecanterEventNotifier extends EventNotifierSupport { public void setEventAdmin(EventAdmin eventAdmin) { this.eventAdmin = eventAdmin; }  EventAdmin getEventAdmin(); void setEventAdmin(EventAdmin eventAdmin); void setCamelContextMatcher(String camelContextMatcher); void setRouteMatcher(String routeMatcher); void setExtender(DecanterCamelEventExtender extender); void setIncludeBody(boolean includeBody); void setIncludeHeaders(boolean includeHeaders); void setIncludeProperties(boolean includeProperties); @Override boolean isEnabled(EventObject eventObject); void notify(EventObject event);  }
@Test public void testEventNotifier() throws Exception { MockEventAdmin eventAdmin = new MockEventAdmin(); DecanterEventNotifier notifier = new DecanterEventNotifier(); notifier.setEventAdmin(eventAdmin); DefaultCamelContext camelContext = createCamelContext(notifier); ProducerTemplate producerTemplate = camelContext.createProducerTemplate(); producerTemplate.sendBodyAndHeader("direct:start", "TEST", "foo", "bar"); Assert.assertEquals(10, eventAdmin.getPostEvents().size()); Event camelContextStartingEvent = eventAdmin.getPostEvents().get(0); Assert.assertEquals("test-context", camelContextStartingEvent.getProperty("camelContextName")); Assert.assertEquals(CamelContextStartingEvent.class.getName(), camelContextStartingEvent.getProperty("eventType")); Assert.assertEquals("camelEvent", camelContextStartingEvent.getProperty("type")); Event routeAddedEvent = eventAdmin.getPostEvents().get(1); Assert.assertEquals("test-context", routeAddedEvent.getProperty("camelContextName")); Assert.assertEquals("test-route", routeAddedEvent.getProperty("routeId")); Assert.assertEquals(RouteAddedEvent.class.getName(), routeAddedEvent.getProperty("eventType")); Assert.assertEquals("camelEvent", routeAddedEvent.getProperty("type")); Event routeStartedEvent = eventAdmin.getPostEvents().get(2); Assert.assertEquals("test-context", routeStartedEvent.getProperty("camelContextName")); Assert.assertEquals("test-route", routeStartedEvent.getProperty("routeId")); Assert.assertEquals(RouteStartedEvent.class.getName(), routeStartedEvent.getProperty("eventType")); Assert.assertEquals("camelEvent", routeStartedEvent.getProperty("type")); Event camelContextStartedEvent = eventAdmin.getPostEvents().get(3); Assert.assertEquals("test-context", camelContextStartedEvent.getProperty("camelContextName")); Assert.assertEquals(CamelContextStartedEvent.class.getName(), camelContextStartedEvent.getProperty("eventType")); Assert.assertEquals("camelEvent", camelContextStartedEvent.getProperty("type")); Event exchangeSendingEvent = eventAdmin.getPostEvents().get(4); Assert.assertEquals("test-context", exchangeSendingEvent.getProperty("camelContextName")); Assert.assertEquals(ExchangeSendingEvent.class.getName(), exchangeSendingEvent.getProperty("eventType")); Assert.assertEquals("camelEvent", exchangeSendingEvent.getProperty("type")); Assert.assertEquals("InOnly", exchangeSendingEvent.getProperty("exchangePattern")); Assert.assertEquals("direct: Assert.assertEquals("TEST", exchangeSendingEvent.getProperty("inBody")); Event exchangeCreatedEvent = eventAdmin.getPostEvents().get(5); Assert.assertEquals("test-context", exchangeCreatedEvent.getProperty("camelContextName")); Assert.assertEquals(ExchangeCreatedEvent.class.getName(), exchangeCreatedEvent.getProperty("eventType")); Assert.assertEquals("camelEvent", exchangeCreatedEvent.getProperty("type")); Assert.assertEquals("InOnly", exchangeCreatedEvent.getProperty("exchangePattern")); Assert.assertEquals("TEST", exchangeCreatedEvent.getProperty("inBody")); }
@Test public void testIgnoredEvents() throws Exception { MockEventAdmin eventAdmin = new MockEventAdmin(); DecanterEventNotifier notifier = new DecanterEventNotifier(); notifier.setEventAdmin(eventAdmin); notifier.setIgnoreCamelContextEvents(true); DefaultCamelContext camelContext = createCamelContext(notifier); ProducerTemplate producerTemplate = camelContext.createProducerTemplate(); producerTemplate.sendBodyAndHeader("direct:start", "TEST", "foo", "bar"); Assert.assertEquals(8, eventAdmin.getPostEvents().size()); }