InstantMessagingModule.getAdapter().deleteAccount(testUserA);
InstantMessagingModule.getAdapter().deleteAccount(testUserB);
InstantMessagingModule.getAdapter().deleteAccount(testUserC);
im.deleteRosterGroup(groupId);
Authentication authC = ManagerFactory.getManager().findAuthenticationByAuthusername(testUserC, ClientManager.PROVIDER_INSTANT_MESSAGING);
if(authC != null) ManagerFactory.getManager().deleteAuthentication(authC);
DBFactory.getInstance().intermediateCommit();
InstantMessagingClient imClientC = InstantMessagingModule.getAdapter().getClientManager().getInstantMessagingClient(testUserC);
//wait some time as connection process is in background thread
Thread.sleep(3000);
assertTrue(imClientC.isConnected());
imClientC.closeConnection(true);
assertTrue(InstantMessagingModule.getAdapter().deleteAccount(testUserC));
//delete IM passwords, otherwise accounts don't get created
Authentication authA = ManagerFactory.getManager().findAuthenticationByAuthusername(testUserA, ClientManager.PROVIDER_INSTANT_MESSAGING);
Authentication authB = ManagerFactory.getManager().findAuthenticationByAuthusername(testUserB, ClientManager.PROVIDER_INSTANT_MESSAGING);
if(authA != null) ManagerFactory.getManager().deleteAuthentication(authA);
if(authB != null) ManagerFactory.getManager().deleteAuthentication(authB);
//get the IM client, it connects automatically to the server (creates an account on the im server)