Search in sources :

Example 21 with XmlPullParser

use of org.jivesoftware.smack.xml.XmlPullParser in project Smack by igniterealtime.

the class DataFormsXmlElementProvider method parse.

@Override
public DataFormsXmlElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws IOException, XmlPullParserException, SmackParsingException {
    XmlPullParser.TagEvent tagEvent = parser.nextTag();
    final StandardExtensionElement standardExtensionElement;
    if (tagEvent == XmlPullParser.TagEvent.START_ELEMENT) {
        standardExtensionElement = StandardExtensionElementProvider.INSTANCE.parse(parser);
    } else {
        standardExtensionElement = null;
    }
    return new DataFormsXmlElement(standardExtensionElement);
}
Also used : StandardExtensionElement(org.jivesoftware.smack.packet.StandardExtensionElement) XmlPullParser(org.jivesoftware.smack.xml.XmlPullParser) DataFormsXmlElement(org.jivesoftware.smackx.xmlelement.element.DataFormsXmlElement)

Example 22 with XmlPullParser

use of org.jivesoftware.smack.xml.XmlPullParser in project Smack by igniterealtime.

the class AcknowledgedExtensionTest method checkDisplayedProvider.

@Test
public void checkDisplayedProvider() throws Exception {
    XmlPullParser parser = PacketParserUtils.getParserFor(acknowledgedExtension);
    AcknowledgedExtension acknowledgedExtension1 = new AcknowledgedProvider().parse(parser);
    assertEquals("message-1", acknowledgedExtension1.getId());
    Message message = PacketParserUtils.parseStanza(acknowledgedMessageStanza);
    AcknowledgedExtension acknowledgedExtension2 = AcknowledgedExtension.from(message);
    assertEquals("message-1", acknowledgedExtension2.getId());
}
Also used : Message(org.jivesoftware.smack.packet.Message) AcknowledgedProvider(org.jivesoftware.smackx.chat_markers.provider.AcknowledgedProvider) XmlPullParser(org.jivesoftware.smack.xml.XmlPullParser) AcknowledgedExtension(org.jivesoftware.smackx.chat_markers.element.ChatMarkersElements.AcknowledgedExtension) Test(org.junit.jupiter.api.Test)

Example 23 with XmlPullParser

use of org.jivesoftware.smack.xml.XmlPullParser in project Smack by igniterealtime.

the class RetractedElementProvider method parse.

@Override
public RetractedElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException, ParseException {
    Date date = ParserUtils.getDateFromXep82String(parser.getAttributeValue("", RetractedElement.ATTR_STAMP));
    OriginIdElement originIdElement = null;
    while (originIdElement == null) {
        XmlPullParser.TagEvent tag = parser.nextTag();
        if (tag == XmlPullParser.TagEvent.START_ELEMENT && OriginIdElement.ELEMENT.equals(parser.getName()) && StableUniqueStanzaIdManager.NAMESPACE.equals(parser.getNamespace())) {
            originIdElement = OriginIdProvider.INSTANCE.parse(parser);
        }
    }
    return new RetractedElement(date, originIdElement);
}
Also used : RetractedElement(org.jivesoftware.smackx.message_retraction.element.RetractedElement) XmlPullParser(org.jivesoftware.smack.xml.XmlPullParser) OriginIdElement(org.jivesoftware.smackx.sid.element.OriginIdElement) Date(java.util.Date)

Example 24 with XmlPullParser

use of org.jivesoftware.smack.xml.XmlPullParser in project Smack by igniterealtime.

the class CarbonTest method carbonReceivedTest.

@Test
public void carbonReceivedTest() throws Exception {
    XmlPullParser parser;
    String control;
    CarbonExtension cc;
    control = XMLBuilder.create("received").e("forwarded").a("xmlns", "urn:xmpp:forwarded:0").e("message").a("from", "romeo@montague.com").asString(outputProperties);
    parser = PacketParserUtils.getParserFor(control);
    cc = new CarbonManagerProvider().parse(parser);
    assertEquals(CarbonExtension.Direction.received, cc.getDirection());
    // check end of tag
    assertEquals(XmlPullParser.Event.END_ELEMENT, parser.getEventType());
    assertEquals("received", parser.getName());
}
Also used : CarbonManagerProvider(org.jivesoftware.smackx.carbons.provider.CarbonManagerProvider) CarbonExtension(org.jivesoftware.smackx.carbons.packet.CarbonExtension) XmlPullParser(org.jivesoftware.smack.xml.XmlPullParser) ExperimentalInitializerTest(org.jivesoftware.smackx.ExperimentalInitializerTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 25 with XmlPullParser

use of org.jivesoftware.smack.xml.XmlPullParser in project Smack by igniterealtime.

the class DisplayedExtensionTest method checkDisplayedProvider.

@Test
public void checkDisplayedProvider() throws Exception {
    XmlPullParser parser = PacketParserUtils.getParserFor(displayedExtension);
    DisplayedExtension displayedExtension1 = new DisplayedProvider().parse(parser);
    assertEquals("message-1", displayedExtension1.getId());
    Message message = PacketParserUtils.parseStanza(displayedMessageStanza);
    DisplayedExtension displayedExtension2 = DisplayedExtension.from(message);
    assertEquals("message-1", displayedExtension2.getId());
}
Also used : Message(org.jivesoftware.smack.packet.Message) DisplayedExtension(org.jivesoftware.smackx.chat_markers.element.ChatMarkersElements.DisplayedExtension) XmlPullParser(org.jivesoftware.smack.xml.XmlPullParser) DisplayedProvider(org.jivesoftware.smackx.chat_markers.provider.DisplayedProvider) Test(org.junit.jupiter.api.Test)

Aggregations

XmlPullParser (org.jivesoftware.smack.xml.XmlPullParser)139 Test (org.junit.jupiter.api.Test)69 Message (org.jivesoftware.smack.packet.Message)15 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 Date (java.util.Date)12 ExtensionElement (org.jivesoftware.smack.packet.ExtensionElement)11 Jid (org.jxmpp.jid.Jid)11 IOException (java.io.IOException)10 ArrayList (java.util.ArrayList)10 XmlPullParserException (org.jivesoftware.smack.xml.XmlPullParserException)10 EnumSource (org.junit.jupiter.params.provider.EnumSource)9 IQ (org.jivesoftware.smack.packet.IQ)8 Test (org.junit.Test)8 MarkupElement (org.jivesoftware.smackx.message_markup.element.MarkupElement)7 MarkupElementProvider (org.jivesoftware.smackx.message_markup.provider.MarkupElementProvider)7 XmlElement (org.jivesoftware.smack.packet.XmlElement)5 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 NamedElement (org.jivesoftware.smack.packet.NamedElement)4 HttpOverXmppResp (org.jivesoftware.smackx.hoxt.packet.HttpOverXmppResp)4