Camel advisewith没有模拟出端点



我有一个复杂的Camel集成测试,目前在2条路由下工作良好。所有的advisewiths都工作得很好,并成功地模拟了.to()端点。但是,当添加新的advisewith以模拟新路由中的to()时,测试将打开一个连接,而不是将消息重定向到mockEndpoint。AdviceWith如下:

AdviceWithRouteBuilder.adviceWith(camelContext, CREATE_PERSON_ROUTE_ID, route ->
route.weaveById(CREATE_PERSON_ENDPOINT).replace().to(mockCreatePersonEndpointUri));

同样的格式也适用于其他路由,例如:

AdviceWithRouteBuilder.adviceWith(camelContext, QUARANTINE_RECORD_PERSON_ROUTE_ID, route ->
route.weaveById(PERSON_QUARANTINE_RECORD_ENDPOINT).replace().to(mockPersonQuarantineRecordEndpointUri));

出现此问题的驼峰线:

.to(housingEndpoint).id(CREATE_PERSON_ENDPOINT)

所讨论的端点:

Endpoint housingEndpoint = HousingRestAPIEndpoint.getHousingRestAPIEndpoint(getContext());

请查看测试设置:

mockCreatePersonEndpoint = camelContext.getEndpoint(mockCreatePersonEndpointUri, MockEndpoint.class);

我想知道如果这是一个错误,因为如所述,完全相同的配置工作良好的其他路由与端点被模拟出来。同样,如果我将测试代码提取到它自己的类中,AdviceWith的行为就会像预期的那样。欢迎提出任何意见。由于

现在已经修复了,问题是我在测试类和被测试代码中初始化了一个新的CamelContext,导致advisewith实际上模拟了一个没有被使用的路由。

最新更新