Search in sources :

Example 1 with MessageEvent

use of jetbrains.communicator.core.transport.MessageEvent in project intellij-plugins by JetBrains.

the class JabberTransport_ConnectionTest method testSendCustomMessage_WithoutProvider.

public void testSendCustomMessage_WithoutProvider() throws Exception {
    addEventListener();
    myTransport.sendXmlMessage(mySelf, new TextXmlMessage("some text") {

        @Override
        public String getTagNamespace() {
            return "some namespace";
        }
    });
    new WaitFor(TIMEOUT) {

        @Override
        protected boolean condition() {
            return myEvents.size() > 1;
        }
    };
    IDEtalkEvent event = myEvents.get(1);
    assertTrue("Expect message Event for unknown provider", event instanceof MessageEvent);
    assertEquals("Expect message text", "some text", ((MessageEvent) event).getMessage());
}
Also used : WaitFor(jetbrains.communicator.util.WaitFor) IDEtalkEvent(jetbrains.communicator.core.IDEtalkEvent) MessageEvent(jetbrains.communicator.core.transport.MessageEvent) TextXmlMessage(jetbrains.communicator.core.transport.TextXmlMessage)

Example 2 with MessageEvent

use of jetbrains.communicator.core.transport.MessageEvent in project intellij-plugins by JetBrains.

the class JabberTransport_ConnectionTest method testTimeIsSetInSimpleMessage.

public void testTimeIsSetInSimpleMessage() throws Throwable {
    Message baseMessage = myTransport.createBaseMessage(mySelf, "some text");
    myTransport.getFacade().getConnection().sendPacket(baseMessage);
    new WaitFor(TIMEOUT) {

        @Override
        protected boolean condition() {
            return myEvents.size() > 0;
        }
    };
    long diff = ((MessageEvent) myEvents.get(1)).getWhen().getTime() - System.currentTimeMillis();
    assertTrue("Time should be set for simple Jabber messages: " + diff, Math.abs(diff) < 150);
}
Also used : TextXmlMessage(jetbrains.communicator.core.transport.TextXmlMessage) Message(org.jivesoftware.smack.packet.Message) WaitFor(jetbrains.communicator.util.WaitFor) MessageEvent(jetbrains.communicator.core.transport.MessageEvent)

Example 3 with MessageEvent

use of jetbrains.communicator.core.transport.MessageEvent in project intellij-plugins by JetBrains.

the class JabberTransport_ConnectionTest method testSimpleJabberMessage.

public void testSimpleJabberMessage() throws Throwable {
    Message message = new Message(mySelf.getName(), Message.Type.NORMAL);
    String body = "some текст <>#$%^";
    message.setThread("someThreadId");
    message.setBody(body);
    addEventListener();
    myFacade.getConnection().sendPacket(message);
    new WaitFor(TIMEOUT) {

        @Override
        protected boolean condition() {
            return myEvents.size() > 1;
        }
    };
    IDEtalkEvent event = myEvents.get(1);
    assertTrue("Expect message Event", event instanceof MessageEvent);
    assertEquals("Expect message text", body, ((MessageEvent) event).getMessage());
    assertEquals("Should remember threadId for incoming messages", "someThreadId", myTransport.getThreadId(mySelf));
}
Also used : TextXmlMessage(jetbrains.communicator.core.transport.TextXmlMessage) Message(org.jivesoftware.smack.packet.Message) WaitFor(jetbrains.communicator.util.WaitFor) IDEtalkEvent(jetbrains.communicator.core.IDEtalkEvent) MessageEvent(jetbrains.communicator.core.transport.MessageEvent)

Example 4 with MessageEvent

use of jetbrains.communicator.core.transport.MessageEvent 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]);
}
Also used : EventVisitor(jetbrains.communicator.core.EventVisitor) WaitFor(jetbrains.communicator.util.WaitFor) IDEtalkEvent(jetbrains.communicator.core.IDEtalkEvent) MessageEvent(jetbrains.communicator.core.transport.MessageEvent) IDEtalkAdapter(jetbrains.communicator.core.IDEtalkAdapter)

Example 5 with MessageEvent

use of jetbrains.communicator.core.transport.MessageEvent in project intellij-plugins by JetBrains.

the class EventsProcessorTest method testIncomingMessage_No_Tab_WithoutExpand.

public void testIncomingMessage_No_Tab_WithoutExpand() throws Exception {
    IdeaFlags.EXPAND_ON_MESSAGE.change(false);
    MessageEvent event = EventFactory.createMessageEvent(new MockTransport(), "bob", "text");
    myMock.expects(once()).method("newMessageAvailable").with(eq(myUserModel.createUser("bob", MockTransport.NAME)), eq(event));
    myMock.expects(once()).method("getWindow").will(returnValue(null));
    getBroadcaster().fireEvent(event);
}
Also used : MessageEvent(jetbrains.communicator.core.transport.MessageEvent) MockTransport(jetbrains.communicator.mock.MockTransport)

Aggregations

MessageEvent (jetbrains.communicator.core.transport.MessageEvent)7 WaitFor (jetbrains.communicator.util.WaitFor)4 IDEtalkEvent (jetbrains.communicator.core.IDEtalkEvent)3 TextXmlMessage (jetbrains.communicator.core.transport.TextXmlMessage)3 EventVisitor (jetbrains.communicator.core.EventVisitor)2 MockTransport (jetbrains.communicator.mock.MockTransport)2 Message (org.jivesoftware.smack.packet.Message)2 IDEtalkAdapter (jetbrains.communicator.core.IDEtalkAdapter)1 LocalMessage (jetbrains.communicator.core.dispatcher.LocalMessage)1 CodePointerEvent (jetbrains.communicator.core.transport.CodePointerEvent)1 StacktraceEvent (jetbrains.communicator.core.transport.StacktraceEvent)1 IncomingCodePointerMessage (jetbrains.communicator.idea.codePointer.IncomingCodePointerMessage)1 IncomingLocalMessage (jetbrains.communicator.idea.sendMessage.IncomingLocalMessage)1 IncomingStacktraceMessage (jetbrains.communicator.idea.sendMessage.IncomingStacktraceMessage)1