Example #1
0
 @Test
 public void shouldSendTwoStateIfDiferent() {
   session.receives(
       "<message from='other@domain/other' to='self@domain/res' type='chat'>"
           + "<active xmlns='http://jabber.org/protocol/chatstates'/></message>");
   chatStateManager.setOwnState(ChatState.composing);
   chatStateManager.setOwnState(ChatState.pause);
   session.verifySent(
       "<message from='self@domain/res' to='other@domain/other' type='chat'>"
           + "<composing xmlns='http://jabber.org/protocol/chatstates'/></message>"
           + "<message from='self@domain/res' to='other@domain/other' type='chat'>"
           + "<pause xmlns='http://jabber.org/protocol/chatstates'/></message>");
 }
Example #2
0
 @Test
 public void shouldStopAfterGone() {
   session.receives(
       "<message from='other@domain/other' to='self@domain/res' type='chat'><active /></message>");
   session.receives(
       "<message from='other@domain/other' to='self@domain/res' type='chat'><gone /></message>");
   chatStateManager.setOwnState(ChatStateManager.ChatState.composing);
   chatStateManager.setOwnState(ChatStateManager.ChatState.pause);
   session.verifySent("<message><active /></message>");
   session.verifyNotSent("<message><composing /></message>");
   session.verifyNotSent("<message><pause /></message>");
   session.verifyNotSent("<message><gone /></message>");
 }
Example #3
0
 @Before
 public void beforeTests() {
   session = new SessionTester();
   chatManager = new PairChatManager(session);
   session.setLoggedIn(MYSELF);
   final StateManager stateManager = new StateManager(chatManager);
   chat = chatManager.open(OTHER);
   chatStateManager = stateManager.getChatState(chat);
   stateListener = new MockedListener<ChatState>();
   chatStateManager.onChatStateChanged(stateListener);
 }
Example #4
0
 @Test
 public void shouldStartStateAfterNegotiation() {
   chat.send(new Message("test message"));
   session.receives(
       "<message from='other@domain/other' to='self@domain/res' type='chat'>"
           + "<active xmlns='http://jabber.org/protocol/chatstates'/></message>");
   final Message message = new Message(MYSELF, OTHER, "test message");
   message.addChild(ChatStateManager.ChatState.active.toString(), ChatStateManager.XMLNS);
   chatStateManager.setOwnState(ChatStateManager.ChatState.composing);
   session.verifySent(
       message.toString()
           + "<message from='self@domain/res' to='other@domain/other' type='chat'>"
           + "<composing xmlns='http://jabber.org/protocol/chatstates'/></message>");
 }
Example #5
0
 @Test
 public void shouldNotSendStateIfNegotiationNotAccepted() {
   chatStateManager.setOwnState(ChatState.composing);
   session.verifySentNothing();
 }