camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: How to mock endpoints taking lots of different query parameters values?
Date Thu, 20 Sep 2012 06:51:07 GMT

There is API on CamelContext to get all the endpoints. Then just loop
that and do your own matching on the names (eg your wildcard stuff),
and apply the whenXXX code to them.

On Thu, Sep 20, 2012 at 8:46 AM, pmcb55 <> wrote:
> Hi Willem,
> Thanks for the comment - and yes, I probably could add a custom
> MockComponent like you say, but that's a lot more work than I think a
> developer should have to do.
> The reason to have a single mock to handle numerous query parameters is
> simply that the actual thing I'm mocking is a complex Web Service that in
> the real world is a HTTP endpoint that takes it's input via URI query
> parameters (and it can take lots of different params with lots of different
> values). So I'm trying to mock this complex component so I can run unit test
> easily without having to go through HTTP to the real service.
> So as I posted originally, I just want to write something really simple and
> intuitive like:
>   Processor emulator = new EmulatorThatActsLikeTheComplexHttpService();
>   MockEndpoint mock = getMockEndpoint("mock:Service");
>   mock.whenAnyExchangeReceived(emulator);
> As you can see I want my emulator to handle 'any' exchange that is fired at
> the mock, so I can setup tests to fire all kinds of requests like this:
>   from("direct:start").to("mock:Service?q=test");
>   from("direct:start").to("mock:Service?UserCategory=HighPriority&q=test");
>   from("direct:start").to("mock:Service?UserCategory=LowPriority&q=test");
> from("direct:start").to("mock:Service?UserCategory=HighPriority&Country=France&q=test");
> from("direct:start").to("mock:Service?UserCategory=HighPriority&Country=Ireland&q=test");
> Thanks,
> Pat.
> --
> View this message in context:
> Sent from the Camel - Users mailing list archive at

Claus Ibsen
Red Hat, Inc.
FuseSource is now part of Red Hat
Twitter: davsclaus
Author of Camel in Action:

View raw message