Search in sources :

Example 21 with MockMessage

use of jetbrains.communicator.mock.MockMessage in project intellij-plugins by JetBrains.

the class LocalMessageDispatcherTest method testHistory.

public void testHistory() throws Exception {
    assertEquals(0, myDispatcher.getHistory(myUser, null).length);
    MockMessage message = new MockMessage();
    myDispatcher.addPendingMessage(myUser, message);
    assertEquals(1, myDispatcher.getPendingMessages(myUser).length);
    assertEquals(0, myDispatcher.getHistory(myUser, null).length);
    myDispatcher.sendNow(myUser, message);
    assertEquals(0, myDispatcher.getPendingMessages(myUser).length);
    assertEquals(1, myDispatcher.getHistory(myUser, null).length);
    MockMessage message2 = new MockMessage();
    myDispatcher.sendNow(myUser, message2);
    LocalMessage[] history = myDispatcher.getHistory(myUser, null);
    assertEquals(2, history.length);
    assertSame(message, history[0]);
    assertSame(message2, history[1]);
}
Also used : LocalMessage(jetbrains.communicator.core.dispatcher.LocalMessage) MockMessage(jetbrains.communicator.mock.MockMessage)

Example 22 with MockMessage

use of jetbrains.communicator.mock.MockMessage in project intellij-plugins by JetBrains.

the class LocalMessageDispatcherTest method testHistoryInSeveralFiles.

public void testHistoryInSeveralFiles() throws Exception {
    myDispatcher.sendNow(myUser, new MockMessage(new Date()));
    myDispatcher.sendNow(myUser, new MockMessage(yesterday()));
    Thread.sleep(SAVE_WAIT_TIMEOUT);
    assertEquals(2, new File(myIdeFacade.getCacheDir(), "history").listFiles().length);
    LocalMessageDispatcherImpl localMessageDispatcher = createLocalMessageDispatcher();
    LocalMessage[] messages = localMessageDispatcher.getHistory(myUser, a_moment_ago());
    assertEquals(1, messages.length);
    messages = localMessageDispatcher.getHistory(myUser, new Date(System.currentTimeMillis() - 1000 * 3601 * 24));
    assertEquals(2, messages.length);
}
Also used : LocalMessage(jetbrains.communicator.core.dispatcher.LocalMessage) MockMessage(jetbrains.communicator.mock.MockMessage) File(java.io.File) Date(java.util.Date)

Aggregations

MockMessage (jetbrains.communicator.mock.MockMessage)22 LocalMessage (jetbrains.communicator.core.dispatcher.LocalMessage)7 Date (java.util.Date)6 MockTransport (jetbrains.communicator.mock.MockTransport)3 File (java.io.File)2 ArrayList (java.util.ArrayList)1 Message (jetbrains.communicator.core.dispatcher.Message)1 TransportEvent (jetbrains.communicator.core.transport.TransportEvent)1 UserEvent (jetbrains.communicator.core.users.UserEvent)1 SendMessageEvent (jetbrains.communicator.ide.SendMessageEvent)1 MockUser (jetbrains.communicator.mock.MockUser)1 WaitFor (jetbrains.communicator.util.WaitFor)1 WatchDog (jetbrains.communicator.util.WatchDog)1 Level (org.apache.log4j.Level)1 Logger (org.apache.log4j.Logger)1