@Test
public void failedConnect() throws XMPPException, InterruptedException, IOException, SmackException {

    XMPPException xmppException = mock(XMPPException.class);
    Mockito.doThrow(xmppException).when(connection).connect();
    
    ModelAndView mav = controller.login(ENTITY, PASSWORD, session);
    
    Mockito.verify(connection).connect();
    
    Assert.assertNull(session.getAttribute(AdminConsoleController.SESSION_ATTRIBUTE));
    Assert.assertEquals("index", mav.getViewName());
    Assert.assertNotNull(mav.getModel().get("error"));
    Assert.assertNull(mav.getModel().get("authenticated"));
}