@Test
public void testLoginLockedAccount() throws Exception {

    try {
        lockAccount("jad");
        // Set up the request
        LoginCredentials credentials = new LoginCredentials("jad", "wrong");
        HttpServletRequest request = buildLoginRequest(credentials);
        HttpServletResponse response = mock(HttpServletResponse.class);
        // Create mock OSGi services to inject
        MockLogService logservice = new MockLogService();
        // Create the servlet and do the login
        Login resource = new Login();
        resource.logservice = logservice;
        createSubjectAndBindItToThread(request, response);
        LoginResult result = resource.doLogin(credentials);
        // Check the response
        assertEquals(0, result.getRoles().length);
        assertEquals("Locked account", result.getErrorMessage());
    } finally {
        unlockAccount("jad");
    }
}