Hi Claus,
I've done some steps forward. Thank you for your hint to AdviceWith and
Stubs. But there is the same issue:
ModelCamelContext modelCamelContext = (ModelCamelContext)
camelContext;
modelCamelContext.getRouteDefinitions().get(0).adviceWith(camelContext, new
AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
replaceFromWith("direct:in");
interceptSendToEndpoint("mock:bean://processorA?method=processContent")
.skipSendToOriginalEndpoint()
.to("mock:out");
}
});
modelCamelContext.start();
MockEndpoint out = modelCamelContext.getEndpoint("mock:out",
MockEndpoint.class);
out.setExpectedMessageCount(1);
LOG.info(">>>>>>>> produce");
testProducer.sendBodyAndHeader("<message>test</message>",
Constants.JMS_HEADER_DATA_SOURCE, Constants.DEFAULT_JMS_HEADER_A);
out.assertIsSatisfied();
LOG.info(">>>>>>>> finish");
The Message is sent successfully to direct:in. It's also delivered
correctly using the route. When I put additional log statements into the
route they will be shown correctly which indicates that the Message is
delivered correctly. But the assertIsSatisfied failed. When I debug into
the MockEndpoint code, I can see that the counter is incremented correctly.
When the assertIsSatisfied is called the counter is empty. But the init
method of the MockEndpoint isn't called. So I would expect that the counter
is at 1 and not 0.
Marc
2015-08-04 10:41 GMT+02:00 Marc Ende <[email protected]>:
> Hi Claus,
>
> thanks for the hint to stub and adviceWith. I'm trying to use stub but I
> haven't found an example how to use stub.
> Do I use it in combination with @Produce or is it a completly diffrent
> approach?
>
> Thanks
> Marc
>
> 2015-08-04 9:37 GMT+02:00 Claus Ibsen <[email protected]>:
>
>> Hi
>>
>> Take a look at stub, or advice with and use replace from etc for testing.
>>
>>
>> On Tue, Aug 4, 2015 at 8:48 AM, Marc Ende <[email protected]> wrote:
>> > Hi,
>> >
>> > I've got a not very complex route:
>> >
>> >
>> >
>> from(routes.getActivemqEndpoint()).routeId(Route.PROCESSING_ROUTE.getRouteId())
>> > .choice()
>> >
>> >
>> .when(header(Constants.JMS_HEADER_DATA_SOURCE).isEqualTo(Constants.DEFAULT_JMS_HEADER_B))
>> > .to(routes.getProcessingEndpoint(Constants.ORIGIN_B))
>> >
>> >
>> .when(header(Constants.JMS_HEADER_DATA_SOURCE).isEqualTo(Constants.DEFAULT_JMS_HEADER_A))
>> > .to(routes.getProcessingEndpoint(Constants.ORIGIN_A))
>> > .otherwise()
>> > .log(LoggingLevel.ERROR,"Message was not identified...")
>> > .to(routes.getProcessingUnknownEndpoint());
>> >
>> > If I try to unit-test this route using spring. This route is correctly
>> > build up in camel context and I also can send messages to the endpoints
>> in
>> > this route.
>> > But I would expect that if i send a message to the activemq endpoint it
>> > should be delivered to one of the other endpoints. But that didn't
>> happen.
>> >
>> > the activemq endpoint is mocked using mock:activemq://queue... If I
>> send a
>> > message to mock:activemq://queue... it will only be delivered to this
>> > endpoint.
>> > If I send the message to the real endpoint of the route
>> > (activemq://queue...) it will be delivered to the expected endpoint. But
>> > then the counter within the MockEndpoint of the endpoint
>> > isn't incremented and the assertion fails.
>> >
>> > Does anyone have an idea?
>> >
>> > Marc
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> http://davsclaus.com @davsclaus
>> Camel in Action 2nd edition: http://www.manning.com/ibsen2
>>
>
>