use of org.jivesoftware.smackx.sid.element.StanzaIdElement in project Smack by igniterealtime.
the class StableUniqueStanzaIdTest method fromMessageTest.
@Test
public void fromMessageTest() {
MessageBuilder messageBuilder = StanzaBuilder.buildMessage();
Message message = messageBuilder.build();
assertFalse(OriginIdElement.hasOriginId(message));
assertFalse(StanzaIdElement.hasStanzaId(message));
OriginIdElement.addTo(messageBuilder);
message = messageBuilder.build();
assertTrue(OriginIdElement.hasOriginId(message));
StanzaIdElement stanzaId = new StanzaIdElement("alice@wonderland.lit");
message.addExtension(stanzaId);
assertTrue(StanzaIdElement.hasStanzaId(message));
assertEquals(stanzaId, StanzaIdElement.getStanzaId(message));
}
use of org.jivesoftware.smackx.sid.element.StanzaIdElement in project Smack by igniterealtime.
the class StableUniqueStanzaIdTest method stanzaIdProviderTest.
@Test
public void stanzaIdProviderTest() throws Exception {
String xml = "<stanza-id xmlns='urn:xmpp:sid:0' id='de305d54-75b4-431b-adb2-eb6b9e546013' by='alice@wonderland.lit' />";
StanzaIdElement element = new StanzaIdElement("de305d54-75b4-431b-adb2-eb6b9e546013", "alice@wonderland.lit");
assertEquals("de305d54-75b4-431b-adb2-eb6b9e546013", element.getId());
assertEquals("alice@wonderland.lit", element.getBy());
assertXmlSimilar(xml, element.toXML().toString());
StanzaIdElement parsed = StanzaIdProvider.INSTANCE.parse(TestUtils.getParser(xml));
assertEquals(element.getId(), parsed.getId());
assertEquals(element.getBy(), parsed.getBy());
}
Aggregations