You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by James Strachan <ja...@gmail.com> on 2008/09/17 11:14:30 UTC

Fwd: testNG test harness for Camel, sending and receiving messages

Forgot to CC the user list whoops :)

2008/9/16 Mick Knutson <mk...@baselogic.com>:
> I am trying to setup camel within Maven to start my camel context via the
>           <plugin>
>                <groupId>org.apache.camel</groupId>
>                <artifactId>camel-maven-plugin</artifactId>
>                <version>1.4.0</version>
>            </plugin>
>
> Now I was hoping that someone has already created a baseCamelTestNG class to
> start/stop camel, then helper class to send and receive messages.
>
> Then after the tests have run, the plugin can shutdown.

BTW there's a Camel user list, I've CC'd so other camel users can listen too...
http://activemq.apache.org/camel/discussion-forums.html

The best approach for unit testing and sending & receiving messages is
to use the Spring Testing mechanism which works with JUnit 3.x, 4.x or
TestNG
http://activemq.apache.org/camel/spring-testing.html

for TestNG you might want to derive from AbstractTestNGSpringContextTests see
http://static.springframework.org/spring/docs/2.5.x/reference/testing.html#testcontext-fixture-di

this then does the dependency injection with Spring and runs your test case.

To send messages you can inject a ProducerTemplate; then to receive
messages you can then use the @MessageDriven annotation on a method -
see the examples here
http://activemq.apache.org/camel/bean-integration.html

plus you can then inject mock endpoints for testing as well as described here
http://activemq.apache.org/camel/spring-testing.html
http://activemq.apache.org/camel/mock.html

--
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com



-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com