use of jetbrains.communicator.util.WaitFor in project intellij-plugins by JetBrains.
the class TestUtil method testSendMessage_Functional.
public static void testSendMessage_Functional(BaseTestCase testCase, User self) {
final String[] log = new String[] { "" };
final long[] whenSent = new long[1];
testCase.getBroadcaster().addListener(new IDEtalkAdapter() {
@Override
public void afterChange(IDEtalkEvent event) {
event.accept(new EventVisitor() {
@Override
public void visitMessageEvent(MessageEvent event) {
super.visitMessageEvent(event);
log[0] += event.getRemoteUser() + ' ' + event.getMessage();
if (event.getWhen().getTime() - whenSent[0] < 150) {
log[0] += " timingOK";
} else {
log[0] += (event.getWhen().getTime() - whenSent[0]);
}
}
});
}
});
testCase.markLastListenerForCleanup();
log[0] = "";
String comment = "SS��� messa&&ge";
whenSent[0] = System.currentTimeMillis();
self.sendMessage(comment, testCase.getBroadcaster());
new WaitFor(500) {
@Override
protected boolean condition() {
return log[0].length() > 0;
}
};
assertEquals("Message expected", self.getName() + ' ' + comment + " timingOK", log[0]);
}
use of jetbrains.communicator.util.WaitFor in project intellij-plugins by JetBrains.
the class TestUtil method testSendCodePointer_Functional.
public static void testSendCodePointer_Functional(BaseTestCase testCase, User self) {
final String[] log = new String[] { "" };
testCase.getBroadcaster().addListener(new IDEtalkAdapter() {
@Override
public void afterChange(IDEtalkEvent event) {
event.accept(new EventVisitor() {
@Override
public void visitCodePointerEvent(CodePointerEvent event) {
log[0] += event.getRemoteUser() + ' ';
log[0] += event.getComment();
log[0] += event.getCodePointer().toString();
log[0] += event.getFile().toString();
}
});
}
});
testCase.markLastListenerForCleanup();
log[0] = "";
CodePointer pointer = new CodePointer(0, 1);
VFile file = VFile.create("path");
self.sendCodeIntervalPointer(file, pointer, "comment���< && 53", testCase.getBroadcaster());
new WaitFor(2000) {
@Override
protected boolean condition() {
return log[0].length() > 0;
}
};
Assert.assertEquals("Code Pointer expected", self.getName() + " comment���< && 53" + pointer + file, log[0]);
}
use of jetbrains.communicator.util.WaitFor in project intellij-plugins by JetBrains.
the class AsyncMessageDispatcherTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
myIdeFacade = new MockIDEFacade(getClass());
myUser = new MockUser("user", null);
myUser.setOnline(true);
myDispatcher = new AsyncMessageDispatcherImpl(getBroadcaster(), myIdeFacade);
new WaitFor(1000) {
@Override
protected boolean condition() {
return myDispatcher.isRunning();
}
};
myLog = new String[] { "" };
}
use of jetbrains.communicator.util.WaitFor in project intellij-plugins by JetBrains.
the class AsyncMessageDispatcherTest method testAddMessagesWhileDispatching.
public void testAddMessagesWhileDispatching() throws Exception {
NotifyableMessage mockMessage = new NotifyableMessage(true, myLog);
MockUser user1 = new MockUser("user1", null);
MockUser user2 = new MockUser("user2", null);
user1.setOnline(true);
user2.setOnline(true);
myDispatcher.sendLater(user1, mockMessage);
mockMessage.waitUntilDispatchingStarted();
myDispatcher.sendLater(user2, new MockMessage(true));
assertEquals("Messages not delivered yet", 2, myDispatcher.getUsersWithMessages().length);
triggerMessageProcessing(mockMessage);
new WaitFor(200) {
@Override
protected boolean condition() {
return myDispatcher.getUsersWithMessages().length == 0;
}
};
assertEquals("All messages should be delivered", 0, myDispatcher.getUsersWithMessages().length);
}
use of jetbrains.communicator.util.WaitFor in project intellij-plugins by JetBrains.
the class TestUtil method testSendXmlMessage_Functional.
public static void testSendXmlMessage_Functional(BaseTestCase testCase, User self, final boolean checkResponse) {
final String[] log = new String[] { "" };
log[0] = "";
final String comment = "��� mes&&<>sage";
MockXmlMessage message = new MockXmlMessage("tagName", "myNamespace") {
@Override
public boolean needsResponse() {
return checkResponse;
}
@Override
public void fillRequest(Element element) {
element.setText(comment);
}
@Override
public void processResponse(Element responseElement) {
log[0] += responseElement.getAttributeValue("foo");
}
};
final MockXmlResponseProvider mockXmlResponseProvider = new MockXmlResponseProvider("tagName", "myNamespace", testCase.getBroadcaster()) {
@Override
public boolean processAndFillResponse(Element response, Element request, Transport transport, String remoteUser) {
log[0] += remoteUser + " " + request.getName() + " " + request.getText();
assertEquals("root element expected", "tagName", request.getName());
response.setAttribute("foo", "gar");
return true;
}
};
Pico.getInstance().registerComponentInstance(mockXmlResponseProvider);
testCase.disposeOnTearDown(new Disposable() {
@Override
public void dispose() {
Pico.getInstance().unregisterComponentByInstance(mockXmlResponseProvider);
}
});
self.sendXmlMessage(message);
new WaitFor(500) {
@Override
protected boolean condition() {
if (checkResponse) {
return log[0].endsWith("gar");
} else {
return log[0].length() > 0;
}
}
};
String expectedLog = self.getName() + " tagName " + comment;
expectedLog += checkResponse ? "gar" : "";
assertEquals("Message expected", expectedLog, log[0]);
}
Aggregations