java Camel/Quarkus - AdviceWith无法通过id找到路线

cu6pst1q  于 2024-01-05  发布在  Java
关注(0)|答案(1)|浏览(253)

我有以下路线:

  1. from("direct:someRoute")
  2. .id("someRoute")
  3. .log(...)
  4. .to("sql-stored:someProcedure(BIGINT ${exchangeProperty.someVal})")
  5. .id("someCall")
  6. .log(...)
  7. .end()

字符串
我正在尝试用预存数据替换someCall REST调用以进行测试。
我的测试是这样的:

  1. @QuarkusTest
  2. public Class Tests{
  3. @Inject
  4. CamelContext camelContext
  5. @BeforeEach
  6. public void setup(){
  7. AdviceWith.adviceWith(
  8. this.camelContext,
  9. "someRoute",
  10. a -> {
  11. a.weaveById("someCall")
  12. .replace()
  13. .setBody()
  14. .constant("{}")
  15. }
  16. );
  17. }
  18. @Test
  19. public void testOne(){
  20. //...
  21. }
  22. @Test
  23. public void testTwo(){
  24. //...
  25. }
  26. }


然而,当我运行测试时,我得到以下错误:

  • 第一个测试错误:
  • Cannot advice route as route with id: someRoute does not exists
  • 第二个测试错误:
  • There are no outputs with matches: someCall in the route: <routeToString, oddly with no mention of the someCall route, or even an sql route>

对我来说似乎是奇怪的错误,查看日志和路由肯定会被拾取,更奇怪的是someCall引用不在toString中。

更新

刚刚意识到这发生在第一次测试之后的测试中。似乎我的问题与@BeforeEach中的面孔有关.

更新2

在测试开始时尝试调用context.stop()context.start(),但得到一个错误,说不支持。
尝试使用CamelQuarkusTestSupport最终完成了第一个测试,但是每个额外的测试都有一个没有路由的空CamelQuarkus

vc9ivgsu

vc9ivgsu1#

这是因为您应该将ID设置为:

  1. .routeId("someRoute")

字符串

相关问题