ServletSecurityAuthenticationService extends GroupAdapterAuthorizationSource implements AuthenticationService { @Override public boolean isLoggedIn() { HttpServletRequest request = getRequestForThread(); return request.getUserPrincipal() != null; } ServletSecurityAuthenticationService(); @Override User login(String username,
                      String password); @Override boolean isLoggedIn(); @Override void logout(); @Override User getUser();  }
@Test public void testLoggedIn() { assertTrue(tested.isLoggedIn()); }
@Test public void testNotLoggedIn() { doReturn(null).when(request).getUserPrincipal(); assertFalse(tested.isLoggedIn()); }