简体   繁体   中英

What's the difference between the different Jersey test containers?

According to http://jersey.java.net/nonav/apidocs/latest/jersey/jersey-test-framework/jersey-test-framework-core/com/sun/jersey/test/framework/JerseyTest.html users may choose between two kinds of test containers:

  1. Low-level container that does not support servlets
  2. Web-based container that does support servlets

I have the following questions:

  1. What's the advantage/disadvantage of each kind of container? For example, I assume low-level containers are faster but are missing some sort of functionality.
  2. What is meant by the fact that low-level containers do not support servlets? I thought that JAX-RS is based on top of Servlets. What aren't low-level containers able to do?

UPDATE :

Upon further research I discovered that low-level containers are faster but they really run without servlets. When clients make requests,a the appropriate Resources are constructed and the response is passed back to the client, all in-memory. This is similar to running an embedded database versus a conventional network-based JDBC connection.

There is no mechanism to supply a ServletContextListener, register servlets or filters. I'm guessing the request scope isn't supported either.

My question is, can you really test anything meaningful under these restrictions?

"... can you really test anything meaningful under these restrictions..."

You can test your business logic, and do it quicker.

(Would like to see this fixed though: JERSEY-622 . The in-memory test container doesn't support Jackson, ie the POJO-mapping feature of Jersey.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM