Apache Camel - Connection Beans Without Spring
Join the DZone community and get the full member experience.
Join For FreeWhile writing some tests for an Apache Camel project, I just spent rather longer than I'd have liked trying to work out how to configure a connection bean for Mongo without using Spring.
Since I hide my embarrassments in public I thought I'd best share with anyone else with brain freeze.
Since I hide my embarrassments in public I thought I'd best share with anyone else with brain freeze.
public class SomeTest extends CamelTestSupport { @Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { from("direct:findAll") .to("mongodb:myConnectionBean?database=flights&collection=tickets&operation=findAll") .to("mock:resultFindAll"); } }; } @Override protected JndiRegistry createRegistry() throws Exception { JndiRegistry reg = new JndiRegistry(createJndiContext()); Mongo connectionBean = new Mongo("localhost", 27017); reg.bind("myConnectionBean", connectionBean); return reg; } @Test public void testSomething() throws InterruptedException { // test something here } }Don't forget you need the camel-mongodb artifact in your pom.xml file. Good luck fellow travellers.
Apache Camel
Spring Framework
Connection (dance)
Published at DZone with permission of Col Wilson, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
Top Six React Development Tools
-
A Complete Guide to Agile Software Development
-
Azure Virtual Machines
-
How To Use an Automatic Sequence Diagram Generator
Comments