JAX-RS is a popular JavaEE standard to create RESTful endpoints in Java easily. However, it is not always clear for new learners how to test those endpoints properly.
As JAX-RS is only a standard and is usually used in conjunction with JSON, there are unsurprisingly multiple implementations for those standards available.
Vendor | Library Name | License |
---|---|---|
Apache Foundation |
Apache CXF |
Apache License 2.0 |
Eclipse Foundation |
Eclipse Jersey (reference implementation) |
Eclipse Public License 2.0 |
JBoss by RedHat |
JBoss restEasy |
Apache License 2.0 |
You can also switch the JSON-B and JSON-P implementations. However, both of them can only be switched at the same time.
Vendor | Library Name | License |
---|---|---|
Apache Foundation |
Apache Johnzon |
Apache License 2.0 |
Eclipse Foundation |
Eclipse Yasson (reference implementation) |
Eclipse Public License 2.0 |
Where useful, tests are duplicated to be run on all combinations of implementations.
First we need an endpoint to test.
For this reason, there are the modules web/rest-api
and web/rest-impl
.
Please note that it is often not required to have a separate api project.
This is YAGNI (you ain’t gonna need it) in most cases.
However, separating the API from the implementation allows you (or others) to re-use
the jar file from the API project for the Proxy-based API.
module path | JAX-RS impl | JSON impl |
---|---|---|
|
Apache CXF |
Apache Johnzon |
|
Eclipse Jersey |
Apache Johnzon |
|
Eclipse Jersey |
Eclipse Yasson |
module path | Container/App server |
---|
This project makes use of both the maven-toolchain-plugin to accept IBM Semeru Runtimes for tests and the toolchains-maven-plugin for downloading the JDK first (if required).