Search in sources :

Example 6 with ExchangeSendingEvent

use of org.apache.camel.management.event.ExchangeSendingEvent in project camel by apache.

the class EventNotifierExchangeSentTest method testExchangeWireTap.

public void testExchangeWireTap() throws Exception {
    getMockEndpoint("mock:result").expectedMessageCount(1);
    template.sendBody("direct:tap", "Hello World");
    assertMockEndpointsSatisfied();
    // give it time to complete
    Thread.sleep(200);
    assertEquals(6, events.size());
    // we should find log:foo which we tapped
    // which runs async so they can be in random order
    boolean found = false;
    boolean found2 = false;
    for (EventObject event : events) {
        if (event instanceof ExchangeSendingEvent) {
            ExchangeSendingEvent sending = (ExchangeSendingEvent) event;
            String uri = sending.getEndpoint().getEndpointUri();
            if ("log://foo".equals(uri)) {
                found = true;
            }
        } else if (event instanceof ExchangeSentEvent) {
            ExchangeSentEvent sent = (ExchangeSentEvent) event;
            String uri = sent.getEndpoint().getEndpointUri();
            if ("log://foo".equals(uri)) {
                found2 = true;
            }
        }
    }
    assertTrue("We should find log:foo being wire tapped", found);
    assertTrue("We should find log:foo being wire tapped", found2);
}
Also used : ExchangeSentEvent(org.apache.camel.management.event.ExchangeSentEvent) ExchangeSendingEvent(org.apache.camel.management.event.ExchangeSendingEvent) EventObject(java.util.EventObject)

Aggregations

ExchangeSendingEvent (org.apache.camel.management.event.ExchangeSendingEvent)6 ExchangeSentEvent (org.apache.camel.management.event.ExchangeSentEvent)4 EventObject (java.util.EventObject)3 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Endpoint (org.apache.camel.Endpoint)1 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)1 ExchangeCreatedEvent (org.apache.camel.management.event.ExchangeCreatedEvent)1 RouteAddedEvent (org.apache.camel.management.event.RouteAddedEvent)1 RouteRemovedEvent (org.apache.camel.management.event.RouteRemovedEvent)1 EventNotifierSupport (org.apache.camel.support.EventNotifierSupport)1