Hi there,
I have just updated to Spring 3.1 and got some NPEs in my controllers tests (stacktrace below).
In my workaround, I just set the needed request attribute as the DefaultAnnotationHandlerMapping would do in my preconditions for the test, because I use some code like
Code://setup preconditions ModelAndView mv = new AnnotationMethodHandlerAdapter().handle(request, response, controller); //do the asserts with the model and view
so my question:
Is there a better/other way to test controllers or should the AnnotationMethodHandlerAdapter be more robust to handle request without this attribute??
java.lang.NullPointerException
at org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter$ServletHandlerMethodRe solver.useTypeLevelMapping(AnnotationMethodHandler Adapter.java:675)
at org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter$ServletHandlerMethodRe solver.resolveHandlerMethod(AnnotationMethodHandle rAdapter.java:585)
at org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter.invokeHandlerMethod(An notationMethodHandlerAdapter.java:431)
at org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter.handle(AnnotationMetho dHandlerAdapter.java:424)


Reply With Quote