use of java.util.EventObject in project camel by apache.
the class EventNotifierRedeliveryEventsTest method createCamelContext.
@Override
protected CamelContext createCamelContext() throws Exception {
DefaultCamelContext context = new DefaultCamelContext(createRegistry());
context.getManagementStrategy().addEventNotifier(new EventNotifierSupport() {
public void notify(EventObject event) throws Exception {
events.add(event);
}
public boolean isEnabled(EventObject event) {
return true;
}
@Override
protected void doStart() throws Exception {
setIgnoreCamelContextEvents(true);
setIgnoreRouteEvents(true);
setIgnoreServiceEvents(true);
}
@Override
protected void doStop() throws Exception {
}
});
return context;
}
use of java.util.EventObject in project camel by apache.
the class EventNotifierServiceStoppingFailedEventTest method createCamelContext.
@Override
protected CamelContext createCamelContext() throws Exception {
CamelContext context = super.createCamelContext();
context.addService(new MyService("A", false));
context.addService(new MyService("B", true));
context.addService(new MyService("C", false));
context.getManagementStrategy().addEventNotifier(new EventNotifierSupport() {
public void notify(EventObject event) throws Exception {
events.add(event);
}
public boolean isEnabled(EventObject event) {
return true;
}
@Override
protected void doStart() throws Exception {
}
@Override
protected void doStop() throws Exception {
}
});
return context;
}
use of java.util.EventObject in project camel by apache.
the class EventNotifierEventsTest method createCamelContext.
@Override
protected CamelContext createCamelContext() throws Exception {
DefaultCamelContext context = new DefaultCamelContext(createRegistry());
context.getManagementStrategy().addEventNotifier(new EventNotifierSupport() {
public void notify(EventObject event) throws Exception {
events.add(event);
}
public boolean isEnabled(EventObject event) {
return true;
}
@Override
protected void doStart() throws Exception {
}
@Override
protected void doStop() throws Exception {
}
});
return context;
}
use of java.util.EventObject in project camel by apache.
the class EventNotifierExchangeCompletedTest method createCamelContext.
@Override
protected CamelContext createCamelContext() throws Exception {
DefaultCamelContext context = new DefaultCamelContext(createRegistry());
context.getManagementStrategy().addEventNotifier(new EventNotifierSupport() {
public void notify(EventObject event) throws Exception {
events.add(event);
}
public boolean isEnabled(EventObject event) {
// we only want the completed event
return event instanceof ExchangeCompletedEvent;
// you can add additional filtering such as the exchange
// should be from a specific endpoint or route
// just return true for the events you like
}
protected void doStart() throws Exception {
// noop
}
protected void doStop() throws Exception {
// noop
}
});
return context;
}
use of java.util.EventObject in project camel by apache.
the class EventNotifierExchangeSentParallelTest method testExchangeSentRecipient.
public void testExchangeSentRecipient() throws Exception {
getMockEndpoint("mock:result").expectedMessageCount(1);
template.sendBodyAndHeader("direct:foo", "Hello World", "foo", "direct:cool,direct:start");
// wait for the message to be fully done using oneExchangeDone
assertMockEndpointsSatisfied();
assertTrue(oneExchangeDone.matchesMockWaitTime());
// stop Camel to let all the events complete
context.stop();
assertTrue("Should be 11 or more, was: " + events.size(), events.size() >= 11);
// we run parallel so just assert we got 6 sending and 6 sent events
int sent = 0;
int sending = 0;
for (EventObject event : events) {
if (event instanceof ExchangeSendingEvent) {
sending++;
} else {
sent++;
}
}
assertTrue("There should be 5 or more, was " + sending, sending >= 5);
assertTrue("There should be 5 or more, was " + sent, sent >= 5);
}
Aggregations