Reputation: 21
I have a complex Camel integration test which currently is working fine with 2 routes. All AdviceWiths work perfectly fine and successfully mock out the .to() endpoints. However, when adding a new AdviceWith in order to mock out a to() in a new route, the test opens a connection instead of redirecting the message to the mockEndpoint. The AdviceWith is as follows:
AdviceWithRouteBuilder.adviceWith(camelContext, CREATE_PERSON_ROUTE_ID, route ->
route.weaveById(CREATE_PERSON_ENDPOINT).replace().to(mockCreatePersonEndpointUri));
This same format is working fine for another route, such as:
AdviceWithRouteBuilder.adviceWith(camelContext, QUARANTINE_RECORD_PERSON_ROUTE_ID, route ->
route.weaveById(PERSON_QUARANTINE_RECORD_ENDPOINT).replace().to(mockPersonQuarantineRecordEndpointUri));
The camel line where this issue occurs:
.to(housingEndpoint).id(CREATE_PERSON_ENDPOINT)
The endpoint in question:
Endpoint housingEndpoint = HousingRestAPIEndpoint.getHousingRestAPIEndpoint(getContext());
Please see setup for the test:
mockCreatePersonEndpoint = camelContext.getEndpoint(mockCreatePersonEndpointUri, MockEndpoint.class);
I am wondering if this is a bug because as stated, the exact same config works fine for other routes with endpoints that are mocked out. Also, if I extract the test code into its own class, the AdviceWith behaves as expected. Any ideas welcome. Thanks
Upvotes: 0
Views: 1005
Reputation: 21
This is now fixed, issue was that I was initializing a new CamelContext both in the test class and in the code being tested, resulting the AdviceWith essentially mocking out a route that was not being used.
Upvotes: 2