AVIO Consulting

Configure Maven ADF Integration Testing

Jun 25, 2016 | General


The ability to add ADF-BC JUnit Tests has been available since 11g and they worked nicely out-of-the-box within JDeveloper as well as in batch via Ant tasks.  Maven support was added in 12c (12.1.3) and running them in Maven, as of this writing, requires that a small number of adjustments be made to the JDeveloper Model project POM.   

Separate The Model Project Source Folders

Use of Maven convention over configuration would prescribe the use of certain folder structures for the source code in the ADF Model project. According to Maven convention the project java source code would resides in src/main/java while the JUnit tests would reside in src/test/java. The Maven build phases default to these source code locations and having them elsewhere requires POM customization. It is likely if you have created your project already that you may not have followed this convention.

In the case provided here, the project was refactored to use the default Maven source directory structures. This was relatively easy to do as the ADF-BC JUnit tests had not yet been created. The original source code for the ADF-BC Model was moved into the src/main/java folder (recognizing that a small percentage of the files are in fact Java). This allowed the JUnit tests added to the project via a Gallery Wizard to be created in the project in the src/test/java folder. The Maven phases to build the project Java and tests were then separated nicely and does not require any modifications to the project POM to implement the source path locations for each.

Define Source Code Folders

Before you add the JUnit tests to the Model project there should be two source folders defined in the Model project. Before you run the Gallery wizard to create the ADF-BC JUnit Suite you must move the src/test/java folder to the 1st source folder locations as this is where the Wizard will create them.

Define Source Folders
Define Source Folders in JDeveloper


Create JUnit Tests

After setting the source test directory to the number #1 position the tests will be propagated to the src/test/java directory. If you discover there are view object tests classes missing (because the class that runs them all will complain), then run the Wizard again as a workaround (hopefully this has been corrected in 12.2.1). Before re-running the Wizard make sure the src/test/java directory is still positioned as the first source directory as JDeveloper likes to swap them back.

Modify Model Project POM

The Maven POM will need several adjustments, to rerence the default Apache JUnit classes rather than the Oracle ADF Library version of it which at present is missing and to modify the surefire plugin to add various paths to the test phase classpath.

Remove Generated JUnit Dependencies

Remove the two generated dependencies for JUnit from the POM. Samples of the two to be removed are shown below.


Add Apache JUnit Dependency

In place of the two JUnit dependencies deleted in the previous step add the following which will be downloaded from Maven Central and added to your local repository.


Add surefire Plugin

The generated POM for a Model project that is to run JUnit must necessarily include the surefire plugin. The plugin must also include configuration properties that add several key paths into the Java classpath when the tests are to be run. The first is the ADF application’s .adf folder which contains the connections.xml. The second addition is to avoid a ClassDefNotFoundException that would occurs without also including the jps-manifest.jar.



From a Continuous Delivery perspective, these are considered online unit tests to be run in the Integration Test phase, as a database connection is required. To create true offline unit tests it would be necessary to use a tool like DBUnit and an in-memory database like H2.