OK I simplified the test (removed xml read, set header with xpath etc) and got
the test pass.
I used "mockEndpointsAndSkip" in the setup and "getMockEndpoint" instead of an
instance variable mock.
Hope you can adapt it for your (complete) case.
Stephan
@Produce(uri = "direct:METARformatter")
protected ProducerTemplate input;
@Before
public void setupContext() throws Exception{
context.getRouteDefinition("fromMETARformatter").adviceWith(context,
new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
mockEndpointsAndSkip("direct:*");
}
});
}
@Test
public void testValidMetar() throws Exception {
context.start();
getMockEndpoint("mock:direct:METARvalidator").expectedMessageCount(1);
input.sendBody("MyMessageBody");
// Validate our expectations
assertMockEndpointsSatisfied();
}
-----Ursprüngliche Nachricht-----
Von: Lukas Winkler [mailto:[email protected]]
Gesendet: Mittwoch, 2. August 2017 11:24
An: [email protected]
Betreff: Re: AdviceWith in test not followed
Hallo Stephan,
yes I already tried and just had another run, does not change a thing (also
tried with completely different mock endpoint just to be sure).
Let me also use this opportunity to attach a few lines from the unittest run:
[ main] BlueprintCamelContext INFO
Route: metar-provider-formatter is stopped, was consuming from:
Endpoint[direct://METARformatter]
[ main] BlueprintCamelContext INFO
Route: metar-provider-formatter is shutdown and removed, was consuming
from: Endpoint[direct://METARformatter]
[ main] RouteDefinition INFO
AdviceWith route after:
Route(metar-provider-formatter)[[From[direct:METARformatter]] ->
[InterceptSendToEndpoint[direct:METARvalildator ->
[To[mock:outputFromFormatter]]], SetHeader[locationIndicatorICAO,
xpath{XPath: //aixm:locationIndicatorICAO[1]/text()}],
To[direct:METARvalidator]]]
[ main] BlueprintCamelContext INFO
Route: metar-provider-formatter started and consuming from:
Endpoint[direct://METARformatter]
[ main] BlueprintCamelContext INFO
Apache Camel 2.17.0.redhat-630187 (CamelContext:
metar-provider-context) is starting
[ main] BlueprintCamelContext INFO
Total 6 routes, of which 5 are started.
[ main] BlueprintCamelContext INFO
Apache Camel 2.17.0.redhat-630187 (CamelContext:
metar-provider-context) started in 0.000 seconds
- Lukas
On 2 August 2017 at 11:15, Burkard Stephan <[email protected]> wrote:
> Just a quick guess to try: have you tried to replace the "to(output)" with
> "to("mock:outputFromFormatter")"?
>
> Cheers
> Stephan
>
>
> -----Ursprüngliche Nachricht-----
> Von: Lukas Winkler [mailto:[email protected]]
> Gesendet: Mittwoch, 2. August 2017 11:10
> An: [email protected]
> Betreff: AdviceWith in test not followed
>
> Dear list,
>
> starting out with Camel and run into a problem when trying to test part of my
> camel context.
>
> Please find the test code as well as a snipped of the 'to test' route in the
> following gist:
> https://gist.github.com/ingwinlu/bb047cc409fb295b8d74b617ae04008c
>
> From the logs that are running I can see that the message I send through the
> test gets routed via the original path.
>
> Camel Version is Apache Camel 2.17.0.redhat-630187
>
> BR and thanks for any help,
> Lukas