DecanterTraceEventHandler implements TraceEventHandler { public void setEventAdmin(EventAdmin eventAdmin) { this.eventAdmin = eventAdmin; }  @Override void traceExchange(ProcessorDefinition<?> node, Processor target, TraceInterceptor traceInterceptor, Exchange exchange); @Override Object traceExchangeIn(ProcessorDefinition<?> node, Processor target, TraceInterceptor traceInterceptor, Exchange exchange); @Override void traceExchangeOut(ProcessorDefinition<?> node, Processor target, TraceInterceptor traceInterceptor, Exchange exchange, Object traceState); EventAdmin getEventAdmin(); void setExtender(DecanterCamelEventExtender extender); void setEventAdmin(EventAdmin eventAdmin); void setIncludeBody(boolean includeBody); void setIncludeHeaders(boolean includeHeaders); void setIncludeProperties(boolean includeProperties);  }
@Test public void testTracer() throws Exception { JsonMarshaller marshaller = new JsonMarshaller(); MockEventAdmin eventAdmin = new MockEventAdmin(); DecanterTraceEventHandler handler = new DecanterTraceEventHandler(); handler.setEventAdmin(eventAdmin); DefaultCamelContext camelContext = createCamelContext(handler); ProducerTemplate template = camelContext.createProducerTemplate(); template.sendBodyAndHeader("direct:start", "TEST", "header", "test"); for (Event event : eventAdmin.getPostEvents()) { String jsonString = marshaller.marshal(event); JsonReader jsonReader = Json.createReader(new StringReader(jsonString)); JsonObject rootObject = jsonReader.readObject(); System.out.println(jsonString); Assert.assertEquals("InOnly", rootObject.getString("exchangePattern")); Assert.assertEquals("camelTracer", rootObject.getString("type")); Assert.assertEquals("test-route", rootObject.getString("routeId")); Assert.assertEquals("test-context", rootObject.getString("camelContextName")); JsonObject headersObject = rootObject.getJsonObject("inHeaders"); Assert.assertEquals("test", headersObject.getString("header")); Assert.assertEquals("direct: Assert.assertEquals("TEST", rootObject.getString("inBody")); JsonObject propertiesObject = rootObject.getJsonObject("properties"); Assert.assertEquals("log: Assert.assertEquals("String", rootObject.getString("inBodyType")); Assert.assertEquals("decanter/collect/camel/tracer", rootObject.getString("event_topics")); System.out.println(marshaller.marshal(event)); } }