I have simple integration test
@Test
public void shouldReturnErrorMessageToAdminWhenCreatingUserWithUsedUserName()
Spring security's @WithMockUser and hamcrest's containsString matcher makes for a simple and elegant solution:
@Test
@WithMockUser(roles = "USER")
public void loginWithRoleUserThenExpectUserSpecificContent() throws Exception {
mockMvc.perform(get("/index"))
.andExpect(status().isOk())
.andExpect(content().string(containsString("This content is only shown to users.")));
}
More examples on github