I'm trying to get my head around unit testing in Jersey.
The classes that do not depend on Jersey directly can be unit tested using standard JUnit. This one is OK.
But there are also Jersey (or, should I say JAX-RS?) dependent classes. In order to test these (inlc. correctness of the annotations, serialization, status codes, etc.) Jersey provides "test framework" that contains base JerseyTest
class.
This is also fine and understandable.
Then, however, the official documentation specifies several types of supported containers in which subclasses of JerseyTest
can be executed.
It seems like these containers can be divided into two types:
- Real containers
- In-memory container
From my current (newbie) perspective, all type #1 containers provide the same functionality. Therefore, let's take Grizzly as type #1 representative.
Now, it is clear that in-memory container (which is not a real container at all) is faster than Grizzly. Therefore, I'd like to use this container in order to test Jersey dependent classes. But this statement from the official documentation confuses me:
This containers does not support servlet and other container dependent features, but it is a perfect choice for simple unit tests.
I tried to google for comparison of in-memory container with Grizzly, but did not find any definitive comparison. I also read this highly technical thread, but the downsides of in-memory container are still not clear to me.
In this respect, I have two questions:
- What "servlet and other container dependent features" are (no need for a comprehensive list, but just general description)?
- If I choose in-memory container, can I then encounter a situation of code that passes test, but fails in production (I will use Tomcat in production, if that matters)?
Thanks