Search in sources :

Example 16 with WaitFor

use of jetbrains.communicator.util.WaitFor in project intellij-plugins by JetBrains.

the class JabberFacade_ConnectionTest method testPresenceAfterConnection.

public void testPresenceAfterConnection() throws Throwable {
    createGoodAccount(myUser, myFacade);
    final String me = myFacade.getConnection().getUser();
    myFacade.getConnection().getRoster().setSubscriptionMode(Roster.SubscriptionMode.accept_all);
    final JabberFacadeImpl another = new JabberFacadeImpl(myIDEFacade);
    createGoodAccount("ddd" + System.currentTimeMillis(), another);
    another.addUsers("group", Arrays.asList(me));
    new WaitFor(3000) {

        @Override
        protected boolean condition() {
            return another.getConnection().getRoster().getPresence(me) != null;
        }
    };
    Presence presence = another.getConnection().getRoster().getPresence(me);
    assertNotNull(presence);
    assertEquals(Presence.Type.available, presence.getType());
    assertEquals(Presence.Mode.available, presence.getMode());
}
Also used : WaitFor(jetbrains.communicator.util.WaitFor) Presence(org.jivesoftware.smack.packet.Presence)

Example 17 with WaitFor

use of jetbrains.communicator.util.WaitFor in project intellij-plugins by JetBrains.

the class JabberFacade_ConnectionTest method testAddUsers.

public void testAddUsers() throws Exception {
    createGoodAccount(myUser, myFacade);
    final String bob = "bob@jabber.org";
    String self = myFacade.getConnection().getUser();
    myFacade.addUsers("someGroup", Arrays.asList(self, bob));
    final Roster roster = myFacade.getConnection().getRoster();
    new WaitFor(500) {

        @Override
        protected boolean condition() {
            return roster.contains(bob);
        }
    };
    assertTrue("User should be added to the Roster", roster.contains(bob));
    assertFalse("Self should not be added to the Roster", roster.contains(self));
    new WaitFor(200) {

        @Override
        protected boolean condition() {
            return roster.getEntry(bob).getGroups().size() > 0;
        }
    };
    assertEquals("Bad Group", "someGroup", roster.getEntry(bob).getGroups().iterator().next().getName());
}
Also used : Roster(org.jivesoftware.smack.Roster) WaitFor(jetbrains.communicator.util.WaitFor)

Aggregations

WaitFor (jetbrains.communicator.util.WaitFor)17 IDEtalkEvent (jetbrains.communicator.core.IDEtalkEvent)5 MessageEvent (jetbrains.communicator.core.transport.MessageEvent)4 User (jetbrains.communicator.core.users.User)4 UserPresence (jetbrains.communicator.core.users.UserPresence)4 Presence (org.jivesoftware.smack.packet.Presence)4 TextXmlMessage (jetbrains.communicator.core.transport.TextXmlMessage)3 UserEvent (jetbrains.communicator.core.users.UserEvent)3 MockUser (jetbrains.communicator.mock.MockUser)3 EventVisitor (jetbrains.communicator.core.EventVisitor)2 IDEtalkAdapter (jetbrains.communicator.core.IDEtalkAdapter)2 Message (org.jivesoftware.smack.packet.Message)2 CodePointerEvent (jetbrains.communicator.core.transport.CodePointerEvent)1 Transport (jetbrains.communicator.core.transport.Transport)1 CodePointer (jetbrains.communicator.core.vfs.CodePointer)1 VFile (jetbrains.communicator.core.vfs.VFile)1 NullProgressIndicator (jetbrains.communicator.ide.NullProgressIndicator)1 MockIDEFacade (jetbrains.communicator.mock.MockIDEFacade)1 MockMessage (jetbrains.communicator.mock.MockMessage)1 MockXmlMessage (jetbrains.communicator.p2p.MockXmlMessage)1