I'm currently using Spring MVC's HandlerAdapter
to test the annotations of my Spring controller actions to make sure the path variables, request parameters, session attributes, @Valid, etc. are being written correctly.
I've come across a problem where if a controller action has @ResponseBody
and doesn't return a ModelAndView
, I cannot test the response using the HandlerAdapter
.
I found a question on this site that is related, but the accepted answer given is not satisfactory:
How to unit test a ResponseBody or ResponseEntity sent by a spring mvc Controller?
How can I test the annotations and the results at the same time? Or do I need to write two tests - one to test the annotations, and another to call the controller method directly?
Thanks