我写了这条骆驼路线:
@Component
public class FirstRoute extends RouteBuilder {
private static final String DIRECT_ENDPOINT = "direct:test_direct";
private static final String HTTP_ENDPOINT = "http:test_http";
@Autowired
private URIProcessor uriProcessor;
@Override
public void configure() throws Exception {
restConfiguration().component("servlet").bindingMode(RestBindingMode.json);
rest("/doTest/").post("/{comp}").to(DIRECT_ENDPOINT);
test();
}
public void test() {
from(DIRECT_ENDPOINT).routeId("route_rest")
.marshal().json(JsonLibrary.Jackson)
.process(uriProcessor)
.to(HTTP_ENDPOINT).unmarshal().json(JsonLibrary.Jackson, TestDto.class);
}
}
它工作正常。
我想为此路线编写一个测试类,所以我在测试类中写道:
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new FirstRoute();
但是当我运行测试时会出现错误。
这是错误日志:
org.apache.camel.FailedToCreateRouteException: Failed to create route route_rest at: >>> process[Processor@0x0] <<< in route: Route(route_rest)[[From[direct:testEsenzioneReddito]] -> [Ma... because of ref must be specified on: process[Processor@0x0]
...
Caused by: java.lang.IllegalArgumentException: ref must be specified on: process[Processor@0x0]
... 42 more
我不知道这可能是什么,有人知道有人提出任何建议吗? 谢谢