Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

Intercept - Log Message EIP for testing

$
0
0
Hello All,
I am writing a Camel Context test and I want to intercept a logging endpoint
to verify that a message is being logged. Here is a snippet from my route:

<camel:choice>
<camel:when>
<camel:method bean="accessControlProcessor" method="authorize" />
<camel:log message="access control returned true"/>
</camel:when>
<camel:otherwise>
<camel:log message="access control returned false"/>
</camel:otherwise>
</camel:choice>

I want to intercept this log:
<camel:log message="access control returned true"/>

I tried this but couldn't get it to work:

context.getRouteDefinition("myRoute").adviceWith(context, new
AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
interceptSendToEndpoint("log*").to("mock:accessControlLog");

});

However, my 'mock:accessControlLog' does not receive any messages. I know I
can call a 'direct' endpoint and then intercept that direct endpoint, but I
would prefer not to do that.

Is there any way to intercept or mock the log message instead?

Thanks,
Yogesh

Viewing all articles
Browse latest Browse all 5648

Trending Articles