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

问题描述 投票:0回答:1

我有以下路线:

from("direct:someRoute")
.id("someRoute")
.log(...)
.to("sql-stored:someProcedure(BIGINT ${exchangeProperty.someVal})")
.id("someCall")
.log(...)
.end()

我正在尝试用预设的测试数据替换

someCall
REST 调用。

我已经这样设置了我的测试:

@QuarkusTest
public Class Tests{

    @Inject
    CamelContext camelContext

    @BeforeEach
    public void setup(){
        AdviceWith.adviceWith(
            this.camelContext,
            "someRoute",
            a -> {
                a.weaveById("someCall")
                    .replace()
                    .setBody()
                    .constant("{}")
            }
        );
    }

    @Test
    public void testOne(){
        //...
    }
    @Test
    public void testTwo(){
        //...
    }
}

但是,当我运行测试时,出现以下错误:

  • 第一次测试错误:
    • 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
,没有路线...

java apache-camel quarkus
1个回答
0
投票
这是因为你应该将 id 设置为 .routeId("someRoute")

© www.soinside.com 2019 - 2024. All rights reserved.