camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Larry Meadors <larry.mead...@gmail.com>
Subject Re: How to mock a bean in a route for testing
Date Sun, 09 Sep 2012 19:02:32 GMT
Thanks, here's what I ended up doing.

Changed the bean call to look like this:
<to uri="{{circ.service}}"/>

That value is defined in a properties file - in live use it's
"bean:circService", but under testing it's "mock:circService".

In my test, I added this:

@EndpointInject(uri = "{{circ.service}}")
protected MockEndpoint circServiceMock;

Then in my test case, I added this:

circServiceMock.returnReplyBody(new Expression() {
@Override
public <T> T evaluate(Exchange exchange, Class<T> type) {
 return exchange.getContext().getTypeConverter().convertTo(type,
circResponse);
}
});

The circResponse variable has what I want the mocked service to return.

Larry

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message