camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem jiang <>
Subject Re: How to mock endpoints taking lots of different query parameters values?
Date Thu, 20 Sep 2012 06:10:05 GMT
It could easy to implement your requirement by add a customer MockComponent which just look
up the created MockEndpoint if the uri is end with *.

But I'm not sure why do you want to create the same mock endpoint with the uri with different
the query parameters.

Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: |
Blog: ( (English)
 ( (Chinese)
Twitter: willemjiang 
Weibo: willemjiang

On Thursday, September 20, 2012 at 5:37 AM, pmcb55 wrote:

> So I have a very simple mocking use-case. Basically I want to do the
> following:
> Processor emulator = new ServiceEmulator();
> MockEndpoint mock = getMockEndpoint("mock:Service");
> mock.whenAnyExchangeReceived(emulator);
> This is fine, but if I want to invoke my mock with query parameters my
> emulator won't get called:
> from("direct:start").to("mock:Service?q=test");
> Instead I have to explicit list the query parameter values in the
> 'getMockEndpoint()' call:
> MockEndpoint mock = getMockEndpoint("mock:Service?q=test");
> But what if I have lots and lots of variations on the query parameters I
> want to test? Do I have to predefine them all and register an explicit mock
> instance for each of those variations (and get the order of the params
> exactly correct when registering, and then call
> 'mock.whenAnyExchangeReceived(emulator);' on each instance?)?? 
> What I really want to do is have my emulator called regardless of the query
> parameters, and I thought my first example above would just work (i.e.
> getMockEndpoint("mock:Service")). Is there a simple way to specify
> 'whenAnyExchangeReceived()' for a mocked endpoint taking arbitrary query
> parameters, or do I have to move to using 'adviceWith()'?
> I really found the above mocking code very intuitive initially, so if
> something like 'getMockEndpoint("mock:Service*")' (note the wildcard) could
> work that would be cool I think!!
> Thanks,
> Pat.
> --
> View this message in context:
> Sent from the Camel - Users mailing list archive at (

View raw message