JBoss Forge – Speedup your enterprise development – Part III Integration Tests with Arquillian

Take your skills to the next level!

The Persistence Hub is the place to be for every Java developer. It gives you access to all my premium video courses, 2 monthly Q&A calls, monthly coding challenges, a community of like-minded developers, and regular expert sessions.

In this third part of the JBoss Forge series, I will show you how to search and install plugins to extend the JBoss Forge functionality. After that we will use Forge to setup Arquillian and create an integration test for our webservice. If you are new to this series, make sure to check the first two parts. In the first part, we installed JBoss Tools to get JBoss Forge eclipse integration. Then we created a Java EE project with the entities Book and Author and generated a web interface based on these entities. In the second part, we created a RESTful webservice API for our entities.

Install Plugins

Forge provides several plugins to extend its functionality. Today, we will install the Arquillian plugin which we will use for integration testing. We can use the forge find-plugin test command to get a list of all test related plugins in the  Central Plugin Index (CPI). Forge found five different plugins, hosted in github repositories. We install the arquillian plugin by Paul Bakker. This can be done by calling the forge install-plugin command and passing the name of the plugin: JBoss Forge will download the source code and build the plugin during the installation process.

Setup Arquillian

OK, now we can start with our real work for today. We use the Arquillian Forge Plugin to add the required dependencies to our maven configuration. In the past we would have used another project or the Arquillian Getting Started guide to copy the required maven configuration. With JBoss Forge this is much easier and faster. We just need to setup the Arquillian Forge Plugin and decide which container and container type we want to use. We used JBoss AS 7.1.1 to run our application in part one and two. So we use a JBoss AS7 remote container during the integration tests. After that we need to provide the versions of Arquillian, JUnit and the JBoss AS 7 Arquillian plugin. I selected the latest versions of Arquillian and JUnit and the server plugin for JBoss AS 7.1.1: As you can see in the console output, Forge updated the pom.xml and created the arquillian.xml file for us. If you want to test your application with more than one application server, execute the arquillian setup command again and provide the requested parameter.

Write some tests

After setting up the maven configuration, we can also use Forge to speedup the implementation of the integration tests. The arquillian create-test command generates a test class for the given class, adds the required annotation and provides a first implementation of the ShrinkWrap Deployment. The –enableJPA parameter will add the persistence.xml file to the ShrinkWrap deployment: The generated source code of our test class looks like this: As you can see, JBoss Forge injects the class under test, implements a method to create the ShrinkWrap deployment and adds a test method to test the injection. This looks like a nice start to implement our integration tests. But the ShrinkWrap deployment will fail because the list of added classes is incomplete. We need to add the classes Author and Book to the deployment because they are used by the AuthorEndpoint: OK, now we can run our tests with the test command and check if everything is setup correctly. When starting the integration tests, we need to specify the profile which shall be used. The deployment test was successful and we can implement our real test. As you can see below, I implemented a test of the create() method of the AuthorEndpoint. The implementation of an integration test is simple and straight forward.

Eclipse Integration

Executing the integration tests in the JBossForge console is fine, but I also want to do this in my eclipse. This is no problem. We just need to select the maven profile we want to use and we can run our tests in eclipse.


After creating our project in the first and second part, we added Arquillian to our project and implemented an integration test. And again JBossForge took over the annoying parts of the job like configuring maven and creating the initial test classes. I like this much more than copying or trying to remember the required maven configuration. And it’s much faster! What do you think? We also used the plugin mechanism to extend the JBossForge functionality. There are lots of plugins and as you saw at the beginning of this article, it’s fast and easy to add them to your Forge setup. If you need something special, you can implement your own plugin. We will do this in one of the upcoming articles about JBossForge. What do you think about JBossForge? Do you have any experience using it for your test or real projects? Please write a comment and tell me about it!




JBossForge Series

Related Articles


Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  1. Thank you Ronny!

    I think Arquillian is a great framework and a good option to improve the development cycle. For me it feels great to write tests with Arquillian.
    The main benefit of using JBossForge is, that it is easier to use Arquillian. So it's the same as in the first two articles. JBossForge makes it easy to use existing technologies and frameworks 🙂

  2. Is it possible that this is now the end of the nasty write-code, build, deploy, wait-a-while, click-and-enter-some-nasty-things (booooooring!), fix-bugs, re-build, re-deploy… never ending development cycle? I for myself put a lot of hope in both tools. But let's see how it proves in the hard daily practice.

    However, another great article! Thank you very much!

    BTW: Just for completeness. You missed a link to some more of this great stuff: https://github.com/arquillian/continuous-enterprise-development