[英]Testing from-Endpoints with CamelBlueprintTestSupport fails with some components
我想測試用 Blueprint-XML 實現的駱駝路線。 當嘗試使用簡單的“直接”端點測試路由時,一切正常。
但是將“from”端點更改為 netty 或 jetty 組件,測試失敗,但出現以下異常:
java.lang.RuntimeException: 放棄等待來自 bundle 'MyRouteTest' 的 BlueprintContainer
我的路線如下所示:
<route id="test">
<from uri="jetty:http://test:8080/sample/test?matchOnUriPrefix=true" />
<log id="_log1" loggingLevel="INFO" message="Test " />
</route>
我的擴展 CamelBlueprintTestSupport 的測試 class 如下所示:
// 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>
通過將 from 部分從 jetty 替換為 direct 可以正常工作(例如,測試運行沒有錯誤,當然由於 assert(true) 檢查而最終是肯定的)
有誰能夠幫我?
mvn測試的output是
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
解決方案是將以下代碼添加到測試 class 中:
修改路由到
@Override
public boolean isUseAdviceWith() {
return true;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.