quinta-feira, 11 de setembro de 2014

ActiveMQ integration testing with Maven

Technology credits:
Apache Maven & Failsafe
Apache ActiveMQ



Disclosure

Before you start reading further: Keep in mind that this is a work in progress, and although i'm a "Systems&Informatics Engineer" i consider myself a novice programmer. If you have any question you don't see answered here, please leave your comment on the section below to help me improve this article.
Also, you should be aware that this post was a result of a lot of work. If you like it, please feel free to show your appreciation by offering me a cup of coffee through paypal and/or add value to this article by sharing your knowledge.

Objectives of this tutorial:

  • Share how to easily start/stop an ActiveMQ broker for integration test purposes using Maven.
Pre-requisites:
  • You have knowledge about the Maven POM and know how to change it. If you need an example base project checkout this.

Problem

If you are developing and need some middleware like ActiveMQ it's always nice to be able to fully automate the start/stop of this kind of software that will be running as a service on a production server. You don't have keep remembering (to others or to yourself) the pre-requisites about how to build a project. The second advantage is that you always start from a clean, predictable state. And the third is that because you can stop whatever software you needed during Integration Tests, you keep your workbench nice and tidy, releasing memory usage and CPU time, allowing you to produce code faster and more efficiently.

Solution - ActiveMQ

If you are using ActiveMQ, the solution is easy, just add the following code in the 'plugins' area of your Maven POM and you are set:

Now just fire 'mvn clean verify' sit back and enjoy the magic ;)

Happy Coding!