Hi all,
I am currently using the Spring Web MVC in a project. This is my first project using this technology and I am responsible for unit and integration testing. I am confused about how to test my Controllers when I use the annotation stuff.
There is a controller called UserController. (Sorry I cant use the AT-sign in the forum, yet)
There are also some more methods. Now I want to write a test case for the function createGet.Code:ATController ATSessionAttributes("user") public class UserController{ private final UserService userService; ATAutowired public UserController(UserService userService) { this.userService = userService; } ATRequestMapping(value = "create", method = RequestMethod.GET) public ModelMap createGet() throws Exception { return (new ModelMap()).addAttribute("user", new User()); } ... }
My problem is, I don't know how to implement my tests. In some examples people called a method called controller.handleRequest(..) but where is no such method in my case. My Controller does not extend any class where itCode:public class UserServiceTest{ ATTest public void testmethod(){ //Test me } }
may get this method (maybe injected at runtime because ATController annotation).
I am sure that I can test the method createGet() directly, for example calling it and examining the received ModelMap but how can I check that the rest of the ModelAndView did NOT change? I only got the ModelMap back but I don't know the actual ModelAndView. I am confusedAre there any good tutorials that cover this? I only found trivial examples.
Cheers,
Daniel (a bloody spring noob)


Are there any good tutorials that cover this? I only found trivial examples.
Reply With Quote
