0
我也有類似的問題,一個稍微簡單的路線: Camel NotifyBuilder always returns false駱駝NotifyBuilder條件失敗
我的路線如下:
PerfTestRouteBuilder
@Component
public class PerfTestRouteBuilder extends SpringRouteBuilder {
/* (non-Javadoc)
* @see org.apache.camel.builder.RouteBuilder#configure()
*/
@Override
public void configure() throws Exception {
from("direct:test-input")
.log("Creating test response object")
.process(exchange -> {
WOutputAccnLayout stubResponse = new WOutputAccnLayout();
stubResponse.setWOutAccnAccNum("AB999999999");
stubResponse.setWOutAccnCallStatus("SUCCESS");
exchange.getIn().setBody(stubResponse, WOutputAccnLayout.class);
})
.log("Test response object created: ${body}")
.end();
}
}
和我有下面的測試:
PerfTestRouteBuilderIT
public class PerfTestRouteBuilderIT extends CamelTestSupport {
@Override
protected RouteBuilder createRouteBuilder() {
return new PerfTestRouteBuilder();
}
@Before
public void setup() throws Exception {
super.setUp();
}
@Test
public void test_configure_exchangeSentToTestRoute_stubResponseAddedToBody() throws Exception {
startCamelContext();
NotifyBuilder notify = new NotifyBuilder(context)
.from("direct:test-input")
.whenAnyDoneMatches(body().isEqualTo(getStubResponse()))
.create();
template.sendBody("direct:test-input", "");
assertThat(notify.matches(5, TimeUnit.SECONDS), is(true));
stopCamelContext();
}
private WOutputAccnLayout getStubResponse() {
WOutputAccnLayout stubResponse = new WOutputAccnLayout();
stubResponse.setWOutAccnAccNum("AB999999999");
stubResponse.setWOutAccnCallStatus("SUCCESS");
return stubResponse;
}
}
條件計算結果始終爲假,我不明白爲什麼,考慮到getStubResponse方法返回一個對象設置完全一樣將在路線。上次的解決方案是使用template.sendBody,或者通過路由端點創建交換並使用它,目前爲止這兩種方法都沒有奏效。圍繞我如何使用駱駝測試套件?
是它也許是.equals()實施WOutputAccnLayout對象的? – ltsallas
好點,將調查它 – jbailie1991
是的,嘗試了一個關於body和stub響應的assertEquals,由於如何實現.equals失敗。不幸的是它的一個生成的類,所以我不能改變等於實現,但至少我知道它不是notifybuilder – jbailie1991