Package com.calclab.emite.core.stanzas

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


import com.calclab.emite.core.stanzas.Message.Type;

public class MessageTest {
  @Test
  public void shouldAddSubject() {
    final Message message = new Message("message", uri("user2@domain/r"), uri("user1@domain/r"));
    message.setSubject("the subject");
    assertEquals("the subject", message.getSubject());
  }
View Full Code Here


    assertEquals("the subject", message.getSubject());
  }

  @Test
  public void shouldNotAddBodyIfNotSpecified() {
    final Message message = new Message();
    assertNull(message.getBody());
    assertEquals(0, message.getXML().getChildren("body").size());
    final Message message2 = new Message(null, uri("other@domain"), uri("me@domain"));
    assertEquals(0, message2.getXML().getChildren("body").size());
  }
View Full Code Here

    assertEquals(0, message2.getXML().getChildren("body").size());
  }

  @Test
  public void shouldRetrieveSubject() {
    final Message message = new Message(XMLBuilder.create("message").childText("subject", "the subject").getXML());
    assertEquals("the subject", message.getSubject());
  }
View Full Code Here

    assertEquals("the subject", message.getSubject());
  }

  @Test
  public void shouldReturnNullThread() {
    final Message message = new Message("message", uri("user2@domain/r"), uri("user1@domain/r"));
    assertEquals(null, message.getThread());
  }
View Full Code Here

    assertEquals(null, message.getThread());
  }

  @Test
  public void shouldReturnUnkownType() {
    final Message message = new Message(XMLBuilder.create("message").attribute("type", "invalid-here").getXML());
    assertSame(Type.normal, message.getType());
  }
View Full Code Here

    assertSame(Type.normal, message.getType());
  }

  @Test
  public void shouldTypeNotSpecifiedType() {
    final Message message = new Message(XMLBuilder.create("message").getXML());
    final Type type = message.getType();
    assertSame(Type.normal, type);
  }
View Full Code Here

  public void shouldEventBeforeSendStanzaEvents() {
    // we need to log in before
    eventBus.fireEvent(new SessionRequestResultEvent(uri("user@domain")));
    final BeforeStanzaSentTestHandler handler = new BeforeStanzaSentTestHandler();
    session.addBeforeStanzaSentHandler(handler);
    final Message packet = new Message();
    session.send(packet);
    assertTrue(handler.isCalledOnce());
    assertSame(packet, handler.getLastEvent().getStanza());
  }
View Full Code Here

  @Test
  public void shouldEventMessages() {
    final MessageReceivedTestHandler handler = new MessageReceivedTestHandler();
    session.addMessageReceivedHandler(handler);
    final Message message = new Message("message");
    connection.receives(message.getXML());
    assertTrue(handler.isCalledOnce());
  }
View Full Code Here

  }

  @Test
  public void shouldQueueOutcomingStanzas() {
    assertEquals(0, connection.getSentSize());
    session.send(new Message("the Message", uri("other@domain")));
    assertEquals(0, connection.getSentSize());
    eventBus.fireEvent(new SessionRequestResultEvent(uri("name@domain/resource")));
    session.setStatus(SessionStatus.ready);
    assertEquals(1, connection.getSentSize());
  }
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.