我有 spring boot 应用程序,spring boot 版本为 1.5.8camel 2.20.1
简单路线:
@Component
public class MyRoute extends RouteBuilder {
public static final String IN = "file://in";
public static final String OUT = "file://out";
@Override
public void configure() throws Exception {
from(IN).routeId("myId").to(OUT);
}
}
和简单的测试:
//@SpringBootTest
public class MyRouteTest extends CamelTestSupport {
@Produce(uri = MyRoute.IN)
private ProducerTemplate producerTemplate;
@EndpointInject(uri = "mock:file:out")
private MockEndpoint mockEndpointOut;
@Override
public String isMockEndpoints() {
return "*";
}
@Test
public void simpleTest() throws Exception {
mockEndpointOut.expectedMessageCount(1);
producerTemplate.sendBody("Test");
mockEndpointOut.assertIsSatisfied();
}
@Override
protected RoutesBuilder createRouteBuilder() throws Exception {
return new MyRoute();
}
}
当我运行这个测试时,它运行良好,我收到一条消息并且端点很满意。如果我添加@SpringBootTest
注释,测试失败?为什么 ?当我运行 maven clean install 时也没有注释它也会失败:(
任何人都知道这个注释对骆驼测试有什么作用,或者我该如何调整它以使其工作?
谢谢