Tag Archives: arquillian

Building and testing ADF applications with Maven, JSFUnit, Arquillian and Embedded Glassfish

tomcat

Some time ago I have been playing with Java Server Faces 2.0 (e.g. JSF 2) and JSFUnit in combination with Arquillian and Embedded Glassfish as a Proof Of Concept for unit testing JSF applications.

As our applications are being developped with the Oracle ADF framework, I was wondering if it would be possible to do the same with ADF based applications.  The purpose is to build ADF applications with Maven, which is not that hard, but also test it on an Embedded Glassfish, which is quite challenging.  Once this is working, we could use Jenkins as our continuous integration platform.

The first challenge was to determine the required ADF libraries.  As those libraries are defined as a shared library in Weblogic, I had to determine which where needed to make the ADF application run on Glassfish.  To do this, I added the libraries one by one until the ClassNotFoundExceptions were gone.

Then I made a script (e.g. bat-file) which installs all those libraries in my local Maven repository.  I also made some parent POM’s so I could bundle some related libraries together in a logical way.  I know that the latest JDevelopper has an option to install those ADF libraries in Maven, but I wanted to do it manually.

Once this was done, it was only a matter of configuring Arquillian to deploy the ADF application on the Embedded Glassfish.  As I previously did a POC with JSF 2 and Arquillian, most of the configuration settings where already there for reuse. The main challenge with Arquillian, JSFUnit and Glassfish is combining the corresponding versions of the dependencies to make it all work together.  Also the ADF version that we are using runs on JSF 1.2, while Glassfish ships with version 2, so I googled how I could fix that.  Just add a sun-web.xml-file to make it work (see solution at http://stackoverflow.com/questions/2333330/jsf-1-2-app-not-working-with-glassfish-v3).

The setup of the Maven project consists of 3 sub projects, namely a Model, a ViewController and an ear project. The Model project is for holding the models of course. In this example I added a simple BC4J component.  For the moment, it still connects to a local installed Oracle database (Express Edition).  In the future, I would like to change it to a local embedded Derby database to make the tests totally isolated.  I also have to add some concrete tests to test the BC4J component completely.

The ViewController project holds my managed bean with the JSP-page, the ADF configuration and the page binding files.  The ear project speaks for itself so the main focus will be on the ViewController project, which is of course the most important one.

As I spent quite a few days on it to make it all work, I decided to share this research as I’m sure this could be useful for other ADF/JSF developers.

You can find the complete project on https://github.com/dabla/adf-maven-demo.

Note that the project holds a setup directory.  This directory contains a bat-file which adds the ADF libraries to your local Maven repository and also copies some parent POM-files for grouping purposes.

Tagged , , , , , , , , , ,
Erik Wramner

Tips and tricks

Java Enterprise Development

Java / Oracle SOA blog

Java Enterprise Development