use of org.springframework.test.context.TestContext in project spring-security by spring-projects.
the class WithSecurityContextTestExcecutionListenerTests method handlesGenericAnnotation.
@Test
public // gh-3837
void handlesGenericAnnotation() throws Exception {
Method method = ReflectionUtils.findMethod(WithSecurityContextTestExcecutionListenerTests.class, "handlesGenericAnnotationTestMethod");
TestContext testContext = mock(TestContext.class);
when(testContext.getTestMethod()).thenReturn(method);
when(testContext.getApplicationContext()).thenThrow(new IllegalStateException(""));
this.listener.beforeTestMethod(testContext);
assertThat(SecurityContextHolder.getContext().getAuthentication().getPrincipal()).isInstanceOf(WithSuperClassWithSecurityContext.class);
}
Aggregations