How to verify web responses when using Spring and test-mvc
===

A question about how to use test-mvc for unit testing.

I have a simple controller:

    @Controller
    @RequestMapping("/users")
    public class UserController {		 
		private UserService business;
		@Autowired
		public UserController(UserService bus)
		{
			business = bus;
		}
		@RequestMapping(value="{id}", method = RequestMethod.GET)
		public @ResponseBody User getUserById(@PathVariable String id) throws ItemNotFoundException{
 		
			return business.GetUserById(id);
	 
		}

(( My idea is to keep the controllers so thin as possible.))

To test this controller I am trying to do something like this.

    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration(locations = { "classpath:mvc-dispatcher-servlet.xml"})
    public class UserControllerTest extends ControllerTestBase {

	UserService mockedService;
	
	@Before
	public void Setup()
	{
		
		MockitoAnnotations.initMocks( this );	
		mockedService = mock(UserService.class);
	    
	}
		
	@Test
	public void ReturnUserById() throws Exception{
				 
		User user = new User();
		user.setName("Lasse");
		
		stub(mockedService.GetUserById("lasse")).toReturn(user);
	 		
		MockMvcBuilders.standaloneSetup(new UserController(mockedService)).build()
    	.perform(get("/users/lasse"))
        .andExpect(status().isOk())
        .andExpect(?????????????????????????????);
		
	}

My intention is to check that proper json code is returned,,,,,, 

I am not a pro,,, so I have not found a way to replace ??????????????????????? with code to do verify the returned string but I am certain that there must be a elegant way to do this 

Can anyone fill me in?

//lg
