A JBoss Project
Red Hat
JSF Unit

JSF Unit

Dedicated to JSF Testing.

Building JSFUnit with Maven 2

The JSFUnit project uses Maven 2 for its build. This document explains how to build JSFUnit Core, build the examples for your servlet container, and run the JSFUnit tests against the examples.

First, you will need to checkout the source from SVN.

Building JSFUnit and Examples

To build JSFUnit,you must use JDK 1.6. The source level and compilation target are both set to JDK 1.5. However, because of a bug in the JDK 1.5 compiler, you must use JDK 1.6 to compile.

JSFUnit runs on any servlet platform that supports JSF 1.1, JSF 1.2, or JSF 2.0. The build contains many unit tests that can be automatically run against a variety of platforms.

If you build from the JSFUnit trunk then you will build all of the JSFUnit modules, including the examples that are used to run the unit tests and integration tests. Each example needs to be properly assembled for for a specific container. So each container requires certain profiles to be set during the Maven build. Except for Jetty, these containers also require that an environment variable is set for the container's home. Here are the containers and the command to build for each:

Container Environment Variable Setting Maven Build Command Build and Run Tests
Jetty 6 none $ mvn -Pmyfaces1.1 $ mvn -Ptest,myfaces1.1
Tomcat 5 CATALINA_HOME $ mvn -Pmyfaces1.1,tomcat5x $ mvn -Ptest,myfaces1.1,tomcat5x
Tomcat 6 CATALINA_HOME $ mvn -Pmojarra1.2,tomcat6x $ mvn -Ptest,mojarra1.2,tomcat6x
JBoss AS 4.0.x JBOSS_HOME $ mvn -Pjboss4.0 $ mvn -Ptest,jboss4.0
JBoss AS 4.2.x JBOSS_HOME $ mvn -Pjee5,jboss4.2 $ mvn -Ptest,jee5,jboss4.2
JBoss AS 5.x JBOSS_HOME $ mvn -Pjee5,jboss5x $ mvn -Ptest,jee5,jboss5x
JBoss AS 6.x JBOSS_HOME $ mvn -Pjboss6x $mvn -Pjee6,jboss6x

*Note that you should not use the test profile with JBoss 6x.

Setting the Container Home

You can set the CATALINA_HOME or JBOSS_HOME any way you like, but if you plan to run the JSFUnit test suite against more than one container, it is convenient to tie the HOME setting to a profile in your Maven settings.xml file.

	

 <?xml version="1.0" encoding="UTF-8"?>
 <settings>
    <profiles>
      <profile>
        <id>jboss5x</id>
        <properties>
          <JBOSS_HOME>/jboss-5.0.0.GA</JBOSS_HOME>
        </properties>
      </profile>

      <profile>
        <id>tomcat5x</id>
        <properties>
          <CATALINA_HOME>/apache-tomcat-5.5.26</CATALINA_HOME>
        </properties>
      </profile>

      <profile>
        <id>tomcat6x</id>
        <properties>
          <CATALINA_HOME>/apache-tomcat-6.0.16</CATALINA_HOME>
        </properties>
      </profile>
    </profiles>
  </settings>


Setting Compiler Options

If you run the tests from the project root you will find that the container is started and stopped several times and lots of threads are created and destroyed. This can use up system resources. So, in addition to using JDK 1.6, you may find that the following compiler options are needed. To set these compiler optioins, just set the MAVEN_OPTS environment variable as follows:

 MAVEN_OPTS=-XX:MaxPermSize=256m -Xss128k -Xmx1024m

 

Special note for JBoss AS 4.0.x

JBoss AS 4.0.x uses an old version of MyFaces that requires a listener to be declared in web.xml. As is, some of the tests will not pass under JBoss AS 4.0.x unless you add the following to the web.xml file.

	

 <listener>
   <listener-class>
     org.apache.myfaces.webapp.StartupServletContextListener
   </listener-class>
 </listener>