You should use the mvc test framework. It allows you to test all the mvc infrastructure - e.g. the @RequestMapping
, @ResponseBody
etc... - around your controller in addition to your own collaborators.
A very simple example of using the framework would be invoking the getPersons()
method and asserting a 200
response code is received:
...
@Test
public void getPersons() throws Exception {
this.mockMvc.perform(get("/t2/1234/person"))
.andExpect(status().isOk());
}
...
The framework is capable of much more but I urge you to read the documentation, there are plenty of examples included. I hope that helps.