Exemple #1
0
 @Test
 public void shouldEventIncommingMessages() {
   final Chat chat = manager.open(uri("someone@domain"));
   final MessageTestHandler handler = new MessageTestHandler();
   chat.addMessageReceivedHandler(handler);
   session.receives(
       "<message type='chat' id='purplee8b92642' to='user@domain' "
           + "from='someone@domain'><x xmlns='jabber:x:event'/><active"
           + "xmlns='http://jabber.org/protocol/chatstates'/></message>");
   assertTrue(handler.isCalledOnce());
 }
Exemple #2
0
  @Test
  public void shouldOpenDifferentsChatsForDifferentDomains() {
    final Chat chatCom = manager.open(uri("*****@*****.**"));
    final MessageTestHandler handlerCom = new MessageTestHandler();
    chatCom.addMessageReceivedHandler(handlerCom);
    assertTrue("com listener empty", handlerCom.isNotCalled());

    final Chat chatOrg = manager.open(uri("*****@*****.**"));
    final MessageTestHandler handlerOrg = new MessageTestHandler();
    chatOrg.addMessageReceivedHandler(handlerOrg);
    assertTrue("org listener empty", handlerCom.isNotCalled());

    session.receives(new Message("message com 2", MYSELF, uri("*****@*****.**")));
    assertTrue("com has one message", handlerCom.isCalledOnce());
    assertTrue("org has no message", handlerOrg.isNotCalled());
  }