Hello,

I am currently trying to write a unit test for a camel route which contains
a .method("beanId","methodName") component:

  from(this.incomingSource)
    .split().method("splitterBean", "splitMessages")
    .choice()
      .when(isValid)
        .marshal(jaxb).to(this.outgoingDestination)
      .otherwise()
        .processRef("errorReportingProcessor").to(this.invalidDestination)
  .end();
         
In the Test class I have the following lines for the @Before method :

    @Before
    public void beforeTest() throws Exception {
        this.context = new DefaultCamelContext();

        this.route = new SplittingMainRoute();
        this.route.setIncomingSource("mokc:in");
        this.route.setOutgoingDestination(""mock:out);
        this.route.setInvalidDestination("mock:isValid");
        
        this.context.addRoutes(this.route);
        this.context.start();
        
        this.producer = this.context.createProducerTemplate();
    }
        
I'm actually running Camel on Fuse-Servicemix and the "splitterBean" bean is
defined in the bundle-context.xml as <bean id="splitterBean"
class="com.foo.MySplitterBean" />

My question is: How do I instantiate the splitterBean in my unit test so the
route can access it ? And BTW, how do I do that for the
errorReportingProcessor, which is also declared in the bundle-context.xml,
too ?

Many thanks in advance,

Xavier

-- 
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-route-with-method-Unit-Testing-tp3370644p3370644.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to