use of jetbrains.communicator.ide.NullProgressIndicator in project intellij-plugins by JetBrains.
the class JabberUserFinderTest method testRegisterAndFindUser.
public void testRegisterAndFindUser() throws Throwable {
URL url = new URL(JabberUserFinderImpl.TEST_URL);
try {
url.getContent();
} catch (IOException e) {
System.out.println("WARNING: " + JabberUserFinderImpl.TEST_URL + " not available");
return;
}
myUserFinder.registerForProject("kir@localhost");
Thread.sleep(400);
User[] users = myUserFinder.findUsers(new NullProgressIndicator());
assertEquals(1, users.length);
assertEquals("kir@localhost", users[0].getName());
}
use of jetbrains.communicator.ide.NullProgressIndicator 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.ide.NullProgressIndicator in project intellij-plugins by JetBrains.
the class ClearHistoryCommandTest method testClearHistory.
public void testClearHistory() throws Exception {
myIdeMock.expects(once()).method("askQuestion").with(eq(StringUtil.getMsg("ClearHistoryCommand.title")), eq(StringUtil.getMsg("ClearHistoryCommand.text"))).will(returnValue(true));
myIdeMock.expects(once()).method("runLongProcess").will(new CustomStub("runner") {
@Override
public Object invoke(Invocation invocation) throws Throwable {
((IDEFacade.Process) invocation.parameterValues.get(1)).run(new NullProgressIndicator());
return null;
}
});
myIdeMock.expects(once()).method("runOnPooledThread").will(new CustomStub("foo") {
@Override
public Object invoke(Invocation invocation) throws Throwable {
final FutureTask task = new FutureTask((Runnable) invocation.parameterValues.get(0), null);
task.run();
return task;
}
});
myDispatcherMock.expects(once()).method("clearHistory");
myCommand.execute();
}
use of jetbrains.communicator.ide.NullProgressIndicator in project intellij-plugins by JetBrains.
the class P2PTransport method initializeProject.
@Override
public void initializeProject(final String projectName, MutablePicoContainer projectLevelContainer) {
getIdeFacade().runOnPooledThread(() -> {
User[] users = findUsers(new NullProgressIndicator());
Set<User> ourUsers = new HashSet<>();
for (User user : users) {
if (Arrays.asList(user.getProjects()).contains(projectName)) {
ourUsers.add(user);
}
}
if (canAddUsers(projectName, ourUsers)) {
for (User user : ourUsers) {
if (!myUserModel.hasUser(user)) {
user.setGroup(projectName, myUserModel);
myUserModel.addUser(user);
}
}
}
});
}
use of jetbrains.communicator.ide.NullProgressIndicator in project intellij-plugins by JetBrains.
the class P2PTransportTest method testFindUsers.
public void testFindUsers() throws Exception {
User[] users = myTransport.findUsers(new NullProgressIndicator());
assertTrue("At least self should be found", users.length >= 1);
User self = null;
for (User user : users) {
if (user.getName().equals(StringUtil.getMyUsername())) {
self = user;
break;
}
}
assertNotNull("Self user not found in " + Arrays.asList(users), self);
assertTrue("Self should be online", self.isOnline());
InetAddress address = myTransport.getAddress(self);
assertTrue("Self address is expected:" + address, NetworkUtil.isOwnAddress(address));
assertEquals("Projects should be set", PROJECT_NAME, self.getProjects()[0]);
}
Aggregations