camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brad Johnson <brad.john...@mediadriver.com>
Subject Bean injection?
Date Thu, 04 Aug 2016 20:03:09 GMT
Is there an easy way to inject a bean in the CamelTestSupport that is
required by a RouteBuilder?

Looking at the CBTS example I'll modify it a bit:

public class FilterTest extends CamelTestSupport {

    @EndpointInject(uri = "mock:result")
    protected MockEndpoint resultEndpoint;

    @Produce(uri = "direct:start")
    protected ProducerTemplate template;

    @Override
    public boolean isDumpRouteCoverage() {
        return true;
    }

    @Test
    public void testSendMatchingMessage() throws Exception {
        String expectedBody = "<matched/>";

        resultEndpoint.expectedBodiesReceived(expectedBody);

        template.sendBodyAndHeader(expectedBody, "foo", "bar");

        resultEndpoint.assertIsSatisfied();
    }
 @Override
    protected RouteBuilder createRouteBuilder() {
        return MyRouteBuilder()
    }
}

public class MyRouteBuilder extends RouteBuilder {
public void configure() {

from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result");
            }
        };

}

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message