Package jetbrains.communicator.util

Examples of jetbrains.communicator.util.WaitFor


    bob.getRoster().createEntry(selfName, "me", new String[]{"DDD"});

    // Now we connect. Bob should get us in his presence - auto confirmation of the subscription expected.
    // See JabberTransport:mySubscribeListener
    myFacade.connect();
    new WaitFor(TIMEOUT) {
      @Override
      protected boolean condition() {
        return  null != bob.getRoster().getPresence(selfName);
      }
    };
    assertTrue("Sanity check", myFacade.isConnectedAndAuthenticated());

    Presence presence = bob.getRoster().getPresence(selfName);
    assertNotNull(presence);
    assertEquals("Should return good presence", Presence.Type.available,
        presence.getType() );

    new WaitFor(TIMEOUT) {
      @Override
      protected boolean condition() {
        return myEvents.size() > 1;
      }
    };

    final String bobUserName = getUser(bob);

    assertEquals("We should get bob in our contact list as well", 1, myUserModel.getAllUsers().length);
    assertEquals("We should get bob in our contact list as well", bobUserName, myUserModel.getAllUsers()[0].getName());

    new WaitFor(TIMEOUT) {
      @Override
      protected boolean condition() {
        return getBobEntry(bobUserName) != null && getBobEntry(bobUserName).getType() == RosterPacket.ItemType.BOTH;
      }
    };
View Full Code Here


    assertFalse("Not in my contact list", myTransport.isUserInMyContactListAndActive(userName));

    myFacade.addUsers("General", Collections.singletonList(userName));
    final String userName1 = userName;
    new WaitFor(TIMEOUT){
      @Override
      protected boolean condition() {
        return myTransport.isUserInMyContactListAndActive(userName1);
      }
    };
View Full Code Here

    return JabberTransport.getSimpleId(bob.getUser());
  }

  public void testSendMessage2NonExistingUser() throws Throwable {
    myFacade.addUsers("grp", Arrays.asList(new String[]{"some@fake.user"}));
    new WaitFor(TIMEOUT) {
      @Override
      protected boolean condition() {
        return myUserModel.getAllUsers().length > 0;
      }
    };

    myUserModel.getAllUsers()[0].sendMessage("some text", getBroadcaster());
    myEvents.clear();
    new WaitFor(TIMEOUT){
      @Override
      protected boolean condition() {
        return myEvents.size() > 0;
      }
    };
View Full Code Here

    myFacade.disconnect();

    // This should work fine. Connection should be reestablished
    addEventListener();
    mySelf.sendMessage("message", getBroadcaster());
    new WaitFor(TIMEOUT) {
      @Override
      protected boolean condition() {
        return myEvents.size() > 0;
      }
    };
View Full Code Here

  public void testSendMessage_IgnoreList() throws Throwable {

    XMPPConnection conn = createLocalConnectionWithJabberUser("tom" + System.nanoTime(), null);
    conn.getRoster().createEntry(selfJabberId(), "name", new String[0]);
    addEventListener();
    new WaitFor(TIMEOUT) {
      @Override
      protected boolean condition() {
        return myEvents.size() > 1;
      }
    };
    myEvents.clear();

    setIgnoreList(getUser(conn));

    conn.createChat(selfJabberId()).sendMessage("hello");
    new WaitFor(2000) {
      @Override
      protected boolean condition() {
        return myEvents.size() > 0;
      }
    };
View Full Code Here

    message.setBody(body);

    addEventListener();
    myFacade.getConnection().sendPacket(message);

    new WaitFor(TIMEOUT) {
      @Override
      protected boolean condition() {
        return myEvents.size() > 1;
      }
    };
View Full Code Here

      public String getTagNamespace() {
        return "some namespace";
      }
    });

    new WaitFor(TIMEOUT) {
      @Override
      protected boolean condition() {
        return myEvents.size() > 1;
      }
    };
View Full Code Here

  public void testTimeIsSetInSimpleMessage() throws Throwable {
    Message baseMessage = myTransport.createBaseMessage(mySelf, "some text");
    myTransport.getFacade().getConnection().sendPacket(baseMessage);

    new WaitFor(TIMEOUT){
      @Override
      protected boolean condition() {
        return myEvents.size() > 0;
      }
    };
View Full Code Here

    final XMPPConnection bob = createLocalConnectionWithJabberUser(bobName, null);
    final String user = selfJabberId();
    bob.getRoster().createEntry(user, user, new String[0]);
    myFacade.addUsers("grp", Arrays.asList(getUser(bob)));

    new WaitFor(TIMEOUT) {
      @Override
      protected boolean condition() {
        return null != bob.getRoster().getPresence(user);
      }
    };
    assert null != bob.getRoster().getPresence(user);


    // First, change own presence and check it's changed from bob's point of view
    UserPresence presence = new UserPresence(PresenceMode.AWAY);
    assert presence.isOnline();

    myTransport.setOwnPresence(presence);
    new WaitFor(TIMEOUT) {
      @Override
      protected boolean condition() {
        return Presence.Mode.away == bob.getRoster().getPresence(user).getMode();
      }
    };
    Presence p = bob.getRoster().getPresence(user);
    assertSame("Own presence should be away", Presence.Mode.away, p.getMode());
    assertEquals("", p.getStatus());

    // Now, change bob's presence
    new WaitFor(TIMEOUT) {
      @Override
      protected boolean condition() {
        return myEvents.size() > 2;
      }
    };
    myEvents.clear();
    bob.sendPacket(new Presence(Presence.Type.available, "", 0, Presence.Mode.dnd));
    final User bobUser = myUserModel.findUser(getUser(bob), myTransport.getName());

    new WaitFor(TIMEOUT) {
      @Override
      protected boolean condition() {
        return PresenceMode.DND == bobUser.getPresence().getPresenceMode();
      }
    };

    assertSame("Should take bob's presence", PresenceMode.DND, bobUser.getPresence().getPresenceMode());
    UserEvent.Updated event = (UserEvent.Updated) checkEvent(true);
    assertEquals(bobUser, event.getUser());
    assertEquals("presence", event.getPropertyName());
    assertEquals(PresenceMode.DND, event.getNewValue());
    assertEquals(PresenceMode.AVAILABLE, event.getOldValue());

    // Now, change bob's presence + set time
    bob.sendPacket(new Presence(Presence.Type.available, "some status", 0, Presence.Mode.xa));

    new WaitFor(TIMEOUT) {
      @Override
      protected boolean condition() {
        return PresenceMode.EXTENDED_AWAY == bobUser.getPresence().getPresenceMode();
      }
    };
View Full Code Here

    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;
      }
    };
View Full Code Here

TOP

Related Classes of jetbrains.communicator.util.WaitFor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.