use of jetbrains.communicator.core.dispatcher.LocalMessage in project intellij-plugins by JetBrains.
the class IDEAFacadeTest method testCreateLocalMessage_OutgoingCodePointer.
public void testCreateLocalMessage_OutgoingCodePointer() throws Exception {
SendCodePointerEvent event = new SendCodePointerEvent("message", VFile.create("a path"), new CodePointer(3, 4), myUser);
LocalMessage outgoingEvent = myFacade.createLocalMessageForOutgoingEvent(event);
assertTrue(outgoingEvent instanceof OutgoingCodePointerLocalMessage);
}
use of jetbrains.communicator.core.dispatcher.LocalMessage in project intellij-plugins by JetBrains.
the class LocalMessageDispatcherTest method testSendMessageEvent.
public void testSendMessageEvent() throws Exception {
MockTransport mockTransport = new MockTransport();
MockMessage localMessage = new MockMessage();
MockMessage localMessage1 = new MockMessage();
myIdeFacade.setReturnedMessage(localMessage);
getBroadcaster().fireEvent(new SendMessageEvent("text", myUser));
myIdeFacade.setReturnedMessage(localMessage1);
getBroadcaster().fireEvent(new SendMessageEvent("text", myUser));
LocalMessage[] history = myDispatcher.getHistory(myUser, null);
assertEquals("Expect localMessages as a result to OwnMessageEvent", 2, history.length);
assertSame(localMessage, history[0]);
assertSame(localMessage1, history[1]);
}
use of jetbrains.communicator.core.dispatcher.LocalMessage in project intellij-plugins by JetBrains.
the class LocalMessageDispatcherTest method testPerformance.
public void testPerformance() throws Exception {
Logger logger = Logger.getLogger("jetbrains.communicator");
Level oldLevel = logger.getLevel();
try {
logger.setLevel(Level.WARN);
for (int i = 0; i < 1000; i++) {
Date date = new Date(System.currentTimeMillis() + i * 1000L * 3600L);
myDispatcher.sendNow(myUser, new MockMessage(date));
}
Thread.sleep(SAVE_WAIT_TIMEOUT * 2);
WatchDog watchDog = new WatchDog("Load history");
LocalMessageDispatcherImpl localMessageDispatcher = createLocalMessageDispatcher();
LocalMessage[] messages = localMessageDispatcher.getHistory(myUser, yesterday());
assertEquals(1000, messages.length);
long diff = watchDog.diff();
watchDog.watchAndReset("done");
assertTrue("Too long getting history:" + diff, diff < 1500);
messages = localMessageDispatcher.getHistory(myUser, null);
assertEquals(1000, messages.length);
diff = watchDog.diff();
watchDog.watchAndReset("again done");
assertTrue("Too long getting history second time:" + diff, diff < 100);
} finally {
logger.setLevel(oldLevel);
}
}
use of jetbrains.communicator.core.dispatcher.LocalMessage in project intellij-plugins by JetBrains.
the class LocalMessageDispatcherTest method testHistoryPersistence_SortLoadedHistory.
public void testHistoryPersistence_SortLoadedHistory() throws Exception {
myDispatcher.sendNow(myUser, new MockMessage(yesterday(), "someText"));
MockMessage message = new MockMessage();
myDispatcher.sendNow(myUser, message);
Thread.sleep(SAVE_WAIT_TIMEOUT);
LocalMessageDispatcherImpl localMessageDispatcher = createLocalMessageDispatcher();
localMessageDispatcher.sendNow(myUser, message);
Thread.sleep(SAVE_WAIT_TIMEOUT);
assertEquals(2, localMessageDispatcher.getHistory(myUser, a_moment_ago()).length);
LocalMessage[] messages = localMessageDispatcher.getHistory(myUser, null);
assertEquals(3, messages.length);
assertEquals("someText", ((MockMessage) messages[0]).getMessage());
}
use of jetbrains.communicator.core.dispatcher.LocalMessage in project intellij-plugins by JetBrains.
the class LocalMessageDispatcherTest method testTransportEvent.
public void testTransportEvent() throws Exception {
MockTransport mockTransport = new MockTransport();
MockMessage localMessage = new MockMessage();
MockMessage localMessage1 = new MockMessage();
myIdeFacade.setReturnedMessage(localMessage);
getBroadcaster().fireEvent(new TransportEvent(mockTransport, "user") {
});
myIdeFacade.setReturnedMessage(localMessage1);
getBroadcaster().fireEvent(new TransportEvent(mockTransport, "user") {
});
Message[] pendingMessages = myDispatcher.getPendingMessages(myUser);
assertEquals("Expect a local localMessages as a result to TransportEvent", 2, pendingMessages.length);
assertSame(localMessage, pendingMessages[0]);
assertSame(localMessage1, pendingMessages[1]);
assertEquals("", localMessage.getLog());
}
Aggregations