SubjectHttpRequestWrapper extends HttpServletRequestWrapper { @Override public Principal getUserPrincipal() { return principal; } SubjectHttpRequestWrapper(HttpServletRequest request, Subject subject); @Override String getRemoteUser(); @Override Principal getUserPrincipal();  }
@Test public void shouldConstructPrincipalFromSubject() { Principal principal = subjectHttpRequestWrapper.getUserPrincipal(); assertEquals(principal.getName(), userName); verify(subject).getUserName(); verifyNoMoreInteractions(subject); }