dimanche 19 janvier 2014

Camel and (JBoss) WildFly 8.x Integration Testing with Arquillian

It's been a while since I've written anything... Furthermore, it's the first time I write a post in English. So, I'm really sorry for my speech. It's a well-known fact that French people have a catastrophic level foreign language :) So, let's go...

In recent years, a lot of tech have evolved, practices too... In particular, I had the chance to implement a number of agile practices, including TDD a.k.a. Test-Driven Development. TDD is not an easy stuff when you have to create an application implementing databases, mail server and others IT resources, such as legacy systems... because in that event, mocking objects does not really make sense... Furthermore, legacy systems can be integrated by using an EAI, ESB or lightweight integration frameworks. Some of them are very popular like Spring Integration and Apache Camel. But when you have to embed a such framework in an Application Server (JBoss or Glassfish for instance), you may believe things do not go as planned.

Contrary to what you might think, I found this was not as difficult. I wrote a sample that you should checkout on my Github. You can view the code at https://github.com/sydisnet/blog-samples/tree/master/camel-integration.

I hope this can help... This sample embeds a Camel container whose lifecycle is managed by a Singleton EJB. When the singleton starts, a CamelContext is created with a Camel Route connected to an external application. For the purpose of this Use Case, I used Camel Exec Component and Arquillian with WildFly 8.0.0.CR1.

The test is very easy (thanks to Arquillian - my favorite framework this last years). It shows how to create a @Deployment static archive, downloads Camel libs from pom.xml.

Last but not least, don't forget to check your Wildfly Home location in arquillian.xml file.

Have fun :)