私はいくつかのラクダルートが設定されているSpringbootアプリケーションを持っています。私はここにhttp://camel.apache.org/camel-test.html言及した別のものを試してみましたが、それは作業を取得していないようqueueEventHandler :: handleQueueEvent
にtestQueue:SpringブートApache Camelルートテスト
public class CamelConfig {
private static final Logger LOG = LoggerFactory.getLogger(CamelConfig.class);
@Value("${activemq.broker.url:tcp://localhost:61616}")
String brokerUrl;
@Value("${activemq.broker.maxconnections:1}")
int maxConnections;
@Bean
ConnectionFactory jmsConnectionFactory() {
PooledConnectionFactory pooledConnectionFactory = new PooledConnectionFactory(new ActiveMQConnectionFactory(brokerUrl));
pooledConnectionFactory.setMaxConnections(maxConnections);
return pooledConnectionFactory;
}
@Bean
public RoutesBuilder route() {
LOG.info("Initializing camel routes......................");
return new SpringRouteBuilder() {
@Override
public void configure() throws Exception {
from("activemq:testQueue").to("bean:queueEventHandler?method=handleQueueEvent");
}
};
}
}
私はActiveMQのから、このルートをテストしたいです。
私はこの
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {CamelConfig.class, CamelTestContextBootstrapper.class})
public class CamelRouteConfigTest {
@Produce(uri = "activemq:testQueue")
protected ProducerTemplate template;
@Test
public void testSendMatchingMessage() throws Exception {
template.sendBodyAndHeader("testJson", "foo", "bar");
.....
..... verify handleQueueEvent method is called on bean queueEventHandler by mocking
}
ような何かをしようとしています。しかし、私のProducerTemplateは常にnullです。 Autowiring Camelcontextを試しましたが、CamelContextを解決できないという例外があります。しかし、これはSpringCamelContext.classを@SpringBootTestクラスに追加することで解決できます。しかし、私のProducerTemplateはまだnullです。
をお勧めします。私はCamel 2.18を使用しています。Springboot 1.4
Gitでルートとテストコード全体を提供できますか?ありがとうございます。 – sunleo