I am trying to test the security configuration of some of my endpoints which are secured with @PreAuthorize(#oauth2.hasScope(\'scope\'). When acces
I had a similar case and suppressed the NestedServletException by using
@Test(expected = NestedServletException.class) and then I was able to get hold of the MvcResult and do further asserts on it as in other tests like:
// then
MvcResult result = resultActions.andExpect(status().isServiceUnavailable()).andReturn();
String message = result.getResponse().getContentAsString();
assertThat(message).contains("ABC");
assertThat(result.getResolvedException().getClass()).isEqualTo(XYZ.class);
It seemed to work.