15

I have successfully integrated Spring and Jersey via Spring Boot' starter POMs, and I have a couple Jersey endpoints. Now I'd like to unit test the resources. I can't seem to get MockMvc working. I get a 404 error when attempting to GET a resource endpoint.

I know there is a Jersey test framework out there, but it appears to launch a server. I'm hoping to avoid "integration" type tests and keep this as simple as possible. Can I do this with MockMvc?

luboskrnac
  • 23,973
  • 10
  • 81
  • 92
John O'Conner
  • 465
  • 1
  • 6
  • 14

1 Answers1

11

Unfortunately doesn't seem to be possible as MockMvc doesn't actually start servlet container.

You can use

  1. RestTemplate to fire requests against server started on localhost. Here are examples from Spring Boot repo: Example 1 and Example 2.
  2. Rest Assured library
luboskrnac
  • 23,973
  • 10
  • 81
  • 92