我想测试使用蓝图XML实现的Camel Routes。当尝试使用简单的"直接"-from 端点测试路由时,一切正常。
但是,将"from"终结点更改为 netty 或 jetty 组件,测试将失败,并出现以下异常:
java.lang.RuntimeException:放弃等待捆绑包"MyRouteTest"中的蓝图容器
我的路线如下所示:
<route id="test">
<from uri="jetty:http://test:8080/sample/test?matchOnUriPrefix=true" />
<log id="_log1" loggingLevel="INFO" message="Test " />
</route>
我的扩展 CamelBlueprintTestSupport 的测试类如下所示:
// imports...
public class MyRouteTest extends CamelBlueprintTestSupport {
@Override
protected String getBlueprintDescriptor() {
return "/OSGI-INF/blueprint/blueprint2.xml";
}
@Test
public void testRoute() throws Exception {
context.getRouteDefinition("test").adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
replaceFromWith("direct:myMock");
}
});
assert (true);
}
}
将路由修改为
<route id="test">
<from
uri="direct:halloTest" />
<log id="_log1" loggingLevel="INFO" message="Test " />
</route>
通过将从码头到直接的零件更换工作正常(例如,测试运行没有错误,当然最终会成为断言(true(检查的正原因(
有人可以帮助我吗?
mvn 测试的输出为
ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 31.843 s <<< FAILURE! - myPackage.MyRouteTest
[ERROR] testRoute(myPackage.MyRouteTest) Time elapsed: 31.544 s <<< ERROR!
java.lang.RuntimeException: Gave up waiting for BlueprintContainer from bundle "MyRouteTest"
[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR] MyRouteTest>CamelBlueprintTestSupport.setUp:241->CamelBlueprintTestSupport.createBundleContext:175 ▒ Runtime
[INFO]
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
灵魂是将以下代码添加到测试类中:
将路由修改为
@Override
public boolean isUseAdviceWith() {
return true;
}