Search in sources :

Example 1 with ListElement

use of org.jivesoftware.smackx.message_markup.element.ListElement in project Smack by igniterealtime.

the class MessageMarkupTest method listTest.

@Test
public void listTest() throws Exception {
    String xml = "<markup xmlns='urn:xmpp:markup:0'>" + "<list start='31' end='89'>" + "<li start='31'/>" + "<li start='47'/>" + "<li start='61'/>" + "<li start='69'/>" + "</list>" + "</markup>";
    MarkupElement.Builder m = MarkupElement.getBuilder();
    m = m.beginList().addEntry(31, 47).addEntry(47, 61).addEntry(61, 69).addEntry(69, 89).endList();
    assertXmlSimilar(xml, m.build().toXML().toString());
    XmlPullParser parser = TestUtils.getParser(xml);
    MarkupElement parsed = new MarkupElementProvider().parse(parser);
    List<MarkupElement.MarkupChildElement> children = parsed.getChildElements();
    assertEquals(1, children.size());
    ListElement list = (ListElement) children.get(0);
    assertEquals(31, list.getStart());
    assertEquals(89, list.getEnd());
    assertEquals(4, list.getEntries().size());
    assertEquals(list.getStart(), list.getEntries().get(0).getStart());
    assertEquals(47, list.getEntries().get(1).getStart());
}
Also used : MarkupElementProvider(org.jivesoftware.smackx.message_markup.provider.MarkupElementProvider) XmlPullParser(org.jivesoftware.smack.xml.XmlPullParser) ListElement(org.jivesoftware.smackx.message_markup.element.ListElement) MarkupElement(org.jivesoftware.smackx.message_markup.element.MarkupElement) Test(org.junit.jupiter.api.Test)

Aggregations

XmlPullParser (org.jivesoftware.smack.xml.XmlPullParser)1 ListElement (org.jivesoftware.smackx.message_markup.element.ListElement)1 MarkupElement (org.jivesoftware.smackx.message_markup.element.MarkupElement)1 MarkupElementProvider (org.jivesoftware.smackx.message_markup.provider.MarkupElementProvider)1 Test (org.junit.jupiter.api.Test)1