Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a mechanism for integration testing JAX-RS services without deploying (a la MockMVC)?

I have successfully built no-deployment-needed integration test frameworks for Spring MVC REST services using Mock MVC. I am struggling to do the same with JAX-RS services.

REST Assured looks promising, but it seems to require deployment. The test suite can start up a CXF server, but can it wire it up with a servlet container?

It seems that the unique value provided by Mock MVC is in its mock servlet container. Does any other technology provide this.

The JAX-RS testing page of the CXF documentation provides a pattern for injecting a mock HttpServletRequest into a CXF invoker. Which got me thinking ...

Spring MVC's mock servlet elements (MockHttpServletRequest, etc.) come from the spring-test module, is independent of Mock MVC. Would we be able to inject these objects into a CXF invoker? Or will this be a rabbit hole?

Has anyone come up with a solution to this problem?


.

like image 921
Daniel Steinberg Avatar asked Oct 17 '22 10:10

Daniel Steinberg


1 Answers

Daniel - I'm the developer of Karate and something I've been experimenting with is to use a combination of Mockito and the Spring mocks for the HTTPServletRe**** to call a servlet directly and avoid having to boot an app-server.

Since Karate has this swappable abstraction of an http-client, I was thinking of adding this option in the near future.

Just sharing in case it helps you with ideas, or if you want to compare notes. Feel free to open a thread on GitHub.

Update: I made very good progress on this - please look at this thread for a working example.

like image 155
Peter Thomas Avatar answered Oct 21 '22 03:10

Peter Thomas