BeJUG: Incremental Enterprise Application Development with JBoss Forge and Arquillian

30 Nov 2012    

Yesterday, I attended a BeJUG event on JBoss Forge and Arquillian. I heard some good things about Arquillian, so I was eager to learn more about it. The nice thing about Java User Groups is that they present the opportunity to learn about new technology in a short amount of time. In that regard, I would really encourage developers to join a local JUG.

JBoss Forge

JBoss Forge is a framework/shell that attempts to simplify the setup of the JEE stack and takes care of the gotchas (configuration files, dependencies, ..). JBoss Forge also offers a “plugin platform” to extend its initial possibilities. A list of existing plugins can be found here. Forge is part of JBoss Tools, that integrates nicely with Eclipse. Forge creates Maven projects, but goes beyond Maven archetyping by UI Scaffolding. Forge’s scaffoling results in a pure JEE6 application with a CRUD User Interface in JSF.This UI includes support for creating, updating, deleting, pagination and searching. It also supports one-to-many, many-to-many, many-to-one and one-to-one relationships. Another interesting use case was generating JAX-RS Endpoints for data Entities. This was, by far, the easiest way I saw to generate RESTful webservices. The Forge shell also makes it possible to add dependencies to a Maven POM, but I don’t see how this is easier then writing them by hand.

Having learned about the possibilities of JBoss Forge, I wondered what the actual differences with Spring Roo were. Both help with setting up a new project and both have the ability to generate code. Both also make UI scaffolding possible. Of course Spring Roo works with Spring MVC, while JBoss Forge focuses on the JEE6 stack and thus generates JSF. I did notice a Spring MVC plugin for JBoss Forge. There are quite a lot of articles on these tools on the web, but from what I’ve read so far it comes down to the old question: Spring or JEE?

Another point of interest to me was the support for other web frameworks, such as Wicket as that’s what I’m using in my current (daytime) project. A Spring Roo addon exists that generates a Wicket CRUD UI. I haven’t found a plugin for JBoss Forge.

JBoss Arquillian

Arquillian is a testing platform that allows in-container testing. By integrating with middleware the need for mocking objects disappears. Arquillian uses Shrinkwrap to package  unit tests and deploys this packaged archive to a Application Server/Webcontainer. The idea is writing unit tests and test them in a "real" environment. When a unit test is started with Arquillian, Arquillian:
  • Starts a new container or selects a running container
  • Packages the unit test + deploys it (= micro-deployments)
  • Runs the unit test
  • Captures the results
  • Undeploys the package and disconnects from the container
Arquillian promises less boilerplate code, but also introduces new boilerplate to allow a micro-deployment:
    @Deployment
    public static Archive createDeployment() {
        return ShrinkWrap.create(WebArchive.class, "test.war")
            .addPackage(Game.class.getPackage())
            .addAsResource("test-persistence.xml", "META-INF/persistence.xml")
            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
    }

Arquillian also makes it possible to execute the same unit tests for multiple target environments. In certain situations, Arquillian really might come in handy. Arquillian also has an extension called Drone, that brings Selenium to Arquillian to allow UI tests.