Search in sources :

Example 16 with MockMessage

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

the class AbstractMessageDispatcherTest method testUserDeleted.

public void testUserDeleted() throws Exception {
    MockMessage failedMessage = new MockMessage(false);
    myDispatcher.performDispatch(myUser, failedMessage);
    getBroadcaster().fireEvent(new UserEvent.Removed(myUser));
    assertEquals("Queue should be cleared when user is deleted", 0, myDispatcher.getPendingMessages(myUser).length);
}
Also used : MockMessage(jetbrains.communicator.mock.MockMessage) UserEvent(jetbrains.communicator.core.users.UserEvent)

Example 17 with MockMessage

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

the class AbstractMessageDispatcherTest method testSuccessfulSendingOfPendingEvent.

public void testSuccessfulSendingOfPendingEvent() throws Exception {
    myUser.setOnline(true);
    MockMessage failedMessage = new MockMessage(false);
    myDispatcher.performDispatch(myUser, failedMessage);
    failedMessage.setSendSuccessful(true);
    myDispatcher.performDispatch(myUser, failedMessage);
    assertEquals("If sent successful, remove from pending queue", 0, myDispatcher.getPendingMessages(myUser).length);
}
Also used : MockMessage(jetbrains.communicator.mock.MockMessage)

Example 18 with MockMessage

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

the class AbstractMessageDispatcherTest method testMessagesQueue.

public void testMessagesQueue() throws Exception {
    assertEquals("No pending messages", 0, myDispatcher.getPendingMessages(myUser).length);
    myDispatcher.performDispatch(myUser, new MockMessage());
    assertEquals("Sent successfully, queue is still empty", 0, myDispatcher.getPendingMessages(myUser).length);
    // queue failed message
    MockMessage failedMessage = new MockMessage(false);
    myDispatcher.performDispatch(myUser, failedMessage);
    assertEquals("Failed message should be queued", 1, myDispatcher.getPendingMessages(myUser).length);
    assertSame(failedMessage, myDispatcher.getPendingMessages(myUser)[0]);
}
Also used : MockMessage(jetbrains.communicator.mock.MockMessage)

Example 19 with MockMessage

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

the class AbstractMessageDispatcherTest method testSendSameMessageTwice.

public void testSendSameMessageTwice() throws Exception {
    MockMessage failedMessage = new MockMessage(false);
    myDispatcher.performDispatch(myUser, failedMessage);
    myDispatcher.performDispatch(myUser, failedMessage);
    assertEquals("Only one message should be queued", 1, myDispatcher.getPendingMessages(myUser).length);
}
Also used : MockMessage(jetbrains.communicator.mock.MockMessage)

Example 20 with MockMessage

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

the class LocalMessageDispatcherTest method testClearHistory.

public void testClearHistory() throws Exception {
    assertTrue(myDispatcher.isHistoryEmpty());
    MockMessage message = new MockMessage();
    myDispatcher.sendNow(myUser, message);
    myDispatcher.clearHistory();
    assertEquals(0, myDispatcher.getHistory(myUser, null).length);
}
Also used : MockMessage(jetbrains.communicator.mock.MockMessage)

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