Beispiel #1
0
 @Test
 public void managerShouldCreateOneChatForSameResource() {
   final ChatChangedTestHandler handler = addChatCreatedHandler();
   session.receives(new Message("message 1", MYSELF, uri("source@domain/resource1")));
   session.receives(new Message("message 2", MYSELF, uri("source@domain/resource1")));
   assertEquals(1, handler.getCalledTimes());
 }
Beispiel #2
0
 @Test
 public void shouldReuseChatIfNotResouceSpecified() {
   final ChatChangedTestHandler handler = addChatCreatedHandler();
   session.receives(new Message("message 1", MYSELF, uri("source@domain")));
   session.receives(new Message("message 2", MYSELF, uri("source@domain/resource1")));
   assertTrue(handler.isCalledOnce());
 }
Beispiel #3
0
 @Test
 public void shouldReuseChatWhenAnsweringWithDifferentResources() {
   final ChatChangedTestHandler handler = addChatCreatedHandler();
   final Chat chat = manager.open(uri("someone@domain"));
   assertTrue(handler.isCalledOnce());
   assertEquals(chat, handler.getLastChat());
   session.receives(new Message("answer", MYSELF, uri("someone@domain/resource")));
   assertTrue(handler.isCalledOnce());
 }
Beispiel #4
0
  @Test
  public void chatStateDontFireOnChatCreatedButMustAfterOpenChat() {
    final Message message = new Message(null, MYSELF, OTHER);
    message.addChild("gone", ChatStateManager.XMLNS);

    final ChatChangedTestHandler handler = addChatCreatedHandler();
    session.receives(message);
    assertTrue(handler.isNotCalled());
    manager.open(OTHER);
    assertTrue(handler.isCalled());
  }
Beispiel #5
0
 @Test
 public void shouldAcceptInvitations() {
   ChatChangedTestHandler handler = new ChatChangedTestHandler();
   ChatProperties properties = new ChatProperties(USER);
   manager.addChatChangedHandler(handler);
   RoomInvitation invitation =
       new RoomInvitation(
           uri("friend@host/resource"), uri("*****@*****.**"), "theReason", properties);
   manager.acceptRoomInvitation(invitation);
   assertEquals(2, handler.getCalledTimes());
   assertEquals(ChangeTypes.created, handler.getEvent(0).getChangeType());
   assertEquals(ChangeTypes.opened, handler.getEvent(1).getChangeType());
 }
Beispiel #6
0
 @Test
 public void roomInvitationsShouldDontFireOnChatCreated() {
   final ChatChangedTestHandler handler = addChatCreatedHandler();
   session.receives(
       "<message to='"
           + MYSELF
           + "' from='someroom@domain'><x xmlns='http://jabber.org/protocol/muc#user'>"
           + "<invite from='"
           + OTHER
           + "'><reason>Join to our conversation</reason></invite>"
           + "</x><x jid='someroom@domain' xmlns='jabber:x:conference' /></message>");
   assertTrue(handler.isNotCalled());
 }