endpoint.setRuleBaseResource(new ClassPathResource("router.drl"));
drools.setEndpoints(new DroolsEndpoint[] {endpoint });
jbi.activateComponent(drools, "servicemix-drools");
MockServiceComponent m1 = new MockServiceComponent(new QName("target1"), "endpoint");
m1.setResponseContent(new StringSource("<target1/>"));
MockServiceComponent m2 = new MockServiceComponent(new QName("target2"), "endpoint");
m2.setResponseContent(new StringSource("<target2/>"));
MockServiceComponent m3 = new MockServiceComponent(new QName("target3"), "endpoint");
m3.setResponseContent(new StringSource("<target3/>"));
jbi.activateComponent(m1, "mock1");
jbi.activateComponent(m2, "mock2");
jbi.activateComponent(m3, "mock3");
jbi.start();
InOut me = client.createInOutExchange();
me.setService(new QName("drools"));
me.getInMessage().setContent(new StringSource("<test id='0' />"));
client.sendSync(me);
assertNotNull(me.getFault());
client.done(me);
me = client.createInOutExchange();
me.setService(new QName("drools"));
me.getInMessage().setContent(new StringSource("<test id='1' />"));
client.sendSync(me);
Element e = new SourceTransformer().toDOMElement(me.getOutMessage());
assertEquals("target1", e.getLocalName());
client.done(me);
me = client.createInOutExchange();
me.setService(new QName("drools"));
me.getInMessage().setContent(new StringSource("<test id='2' />"));
client.sendSync(me);
e = new SourceTransformer().toDOMElement(me.getOutMessage());
assertEquals("target2", e.getLocalName());
client.done(me);
me = client.createInOutExchange();
me.setService(new QName("drools"));
me.getInMessage().setContent(new StringSource("<test id='3' />"));
me.getInMessage().setProperty("prop", Boolean.TRUE);
client.sendSync(me);
e = new SourceTransformer().toDOMElement(me.getOutMessage());
assertEquals("target3", e.getLocalName());
client.done(me);
me = client.createInOutExchange();
me.setService(new QName("drools"));
me.getInMessage().setContent(new StringSource("<test id='4' />"));
client.sendSync(me);
assertEquals(ExchangeStatus.ERROR, me.getStatus());
Thread.sleep(50);
}