我正在使用Spring Boot,並且我剛剛添加了駱駝。簡單的駱駝測試失敗,沒有收到消息
我有一個簡單的駱駝路線設置:
import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;
@Component
public class MyRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
from("file://in").to("file://out");
}
}
當我嘗試用這條路線創建簡單的測試:
@RunWith(CamelSpringBootRunner.class)
@SpringBootTest
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
public class MyRouteTest extends CamelTestSupport {
@Autowired
private CamelContext camelContext;
@Produce(uri = "file://in")
private ProducerTemplate producerTemplate;
@EndpointInject(uri = "mock:file://out")
private MockEndpoint mockEndpoint;
@Test
public void routeTest() throws Exception {
mockEndpoint.expectedMessageCount(1);
producerTemplate.sendBody("Test");
mockEndpoint.assertIsSatisfied();
}
}
它失敗
mock://file://out Received message count. Expected: <1> but was: <0>
不知道這裏可能是一個問題。我有一個生成器模板,它具有uri作爲我從一開始的路線,並且正在用EndpointInject和模擬uri來嘲弄端點。
Configur e [AdviceWith](http://camel.apache.org/advicewith.html) 詳細示例:http://opensourceconnections.com/blog/2014/04/24/correctly-using-camels-advicewith-in-unit -tests/ – mgyongyosi
嘗試過,同樣的錯誤,奇怪的 – George96