Package com.calclab.emite.core.stanzas

Examples of com.calclab.emite.core.stanzas.Message


    }
  }
 
  @Override
  public void onMessageReceived(final MessageReceivedEvent event) {
    final Message message = event.getMessage();
    log("Messaged received from " + message.getFrom().toString() + ":" + message.getBody());
  }
View Full Code Here


  /**
   * The simplest way to send a message using the Session object
   */
  private void sendHelloWorldMessage() {
    final Message message = new Message("Hello world!");
    message.setTo(uri("test3@localhost"));
    session.send(message);
  }
View Full Code Here

    assertEquals(uri("sender@domain"), properties.getUri());
  }

  @Test
  public void shouldInitiateCreationWhenMessageBody() {
    final ChatProperties properties = strategy.extractProperties(new Message("body"));
    assertTrue(properties.shouldCreateNewChat());
  }
View Full Code Here

  public void shouldNotInitiateCreationIfMessageHasInvitation() {
    final XMLPacket stanza = XMLBuilder.fromXML("<message to='test1@localhost' " + "from='room@conference.localhost' xmlns='jabber:client' "
        + "type='normal'><x xmlns='http://jabber.org/protocol/muc#user'>" + "<invite from='test1@localhost/emite-1291918896669'><reason />"
        + "</invite></x><x jid='room@conference.localhost' " + "xmlns='jabber:x:conference' />"
        + "<body>test1@localhost/emite-1291918896669 invites you to the room room@conference.localhost</body></message>");
    final ChatProperties properties = strategy.extractProperties(new Message(stanza));
    assertFalse(properties.shouldCreateNewChat());
  }
View Full Code Here

    assertFalse(properties.shouldCreateNewChat());
  }

  @Test
  public void shouldNotInitiateCreationWhenNotBody() {
    final ChatProperties properties = strategy.extractProperties(new Message((String) null));
    assertFalse(properties.shouldCreateNewChat());
  }
View Full Code Here

public class PairChatManagerTests extends AbstractChatManagerTests {

  @Test
  public void shouldBeInitiatedByOtherIfMessageArrives() {
    session.receives(new Message("body", ME, OTHER));
    final Chat chat = manager.open(uri("someone@domain"));
    assertFalse(chat.isInitiatedByMe());
  }
View Full Code Here

  @Test
  public void shouldForwardMessagesToChats() {
    final Chat chat = manager.open(OTHER);
    final MessageReceivedTestHandler handler = new MessageReceivedTestHandler();
    chat.addMessageReceivedHandler(handler);
    session.receives(new Message("body", ME, OTHER));
    assertEquals(1, handler.getCalledTimes());
    session.receives("<message type='chat' id='purplee8b92642' to='me@localhost' " + "from='other@localhost'><x xmlns='jabber:x:event'/><active"
        + "xmlns='http://jabber.org/protocol/chatstates'/></message>");
    assertEquals(2, handler.getCalledTimes());
  }
View Full Code Here

  @Test
  public void shouldReceiveMessages() {
    final MessageReceivedTestHandler handler = new MessageReceivedTestHandler();
    pairChat.addMessageReceivedHandler(handler);
    session.receives(new Message("the body", USER_URI, CHAT_URI));
    assertTrue("should receive messages", handler.isCalledOnce());
  }
View Full Code Here

  @Test
  public void shouldSendNoThreadWhenNotSpecified() {
    final ChatProperties properties = new ChatProperties(CHAT_URI, USER_URI, ChatStatus.locked);
    final PairChat noThreadChat = new PairChat(eventBus, session, properties);
    noThreadChat.setStatus(ChatStatus.ready);
    noThreadChat.send(new Message("the message"));
    session.verifySent("<message from='self@domain/res' to='other@domain/other' " + "type='chat'><body>the message</body></message>");
  }
View Full Code Here

    session.verifySent("<message from='self@domain/res' to='other@domain/other' " + "type='chat'><body>the message</body></message>");
  }

  @Test
  public void shouldSendThreadWhenSpecified() {
    pairChat.send(new Message("the message"));
    session.verifySent("<message from='self@domain/res' to='other@domain/other' type='chat'>"
        + "<body>the message</body><thread>theThread</thread></message>");
  }
View Full Code Here

TOP

Related Classes of com.calclab.emite.core.stanzas.Message

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.