use of org.xmpp.packet.Message in project Openfire by igniterealtime.
the class OfflineMessageStoreTest method shouldNotStoreEmptyChatMessagesWithOnlyChatStates.
@Test
public void shouldNotStoreEmptyChatMessagesWithOnlyChatStates() {
Message message = new Message();
message.setType(Message.Type.chat);
PacketExtension chatState = new PacketExtension("composing", "http://jabber.org/protocol/chatstates");
message.addExtension(chatState);
assertFalse(OfflineMessageStore.shouldStoreMessage(message));
}
use of org.xmpp.packet.Message in project Openfire by igniterealtime.
the class OfflineMessageStoreTest method shouldNotStoreEmptyChatMessages.
@Test
public void shouldNotStoreEmptyChatMessages() {
// XEP-0160: "chat" message types SHOULD be stored offline unless they only contain chat state notifications
Message message = new Message();
message.setType(Message.Type.chat);
assertFalse(OfflineMessageStore.shouldStoreMessage(message));
}
use of org.xmpp.packet.Message in project Openfire by igniterealtime.
the class OfflineMessageStoreTest method shouldStoreNormalMessages.
@Test
public void shouldStoreNormalMessages() {
// XEP-0160: Messages with a 'type' attribute whose value is "normal" (or messages with no 'type' attribute) SHOULD be stored offline.
Message message = new Message();
message.setType(Message.Type.normal);
assertTrue(OfflineMessageStore.shouldStoreMessage(message));
Message message2 = new Message();
assertTrue(OfflineMessageStore.shouldStoreMessage(message2));
}
use of org.xmpp.packet.Message in project Openfire by igniterealtime.
the class HttpSessionDeliverable method testNamespaceOnStanzaWithNamespace.
/**
* Verifies that the default namespace is not set on stanzas that already have defined a default namespace.
*
* @see <a href="https://igniterealtime.org/issues/browse/OF-1087">OF-1087</a>
*/
@Test
public void testNamespaceOnStanzaWithNamespace() throws Exception {
// Setup fixture
final Message message = new Message();
message.getElement().setQName(QName.get("message", "unit:test:preexisting:namespace"));
message.setTo("unittest@example.org/test");
message.addChildElement("unittest", "unit:test:namespace");
final List<Packet> packets = new ArrayList<>();
packets.add(message);
// Execute system under test
final HttpSession.Deliverable deliverable = new HttpSession.Deliverable(packets);
final String result = deliverable.getDeliverable();
// verify results
// Note that this assertion depends on the Openfire XML parser-specific ordering of attributes.
assertEquals("<message xmlns=\"unit:test:preexisting:namespace\" to=\"unittest@example.org/test\"><unittest xmlns=\"unit:test:namespace\"/></message>", result);
}
use of org.xmpp.packet.Message in project Openfire by igniterealtime.
the class HttpSessionDeliverable method testNamespaceOnStanza.
/**
* Verifies that the default namespace is set on (non-empty) stanzas.
*
* @see <a href="https://igniterealtime.org/issues/browse/OF-1087">OF-1087</a>
*/
@Test
public void testNamespaceOnStanza() throws Exception {
// Setup fixture
final Message message = new Message();
message.setTo("unittest@example.org/test");
message.addChildElement("unittest", "unit:test:namespace");
final List<Packet> packets = new ArrayList<>();
packets.add(message);
// Execute system under test
final HttpSession.Deliverable deliverable = new HttpSession.Deliverable(packets);
final String result = deliverable.getDeliverable();
// verify results
// Note that this assertion depends on the Openfire XML parser-specific ordering of attributes.
assertEquals("<message to=\"unittest@example.org/test\" xmlns=\"jabber:client\"><unittest xmlns=\"unit:test:namespace\"/></message>", result);
}
Aggregations