@Test
public void userAuthenticationFails() throws Exception {
final String username = "user";
mockMvc.perform(post("/j_spring_security_check").param("j_username", username).param("j_password", "invalid"))
.andExpect(redirectedUrl("/signin?error=1"))
.andExpect(new ResultMatcher() {
public void match(MvcResult mvcResult) throws Exception {
HttpSession session = mvcResult.getRequest().getSession();
SecurityContext securityContext = (SecurityContext) session.getAttribute(SEC_CONTEXT_ATTR);
Assert.assertNull(securityContext);
}