Closed avp closed 10 years ago
@aakpat6: See this StackOverflow link: http://stackoverflow.com/questions/20978535/testing-spring-mvc-router-with-mockmvc/20987253#20987253
I believe there is an issue with the HTTPRequestAdapter
class. Namely, line 193 tests to see whether request.host
has a :
. However, there is a possibility that httpServletRequest.getHeader("host")
returns null
, if the request did not contain any host
header.
If the request does not contain a host
header, a NullPointerException
will be thrown (which is what caused @aakpat6's tests to fail). The method should handle this case more gracefully.
I'm trying to test my Spring MVC webapp with Spring test. It uses springmvc-router for routing and that appears to break the tests, which work fine when I use
@RequestMapping
instead of myroutes.conf
file.I have a
.jsp
file calledvalid.jsp
, and it displays fine when I run the development site from Jetty. The controller is:My
routes.conf
file mapsGET /valid authController.valid
.Now, my tester looks like
When the
mockMvc.perform()
is run, a NullPointerException is thrown:So the question is: is it possible to use Spring's test framework with springmvc-router?