@Test
@SuppressWarnings("unchecked")
public void principalUser() {

  MDC.remove("user");
  HttpRequestContext request = Mockito.mock(HttpRequestContext.class);
  Mockito.when(request.getUserPrincipal()).thenReturn(new Principal() {
    @Override
    public String getName() {
      return "bar";
    }
  });
  HttpContext context = Mockito.mock(HttpContext.class);
  Mockito.when(context.getRequest()).thenReturn(request);
  UserProvider up = new UserProvider();
  assertEquals(up.getValue(context).getName(), "bar");
  assertEquals(MDC.get("user"), "bar");
}