use of jetbrains.communicator.util.WaitFor in project intellij-plugins by JetBrains.
the class JabberTransport_ConnectionTest method testSendCustomMessage_WithoutProvider.
public void testSendCustomMessage_WithoutProvider() throws Exception {
addEventListener();
myTransport.sendXmlMessage(mySelf, new TextXmlMessage("some text") {
@Override
public String getTagNamespace() {
return "some namespace";
}
});
new WaitFor(TIMEOUT) {
@Override
protected boolean condition() {
return myEvents.size() > 1;
}
};
IDEtalkEvent event = myEvents.get(1);
assertTrue("Expect message Event for unknown provider", event instanceof MessageEvent);
assertEquals("Expect message text", "some text", ((MessageEvent) event).getMessage());
}
use of jetbrains.communicator.util.WaitFor in project intellij-plugins by JetBrains.
the class P2PTransportTest method testSetOwnPresence.
public void testSetOwnPresence() throws Exception {
registerResponseProviders(myUserModel, myIdeFacade);
// Add self to contact list
User self = myUserModel.createUser(StringUtil.getMyUsername(), myTransport.getName());
myUserModel.addUser(self);
// Wait for next cycle of user finding
new WaitFor(1000) {
@Override
protected boolean condition() {
return !myTransport.getUserMonitorThread().isFinding();
}
};
// make self away
UserPresence presence = new UserPresence(PresenceMode.AWAY);
assert presence.isOnline();
myTransport.setOwnPresence(presence);
// make sure that away status will be updated
myTransport.findUsers(new NullProgressIndicator());
assert PresenceMode.AWAY == self.getPresence().getPresenceMode();
// Now, test itself. We go online and want this status to be updated almost immediately.
myEvents.clear();
addEventListener();
myTransport.setOwnPresence(new UserPresence(PresenceMode.AVAILABLE));
final User self1 = self;
new WaitFor(200) {
@Override
protected boolean condition() {
return self1.getPresence().getPresenceMode() == PresenceMode.AVAILABLE;
}
};
assertSame("Should provide correct presence mode", PresenceMode.AVAILABLE, myTransport.getUserPresence(self).getPresenceMode());
UserEvent.Updated event = (UserEvent.Updated) checkEvent(true);
assertNotNull("Expect go online event", event);
assertEquals("presence", event.getPropertyName());
}
use of jetbrains.communicator.util.WaitFor in project intellij-plugins by JetBrains.
the class JabberTransport_ConnectionTest method testTimeIsSetInSimpleMessage.
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;
}
};
long diff = ((MessageEvent) myEvents.get(1)).getWhen().getTime() - System.currentTimeMillis();
assertTrue("Time should be set for simple Jabber messages: " + diff, Math.abs(diff) < 150);
}
use of jetbrains.communicator.util.WaitFor in project intellij-plugins by JetBrains.
the class JabberTransport_ConnectionTest method testLocalChanges_UpdateRoster.
public void testLocalChanges_UpdateRoster() throws Throwable {
addEventListener();
addUserFred();
User user = myUserModel.getAllUsers()[0];
final Roster roster = myFacade.getConnection().getRoster();
// Change group:
user.setGroup("someOtherGroup", myUserModel);
new WaitFor(TIMEOUT) {
@Override
protected boolean condition() {
return roster.getGroupCount() == 1 && roster.getGroup("someOtherGroup") != null;
}
};
assertEquals("One group expected", 1, roster.getGroupCount());
RosterGroup group = roster.getGroup("someOtherGroup");
assertNotNull(group);
assertEquals(1, group.getEntryCount());
assertNotNull(group.getEntry(FRED));
// Change Display name:
user.setDisplayName("Some new name", myUserModel);
new WaitFor(TIMEOUT) {
@Override
protected boolean condition() {
return "Some new name".equals(roster.getEntry(FRED).getName());
}
};
assertEquals("User name in Roster should have changed", "Some new name", roster.getEntry(FRED).getName());
// Delete user:
myUserModel.removeUser(user);
new WaitFor(TIMEOUT) {
@Override
protected boolean condition() {
return roster.getEntryCount() == 0;
}
};
assertEquals("User should be removed from Roster", 0, roster.getEntryCount());
}
use of jetbrains.communicator.util.WaitFor in project intellij-plugins by JetBrains.
the class JabberTransport_ConnectionTest method testSimpleJabberMessage.
public void testSimpleJabberMessage() throws Throwable {
Message message = new Message(mySelf.getName(), Message.Type.NORMAL);
String body = "some текст <>#$%^";
message.setThread("someThreadId");
message.setBody(body);
addEventListener();
myFacade.getConnection().sendPacket(message);
new WaitFor(TIMEOUT) {
@Override
protected boolean condition() {
return myEvents.size() > 1;
}
};
IDEtalkEvent event = myEvents.get(1);
assertTrue("Expect message Event", event instanceof MessageEvent);
assertEquals("Expect message text", body, ((MessageEvent) event).getMessage());
assertEquals("Should remember threadId for incoming messages", "someThreadId", myTransport.getThreadId(mySelf));
}
Aggregations