use of java.util.EventObject 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);
}
use of java.util.EventObject in project camel by apache.
the class DebugExceptionEventBreakpointTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
breakpoint = new BreakpointSupport() {
public void onEvent(Exchange exchange, EventObject event, ProcessorDefinition<?> definition) {
AbstractExchangeEvent aee = (AbstractExchangeEvent) event;
Exception e = aee.getExchange().getException();
logs.add("Breakpoint at " + definition + " caused by: " + e.getClass().getSimpleName() + "[" + e.getMessage() + "]");
}
};
exceptionCondition = new ConditionSupport() {
public boolean matchEvent(Exchange exchange, EventObject event) {
return event instanceof ExchangeFailedEvent;
}
};
}
use of java.util.EventObject in project camel by apache.
the class EventHelper method notifyCamelContextStartupFailed.
public static void notifyCamelContextStartupFailed(CamelContext context, Throwable cause) {
ManagementStrategy management = context.getManagementStrategy();
if (management == null) {
return;
}
List<EventNotifier> notifiers = management.getEventNotifiers();
if (notifiers == null || notifiers.isEmpty()) {
return;
}
for (EventNotifier notifier : notifiers) {
if (notifier.isIgnoreCamelContextEvents()) {
continue;
}
EventFactory factory = management.getEventFactory();
if (factory == null) {
return;
}
EventObject event = factory.createCamelContextStartupFailureEvent(context, cause);
if (event == null) {
return;
}
doNotifyEvent(notifier, event);
}
}
use of java.util.EventObject in project camel by apache.
the class EventHelper method notifyCamelContextStarted.
public static void notifyCamelContextStarted(CamelContext context) {
ManagementStrategy management = context.getManagementStrategy();
if (management == null) {
return;
}
List<EventNotifier> notifiers = management.getEventNotifiers();
if (notifiers == null || notifiers.isEmpty()) {
return;
}
for (EventNotifier notifier : notifiers) {
if (notifier.isIgnoreCamelContextEvents()) {
continue;
}
EventFactory factory = management.getEventFactory();
if (factory == null) {
return;
}
EventObject event = factory.createCamelContextStartedEvent(context);
if (event == null) {
return;
}
doNotifyEvent(notifier, event);
}
}
use of java.util.EventObject in project camel by apache.
the class EventHelper method notifyCamelContextResuming.
public static void notifyCamelContextResuming(CamelContext context) {
ManagementStrategy management = context.getManagementStrategy();
if (management == null) {
return;
}
List<EventNotifier> notifiers = management.getEventNotifiers();
if (notifiers == null || notifiers.isEmpty()) {
return;
}
for (EventNotifier notifier : notifiers) {
if (notifier.isIgnoreCamelContextEvents()) {
continue;
}
EventFactory factory = management.getEventFactory();
if (factory == null) {
return;
}
EventObject event = factory.createCamelContextResumingEvent(context);
if (event == null) {
return;
}
doNotifyEvent(notifier, event);
}
}
Aggregations