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