1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-01 01:35:59 +01:00

Retry to delete integration test accounts

in the the connection was terminated because of an error, try to
re-establish the connection when trying to delete the account.
This commit is contained in:
Florian Schmaus 2015-04-22 09:22:57 +02:00
parent f274581c27
commit bfb3f5cd95

View file

@ -466,11 +466,27 @@ public class SmackIntegrationTestFramework {
} }
protected void disconnectAndMaybeDelete(XMPPTCPConnection connection) protected void disconnectAndMaybeDelete(XMPPTCPConnection connection)
throws NoResponseException, XMPPErrorException, NotConnectedException, throws InterruptedException, XMPPException, SmackException, IOException {
InterruptedException {
if (config.registerAccounts) { if (config.registerAccounts) {
final int maxAttempts = 3;
AccountManager am = AccountManager.getInstance(connection); AccountManager am = AccountManager.getInstance(connection);
int attempts;
for (attempts = 0; attempts < maxAttempts; attempts++) {
try {
am.deleteAccount(); am.deleteAccount();
} catch (NoResponseException | InterruptedException e) {
LOGGER.log(Level.WARNING, "Exception deleting account" , e);
continue;
} catch (NotConnectedException e) {
LOGGER.log(Level.WARNING, "Exception deleting account" , e);
connection.connect().login();
continue;
}
break;
}
if (attempts > maxAttempts) {
LOGGER.log(Level.SEVERE, "Could not delete account for connection: " + connection);
}
} }
connection.disconnect(); connection.disconnect();
} }