@Test
public void getsSecurityContextFromServletRequest() throws Exception {

    when(httpServletRequest.getUserPrincipal()).thenReturn(new SimplePrincipal("andrew"));
    when(httpServletRequest.isUserInRole("user")).thenReturn(true);
    when(httpServletRequest.isSecure()).thenReturn(false);
    when(httpServletRequest.getAuthType()).thenReturn("BASIC_AUTH");
    ServletContainerRequest servletContainerRequest = ServletContainerRequest.create(httpServletRequest);
    assertEquals("BASIC_AUTH", servletContainerRequest.getAuthenticationScheme());
    assertEquals("andrew", servletContainerRequest.getUserPrincipal().getName());
    assertFalse(servletContainerRequest.isSecure());
    assertTrue(servletContainerRequest.isUserInRole("user"));
}