I normally override createRegistry() and add my beans to the registry there - something like this \ @Override protected JndiRegistry createRegistry() throws Exception { JndiRegistry registry = super.createRegistry(); registry.bind( "bean-name", new MyBean()); return registry; }
> On Aug 4, 2016, at 2:06 PM, Brad Johnson <brad.john...@mediadriver.com> wrote: > > Fired the email before I finished....Obviously the MyValidator class hasn't > been instantiated or made available as it would be in Spring, CDI or > Blueprint. So I need to add it to the registry. > > I can get the JndiRegistry from the PPDRegistry and call bind on it with > name/bean but don't know if that will really work or if there's an easier > way. > > > public class MyRouteBuilder extends RouteBuilder { > public void configure() { > from("direct:start").filter().method("MyValidator") > .to("mock:result"); > } > }; > > } > > On Thu, Aug 4, 2016 at 3:03 PM, Brad Johnson <brad.john...@mediadriver.com> > wrote: > >> 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"); >> } >> }; >> >> } >> >>