Search in sources :

Example 1 with CodeBlockElement

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

the class MessageMarkupTest method codeBlockTest.

@Test
public void codeBlockTest() throws Exception {
    String xml = "<markup xmlns='urn:xmpp:markup:0'>" + "<bcode start='23' end='48'/>" + "</markup>";
    MarkupElement.Builder m = MarkupElement.getBuilder();
    m.setCodeBlock(23, 48);
    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());
    CodeBlockElement codeBlock = (CodeBlockElement) children.get(0);
    assertEquals(23, codeBlock.getStart());
    assertEquals(48, codeBlock.getEnd());
}
Also used : MarkupElementProvider(org.jivesoftware.smackx.message_markup.provider.MarkupElementProvider) XmlPullParser(org.jivesoftware.smack.xml.XmlPullParser) CodeBlockElement(org.jivesoftware.smackx.message_markup.element.CodeBlockElement) MarkupElement(org.jivesoftware.smackx.message_markup.element.MarkupElement) Test(org.junit.jupiter.api.Test)

Aggregations

XmlPullParser (org.jivesoftware.smack.xml.XmlPullParser)1 CodeBlockElement (org.jivesoftware.smackx.message_markup.element.CodeBlockElement)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