我有以下路线:
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
,没有路线...