Can I use Spring MockMvc with Jersey resources?

I have successfully integrated Spring and Jersey with Spring Boot 'start POM servers, and I have several Jersey endpoints. Now I would like to unit test resources. I cannot get MockMvc to work. I get a 404 error when trying to get the resource endpoint.

I know there is a Jersey test environment there, but it seems to start the server. I hope to avoid integration tests and keep it as simple as possible. Can I do this with MockMvc?

+4
source share
1 answer

Unfortunately, this is not possible, since MockMvc does not actually start the servlet container .

you can use

  • RestTemplateto start server requests running on localhost. The following are examples from the Spring Boot repo: Example 1 and Example 2 .
  • Restored
+4
source

Source: https://habr.com/ru/post/1623170/


All Articles