Testing with a specific JSF version on Glassfish using HtmlUnit and Maven

In the previous article we described how to do testing with multiple containers. But since joining the Glassfish team I have wondered how can I test applications against different versions of JSF on Glassfish?

As it turns out it is actually quite straightforward. This blog entry shows you how to do it. It will allow you to test using a 2.1.2 version and up. All by using properties passed in on the command line.

Download the zip file and follow along. We are going the use the maven-dependency-plugin to copy the javax.faces.jar into the Glassfish installation we are using for testing.


The above mentioned plugin copies the javax.faces.jar file into the Glassfish modules directory during the package phase. This is well before the integration phase so we are sure we have the JSF runtime we want to use.

By using -Djsf.version=2.1.6 on the commandline you would test against Mojarra version 2.1.6. Note that the POM file also requires you to pass in the Glassfish version you are using. This is a little quirk in how Cargo installs the container. So a complete command line could look very similar to the one below.

    mvn -Dintegration.skip=false -Dintegration.container.skip=false 
        -Dintegration.container.type=existing -Dglassfish.version=3.1.2-b15 
        -Djsf.version=2.1.6 clean verify

I hope you liked this article! Let me know what you think, or if you have any suggestions about other content, or if you just want to drop me a note, feel free to do so :)

Posted January 5, 2012