@Test
public void testGetLoginStateWhenLoggedIn() throws Exception {

    // Set up the request
    HttpSession session = mock(HttpSession.class);
    HttpServletRequest request = mock(HttpServletRequest.class);
    when(request.getSession()).thenReturn(session);
    HttpServletResponse response = mock(HttpServletResponse.class);
    // Create mock OSGi services to inject
    MockLogService logservice = new MockLogService();
    // Set up Shiro to be in a logged-in state
    WebSubject subject = createSubjectAndBindItToThread(request, response);
    UsernamePasswordToken token = new UsernamePasswordToken("jad", "1ad".toCharArray(), true);
    subject.login(token);
    // Create the resource and check the login state with HTTP GET
    Login resource = new Login();
    resource.logservice = logservice;
    LoginResult result = resource.loginStatus();
    // Check the response
    assertThat(result.getRoles()).isNotEmpty();
    assertEquals("", result.getErrorMessage());
}