Search in sources :

Example 26 with XMPPErrorException

use of org.jivesoftware.smack.XMPPException.XMPPErrorException in project Smack by igniterealtime.

the class IntTestUtil method disconnectAndMaybeDelete.

public static void disconnectAndMaybeDelete(XMPPTCPConnection connection, Configuration config) throws InterruptedException {
    try {
        if (!config.isAccountRegistrationPossible()) {
            return;
        }
        Configuration.AccountRegistration accountDeletionMethod = config.accountRegistration;
        AccountManager accountManager = AccountManager.getInstance(connection);
        try {
            if (accountManager.isSupported()) {
                accountDeletionMethod = AccountRegistration.inBandRegistration;
            }
        } catch (NoResponseException | XMPPErrorException | NotConnectedException e) {
            LOGGER.log(Level.WARNING, "Could not test if XEP-0077 account deletion is possible", e);
        }
        switch(accountDeletionMethod) {
            case inBandRegistration:
                deleteViaIbr(connection);
                break;
            case serviceAdministration:
                deleteViaServiceAdministration(connection, config);
                break;
            default:
                throw new AssertionError();
        }
    } finally {
        connection.disconnect();
    }
}
Also used : XMPPErrorException(org.jivesoftware.smack.XMPPException.XMPPErrorException) AccountRegistration(org.igniterealtime.smack.inttest.Configuration.AccountRegistration) NotConnectedException(org.jivesoftware.smack.SmackException.NotConnectedException) AccountManager(org.jivesoftware.smackx.iqregister.AccountManager) NoResponseException(org.jivesoftware.smack.SmackException.NoResponseException)

Example 27 with XMPPErrorException

use of org.jivesoftware.smack.XMPPException.XMPPErrorException in project Smack by igniterealtime.

the class EntityCapsTest method testEntityCaps.

@SmackIntegrationTest
public void testEntityCaps() throws XMPPException, InterruptedException, NoResponseException, NotConnectedException, TimeoutException {
    final String dummyFeature = getNewDummyFeature();
    dropWholeEntityCapsCache();
    performActionAndWaitUntilStanzaReceived(new Runnable() {

        @Override
        public void run() {
            sdmTwo.addFeature(dummyFeature);
        }
    }, connection, new AndFilter(PresenceTypeFilter.AVAILABLE, FromMatchesFilter.create(conTwo.getUser())));
    waitUntilTrue(new Condition() {

        @Override
        public boolean evaluate() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
            DiscoverInfo info = sdmOne.discoverInfo(conTwo.getUser());
            return info.containsFeature(dummyFeature);
        }
    });
    DiscoverInfo info = sdmOne.discoverInfo(conTwo.getUser());
    String u1ver = EntityCapsManager.getNodeVersionByJid(conTwo.getUser());
    assertNotNull(u1ver);
    DiscoverInfo entityInfo = EntityCapsManager.CAPS_CACHE.lookup(u1ver);
    assertNotNull(entityInfo);
    assertEquals(info.toXML(), entityInfo.toXML());
}
Also used : AndFilter(org.jivesoftware.smack.filter.AndFilter) DiscoverInfo(org.jivesoftware.smackx.disco.packet.DiscoverInfo) XMPPErrorException(org.jivesoftware.smack.XMPPException.XMPPErrorException) NotConnectedException(org.jivesoftware.smack.SmackException.NotConnectedException) NoResponseException(org.jivesoftware.smack.SmackException.NoResponseException) SmackIntegrationTest(org.igniterealtime.smack.inttest.SmackIntegrationTest) AbstractSmackIntegrationTest(org.igniterealtime.smack.inttest.AbstractSmackIntegrationTest)

Aggregations

XMPPErrorException (org.jivesoftware.smack.XMPPException.XMPPErrorException)27 NoResponseException (org.jivesoftware.smack.SmackException.NoResponseException)10 IQ (org.jivesoftware.smack.packet.IQ)9 Test (org.junit.Test)9 IOException (java.io.IOException)7 SmackException (org.jivesoftware.smack.SmackException)7 NotConnectedException (org.jivesoftware.smack.SmackException.NotConnectedException)7 Stanza (org.jivesoftware.smack.packet.Stanza)6 Bytestream (org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream)6 XMPPError (org.jivesoftware.smack.packet.XMPPError)5 DiscoverInfo (org.jivesoftware.smackx.disco.packet.DiscoverInfo)5 InputStream (java.io.InputStream)4 XMPPException (org.jivesoftware.smack.XMPPException)4 XMPPConnection (org.jivesoftware.smack.XMPPConnection)3 DiscoverItems (org.jivesoftware.smackx.disco.packet.DiscoverItems)3 FileNotFoundException (java.io.FileNotFoundException)2 ArrayList (java.util.ArrayList)2 TimeoutException (java.util.concurrent.TimeoutException)2 AbstractSmackIntegrationTest (org.igniterealtime.smack.inttest.AbstractSmackIntegrationTest)2 SmackIntegrationTest (org.igniterealtime.smack.inttest.SmackIntegrationTest)2