camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmcb55 <mcbenne...@dnb.com>
Subject How to mock endpoints taking lots of different query parameters values?
Date Wed, 19 Sep 2012 21:37:32 GMT
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: http://camel.465427.n5.nabble.com/How-to-mock-endpoints-taking-lots-of-different-query-parameters-values-tp5719629.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message