Links: Table of Contents | Single HTML

Chapter 29. Building and Testing Jersey

29.1. Checking Out the Source

Jersey source code is available on GitHub. You can browse the sources at https://github.com/eclipse-ee4j/jersey.

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

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 git://github.com/eclipse-ee4j/jersey.git

This creates read-only copy of Jersey workspace. If you want to contribute, please use "pull request": https://help.github.com/articles/creating-a-pull-request.

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

or by visiting https://github.com/eclipse-ee4j/jersey/tags.

29.2. Building the Source

Jersey source code requires Java SE 8 or higher. Support of Jetty HTTP container/client requires JDK 11+. The build is based on Maven. Maven 3.6.3 or higher is highly recommended. Also it is recommended you use the following Maven options when building the workspace (can be set in MAVEN_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"):

mvn -Dmaven.test.skip=true -DskipTests 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.

29.3. Testing

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

mvn -Dtest=<pattern> test -pl :[modulename]

where pattern may be a comma separated set of names matching tests classes or individual methods (like LinkTest#testDelimiters) and [modulename] is name of a module from which tests are called. If module does not contain those tests build failure (as no tests run) occurs.

29.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.