1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-25 21:42:07 +01:00

Merge pull request #605 from guusdk/sint_roster-cleanup

[sinttest] Cleanup of test fixtures
This commit is contained in:
Florian Schmaus 2024-07-02 12:34:53 +00:00 committed by GitHub
commit 8fcfe2cc33
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 29 additions and 8 deletions

View file

@ -49,7 +49,7 @@ public class LowLevelRosterIntegrationTest extends AbstractSmackLowLevelIntegrat
final SimpleResultSyncPoint offlineTriggered = new SimpleResultSyncPoint(); final SimpleResultSyncPoint offlineTriggered = new SimpleResultSyncPoint();
rosterOne.addPresenceEventListener(new AbstractPresenceEventListener() { final AbstractPresenceEventListener presenceEventListener = new AbstractPresenceEventListener() {
@Override @Override
public void presenceUnavailable(FullJid jid, Presence presence) { public void presenceUnavailable(FullJid jid, Presence presence) {
if (!jid.equals(conTwo.getUser())) { if (!jid.equals(conTwo.getUser())) {
@ -57,15 +57,24 @@ public class LowLevelRosterIntegrationTest extends AbstractSmackLowLevelIntegrat
} }
offlineTriggered.signal(); offlineTriggered.signal();
} }
}); };
rosterOne.addPresenceEventListener(presenceEventListener);
// Disconnect conTwo, this should cause an 'unavailable' presence to be send from conTwo to try {
// conOne. // Disconnect conTwo, this should cause an 'unavailable' presence to be send from conTwo to
conTwo.disconnect(); // conOne.
conTwo.disconnect();
Boolean result = offlineTriggered.waitForResult(timeout); Boolean result = offlineTriggered.waitForResult(timeout);
if (!result) { if (!result) {
throw new Exception("presenceUnavailable() was not called"); throw new Exception("presenceUnavailable() was not called");
}
} finally {
// Clean up test fixture.
rosterOne.removePresenceEventListener(presenceEventListener);
conTwo.connect();
conTwo.login();
IntegrationTestRosterUtil.ensureBothAccountsAreNotInEachOthersRoster(conOne, conTwo);
} }
} }

View file

@ -111,6 +111,7 @@ public class GeolocationIntegrationTest extends AbstractSmackIntegrationTest {
" that contained '" + data.toXML() + "', but did not."); " that contained '" + data.toXML() + "', but did not.");
} finally { } finally {
unregisterListener(glm2, geoLocationListener); unregisterListener(glm2, geoLocationListener);
IntegrationTestRosterUtil.ensureBothAccountsAreNotInEachOthersRoster(conOne, conTwo);
} }
} }
@ -171,6 +172,7 @@ public class GeolocationIntegrationTest extends AbstractSmackIntegrationTest {
" that contained '" + data.toXML() + "', but did not."); " that contained '" + data.toXML() + "', but did not.");
} finally { } finally {
unregisterListener(glm2, geoLocationListener); unregisterListener(glm2, geoLocationListener);
IntegrationTestRosterUtil.ensureBothAccountsAreNotInEachOthersRoster(conOne, conTwo);
} }
} }

View file

@ -82,6 +82,7 @@ public class MoodIntegrationTest extends AbstractSmackIntegrationTest {
assertResult(moodReceived, "Expected " + conTwo.getUser() + " to receive a PEP notification, but did not."); assertResult(moodReceived, "Expected " + conTwo.getUser() + " to receive a PEP notification, but did not.");
} finally { } finally {
unregisterListener(mm2, moodListener); unregisterListener(mm2, moodListener);
IntegrationTestRosterUtil.ensureBothAccountsAreNotInEachOthersRoster(conOne, conTwo);
} }
} }
@ -117,6 +118,7 @@ public class MoodIntegrationTest extends AbstractSmackIntegrationTest {
assertResult(moodReceived, "Expected " + conTwo.getUser() + " to receive a PEP notification, but did not."); assertResult(moodReceived, "Expected " + conTwo.getUser() + " to receive a PEP notification, but did not.");
} finally { } finally {
unregisterListener(mm2, moodListener); unregisterListener(mm2, moodListener);
IntegrationTestRosterUtil.ensureBothAccountsAreNotInEachOthersRoster(conOne, conTwo);
} }
} }

View file

@ -31,6 +31,7 @@ import org.jivesoftware.smackx.softwareinfo.form.SoftwareInfoForm;
import org.igniterealtime.smack.inttest.AbstractSmackIntegrationTest; import org.igniterealtime.smack.inttest.AbstractSmackIntegrationTest;
import org.igniterealtime.smack.inttest.SmackIntegrationTestEnvironment; import org.igniterealtime.smack.inttest.SmackIntegrationTestEnvironment;
import org.igniterealtime.smack.inttest.annotations.AfterClass;
import org.igniterealtime.smack.inttest.annotations.BeforeClass; import org.igniterealtime.smack.inttest.annotations.BeforeClass;
import org.igniterealtime.smack.inttest.annotations.SmackIntegrationTest; import org.igniterealtime.smack.inttest.annotations.SmackIntegrationTest;
import org.igniterealtime.smack.inttest.annotations.SpecificationReference; import org.igniterealtime.smack.inttest.annotations.SpecificationReference;
@ -54,6 +55,11 @@ public class SoftwareInfoIntegrationTest extends AbstractSmackIntegrationTest {
IntegrationTestRosterUtil.ensureBothAccountsAreSubscribedToEachOther(conOne, conTwo, timeout); IntegrationTestRosterUtil.ensureBothAccountsAreSubscribedToEachOther(conOne, conTwo, timeout);
} }
@AfterClass
public void cleanUp() throws Exception {
IntegrationTestRosterUtil.ensureBothAccountsAreNotInEachOthersRoster(conOne, conTwo);
}
@SmackIntegrationTest @SmackIntegrationTest
public void test() throws Exception { public void test() throws Exception {
SoftwareInfoForm softwareInfoSent = createSoftwareInfoForm(); SoftwareInfoForm softwareInfoSent = createSoftwareInfoForm();

View file

@ -98,6 +98,7 @@ public class UserTuneIntegrationTest extends AbstractSmackIntegrationTest {
Assertions.assertNotNull(result, "Expected to receive a PEP notification, but did not."); Assertions.assertNotNull(result, "Expected to receive a PEP notification, but did not.");
} finally { } finally {
unregisterListener(utm2, userTuneListener); unregisterListener(utm2, userTuneListener);
IntegrationTestRosterUtil.ensureBothAccountsAreNotInEachOthersRoster(conOne, conTwo);
} }
} }
@ -142,6 +143,7 @@ public class UserTuneIntegrationTest extends AbstractSmackIntegrationTest {
assertResult(userTuneReceived, "Expected " + conTwo.getUser() + " to receive a PEP notification from " + conOne.getUser() + ", but did not."); assertResult(userTuneReceived, "Expected " + conTwo.getUser() + " to receive a PEP notification from " + conOne.getUser() + ", but did not.");
} finally { } finally {
unregisterListener(utm2, userTuneListener); unregisterListener(utm2, userTuneListener);
IntegrationTestRosterUtil.ensureBothAccountsAreNotInEachOthersRoster(conOne, conTwo);
} }
} }