Links: Table of Contents | Single HTML

Chapter 17. Building and Testing Jersey

17.1. Checking Out the Source

Jersey source code is available in a Git repository you can browse at http://java.net/projects/jersey/sources/code/show.

In case you are not familiar with Git, we recommend reading on of the many "Getting Started with Git" articles you can find on the web. For example this DZone RefCard.

Before you can clone Jersey repository you have to sign up for a java.net account. Once you are registered, you have to add an SSH key to your java.net profile - see this article on how to do that: http://java.net/projects/help/pages/ProfileSettings#SSH_Keys_Tab

To clone the Jersey repository you can execute the following command on the command-line (provided you have a command-line Git client installed on your machine):

git clone ssh://<your_java_net_id>@java.net/jersey~code

Milestones and releases of Jersey are tagged. You can list the tags by executing the standard Git command in the repository directory:

git tag -l

17.2. Building the Source

Jersey source code requires Java SE 6 or greater. The build is based on Maven. Maven 3 or greater is recommended. Also it is recommended you use the following Maven options when building the workspace (can be set in MAVENT_OPTS environment variable):

-Xmx1048m -XX:PermSize=64M -XX:MaxPermSize=128M

It is recommended to build all of Jersey after you cloned the source code repository. To do that execute the following commands in the directory where jersey source repository was cloned (typically the directory named "jersey~code"):

mvn -Dmaven.test.skip=true clean install

This command will build Jersey, but skip the test execution. If you don't want to skip the tests, execute the following instead:

mvn clean install

Building the whole Jersey project including tests could take significant amount of time.

17.3. Testing

Jersey contains many tests. Unit tests are in the individual Jersey modules, integration and end-to-end tests are in jersey~code/tests directory. You can run tests related to a particular area using the following command:

mvn -Dtest=<pattern> test

where pattern may be a comma separated set of names matching tests.

17.4. Using NetBeans

NetBeans IDE has excellent maven support. The Jersey maven modules can be loaded, built and tested in NetBeans without any additional NetBeans-specific project files.