You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by al...@post8.tele.dk.INVALID on 2025/06/17 05:40:06 UTC

Endpoints not always mocked with Camel 3.22.2 and after - JUnit test included

Hi Camel Support
 

All endpoints are not always mocked with Camel 3.22.2 and after.
 

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 to BaseRoute.java, MyRoute.java and CamelAdviceMockTest.java.
It should be possible to reproduce the problem with these files.
 
The same test works with Camel version 3.10.0
The same test fails with Camel version 4.10.4
 
 
 

Best regards,

 
 

Allan Petersen