Hi

This is because you use BOTH @MockEndpoints("*") and
interceptSendToEndpoint in your routes - then you end up with that dual
mocking that causes problems.
The old code was appearing to working but there are problems and going
forward this will not be supported.
We will let Camel throw a failure when it detects this dual mocking
(@MockEndpoints is a special kind of interceptSendToEndpoint).



On Sun, Aug 31, 2025 at 7:33 PM <[email protected]> wrote:

>
> Hi Camel Support
>
> All endpoints are not always mocked with Camel 4.14.0.
> The problem did start in Camel 3.22.2. The attached JUnit test did work on
> versions before 3.22.2
>
> If you write a JUnit test using:
>
> @CamelSpringBootTest
> @ShutdownTimeout(5)
> @SpringBootTest
> @ExtendWith(SpringExtension.class)
> @MockEndpoints("*")
> @Transactional
> @UseAdviceWith
>
> containing some advices and a custom RouteBuilder having an
> interceptSendToEndpoint.
>
> Something like this:
>
>
> public abstract class BaseRoute extends RouteBuilder {
>
> public BaseRoute() {
> this.interceptSendToEndpoint("*").process((exchange) ->
> System.out.println("Intercept send to"));
> }
>
> }
>
> then MockEndpoint.assertIsSatisfied(context)fails most of the time –
> occasionally it succeeds.
>
> The reason is, that alle the endpoints are not mocked.
>
> The problem might be related to the changes in AbstractCamelContext
> between version 3.22.2 and 3.22.1:
>
> @Override
> public void registerEndpointCallback(EndpointStrategy strategy) {
> if (!endpointStrategies.contains(strategy)) {
> // let it be invoked for already registered endpoints so it can
> // catch-up.
> endpointStrategies.add(strategy);
>
> has been changed to:
>
> @Override
> public void registerEndpointCallback(EndpointStrategy strategy) {
> if (endpointStrategies.add(strategy)) {
> // let it be invoked for already registered endpoints so it can
> // catch-up.
>
>
> I have attached the files BaseRoute.java, MyRoute.java and
> CamelAdviceMockTest.java.
> It should be possible to reproduce the problem with these files.
>
> The test works with Camel version 3.10.0 The test fails with Camel version
> 4.14.0
>
>
>
> Best regards,
>
> Allan Petersen



-- 
Claus Ibsen

Reply via email to