On 8/17/07, Nick Outram <[EMAIL PROTECTED]> wrote: > Settup: > > from("seda:in").beanRef("myBean").to("seda:out); > > with "myBean" defined in the spring application context as a pojo > implementing the meathod read(String) and sending a message: > > template.send("seda:in", new Processor() { > public void process(Exchange e) { > Message in = exchange.getIn(); > in.setBody("Wibble"); > in.setHeader(BeanProcessor.METHOD_NAME, "read"); > } > }); > > doesn't result in a call to the read() method of the bean.
This one totally had me foxed for some time! I was stepping through the debugger, seeing the method invoked correctly. Yet the test was failing. I was really starting to doubt all kinds of things (e.g. the registry, JNDI etc). Turns out - its ye-old-async-tripping-us-up. You're using 'seda:in' as the first send. So the test after calling template.send() it may - or usually won't, have invoked the bean yet. If you wait a bit - it probably will invoke the bean :). i.e. using "seda:in" means, don't block the caller waiting to actually process the message - do that sometime asynchronously in the background. Here's a test case - I just switched it to use "direct:in" so it synchronously processes the message on the template.send() and hey presto, test case works. https://svn.apache.org/repos/asf/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/BeanRouteTest.java If you really want a "seda:in" test case, then we must wait a certain amount of time for the method to be invoked, say using a CountDownLatch - which just reminds me of how very useful the mock testing in camel is :) http://activemq.apache.org/camel/mock.html -- James ------- http://macstrac.blogspot.com/