@Test
public void testLoginWithAuthenticationException() {

    createSubjectThrowingExceptionAndBindItToThread(AuthenticationException.class);
    LoginCredentials credentials = new LoginCredentials("jad", "wrong");
    // Create mock OSGi services to inject
    MockLogService logservice = new MockLogService();
    // Create the servlet and do the login
    Login resource = new Login();
    resource.logservice = logservice;
    LoginResult result = resource.doLogin(credentials);
    // Check the response
    assertEquals(0, result.getRoles().length);
    assertEquals("Unknown error", result.getErrorMessage());
}