Hi,

This is a very basic and probably stupid question but I want to learn from
my mistakes/misunderstandings.

I have a JUnit test case with the override of the RoutesBuilder
createRouteBuilder() method
In that method I define 2 routes like this

from("direct:myRoute")
.setHeader("CamelHttpMethod", constant("POST"))
.setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
.process(exchange -> exchange.getIn().setBody("{"Param":"myParam"}"))
.to("http://myserver/api/service";)
.to("jms:myqueue");

from("jms:myqueue")
.to("mock:myMock)


Now when I execute the test

getMockEndpoint("mock:myMock").expectedMessageCount(1);
assertMockEndpointsSatisfied();
}

The test fails, it only work when I add this in the test

  String response =   template.requestBody("direct:myRoute,"",String.class);

So it looks like i need to "invoke" something before the test runs
correctly. I would have expected the previous statement was not necessary?
Why is this necessary or what am I missing in my route so that
"template.requestBody" doens't need to be executed.

I want to apologize again from this very basic question but hope you can
give me some insight on the why.

Thank you.

Regards,
/Tom

Reply via email to