Skip to content

Instantly share code, notes, and snippets.

@sirius2k
Created June 6, 2018 12:40
Show Gist options
  • Save sirius2k/1ee07c2ed3c15c3e915c0636e40a3f63 to your computer and use it in GitHub Desktop.
Save sirius2k/1ee07c2ed3c15c3e915c0636e40a3f63 to your computer and use it in GitHub Desktop.
Usage of Hamcrest instanceOf
public void testLogin() throws Exception {
this.mockMvc.perform((post("/login").accept(MediaType.ALL).param("id", "admin").param("password", "admin").with(csrf())))
.andDo(print())
.andExpect(status().is3xxRedirection())
.andExpect(request().sessionAttribute("SPRING_SECURITY_LAST_EXCEPTION", instanceOf(BadCredentialsException.class)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment