Testing marshalling is one of those things in jax-rs services that are not easy to test with plain junit tests. For instance, how can you ensure you did not forget an annotation @Path
or @QueryParam
, so that your junit test calling the method succeeds, but actually calling the service fails.
Arquillian provides a solution for those tests. Essentially, Arquillian enables executing tests in a running javaee container. The test setup includes building your war, and deploying your application. This way, you can test all elements of your stack, and make sure all goes together: marshalling, request routing, http filters,...
If you are using the jersey jax-rs stack, you can alternatively use JerseyTest.
Arquillian is more complete, since it enables testing with multiple containers (even selenium support) and does not tie you with a jax-rs implementation.