Using Spring MVC, you can specify that a specific URL will be processed by a specific method, and you can specify that specific parameters will be mapped to specific arguments, for example:
@Controller public class ImageController { @RequestMapping("/getImage") public String getImage( @RequestParam("imageId") int imageId, Map<String,Object> model ) { model.put("image",ImageService.getImage(imageId)); } }
This is good and good, but now I want to check that the HTTP request with the imageId parameter will call this method correctly. In other words, I want a test that breaks if I delete or modify any annotations. Is there any way to do this?
It is easy to verify that getImage is working correctly. I could just create an ImageController and call getImage with the appropriate arguments. However, this is only half the test. The other half of the test should be whether getImage () will be called by the Spring framework when the corresponding HTTP request arrives. I feel that I also need a test for this part, especially since my @RequestMapping annotations become more complex and cause complex parameter parameters.
Could you show me a test that will break if I delete line 4, @RequestMapping("getImage") ?
java spring spring-mvc
Brandon Yarbrough May 14 '09 at 12:41 a.m. 2009-05-14 00:41
source share