Search in sources :

Example 6 with LocalMessage

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);
}
Also used : IncomingLocalMessage(jetbrains.communicator.idea.sendMessage.IncomingLocalMessage) LocalMessage(jetbrains.communicator.core.dispatcher.LocalMessage) CodePointer(jetbrains.communicator.core.vfs.CodePointer) SendCodePointerEvent(jetbrains.communicator.ide.SendCodePointerEvent)

Example 7 with LocalMessage

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]);
}
Also used : LocalMessage(jetbrains.communicator.core.dispatcher.LocalMessage) MockTransport(jetbrains.communicator.mock.MockTransport) MockMessage(jetbrains.communicator.mock.MockMessage) SendMessageEvent(jetbrains.communicator.ide.SendMessageEvent)

Example 8 with LocalMessage

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);
    }
}
Also used : LocalMessage(jetbrains.communicator.core.dispatcher.LocalMessage) WatchDog(jetbrains.communicator.util.WatchDog) MockMessage(jetbrains.communicator.mock.MockMessage) Level(org.apache.log4j.Level) Logger(org.apache.log4j.Logger) Date(java.util.Date)

Example 9 with LocalMessage

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());
}
Also used : LocalMessage(jetbrains.communicator.core.dispatcher.LocalMessage) MockMessage(jetbrains.communicator.mock.MockMessage)

Example 10 with LocalMessage

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());
}
Also used : TransportEvent(jetbrains.communicator.core.transport.TransportEvent) MockMessage(jetbrains.communicator.mock.MockMessage) Message(jetbrains.communicator.core.dispatcher.Message) LocalMessage(jetbrains.communicator.core.dispatcher.LocalMessage) MockTransport(jetbrains.communicator.mock.MockTransport) MockMessage(jetbrains.communicator.mock.MockMessage)

Aggregations

LocalMessage (jetbrains.communicator.core.dispatcher.LocalMessage)20 IncomingLocalMessage (jetbrains.communicator.idea.sendMessage.IncomingLocalMessage)7 MockMessage (jetbrains.communicator.mock.MockMessage)7 Date (java.util.Date)6 TransportEvent (jetbrains.communicator.core.transport.TransportEvent)4 ArrayList (java.util.ArrayList)2 EventVisitor (jetbrains.communicator.core.EventVisitor)2 User (jetbrains.communicator.core.users.User)2 SendMessageEvent (jetbrains.communicator.ide.SendMessageEvent)2 BaseLocalMessage (jetbrains.communicator.idea.BaseLocalMessage)2 IncomingCodePointerMessage (jetbrains.communicator.idea.codePointer.IncomingCodePointerMessage)2 IncomingStacktraceMessage (jetbrains.communicator.idea.sendMessage.IncomingStacktraceMessage)2 MockTransport (jetbrains.communicator.mock.MockTransport)2 File (java.io.File)1 Message (jetbrains.communicator.core.dispatcher.Message)1 CodePointerEvent (jetbrains.communicator.core.transport.CodePointerEvent)1 MessageEvent (jetbrains.communicator.core.transport.MessageEvent)1 StacktraceEvent (jetbrains.communicator.core.transport.StacktraceEvent)1 CodePointer (jetbrains.communicator.core.vfs.CodePointer)1 SendCodePointerEvent (jetbrains.communicator.ide.SendCodePointerEvent)1