Search in sources :

Example 1 with ConnectionListener

use of jetbrains.communicator.jabber.ConnectionListener in project intellij-plugins by JetBrains.

the class JabberFacade_ConnectionTest method testConnectListener.

public void testConnectListener() throws Throwable {
    final boolean[] connected = new boolean[1];
    final boolean[] disconnected = new boolean[1];
    final boolean[] authenticated = new boolean[1];
    myFacade.addConnectionListener(new ConnectionListener() {

        @Override
        public void connected(XMPPConnection connection) {
            connected[0] = true;
        }

        @Override
        public void disconnected(boolean onError) {
            disconnected[0] = true;
        }

        @Override
        public void authenticated() {
            authenticated[0] = true;
        }
    });
    assertFalse("sanity check", connected[0] || disconnected[0] || authenticated[0]);
    createGoodAccount(myUser, myFacade);
    assertTrue("should call listener", connected[0] && authenticated[0]);
    assertFalse(disconnected[0]);
    myFacade.disconnect();
    assertTrue(disconnected[0]);
}
Also used : ConnectionListener(jetbrains.communicator.jabber.ConnectionListener) XMPPConnection(org.jivesoftware.smack.XMPPConnection)

Aggregations

ConnectionListener (jetbrains.communicator.jabber.ConnectionListener)1 XMPPConnection (org.jivesoftware.smack.XMPPConnection)1