Search in sources :

Example 1 with BlockQuoteElement

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

the class MessageMarkupTest method blockQuoteTest.

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

Example 2 with BlockQuoteElement

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

the class MessageMarkupTest method nestedBlockQuoteTest.

@Test
public void nestedBlockQuoteTest() throws Exception {
    String xml = "<markup xmlns='urn:xmpp:markup:0'>" + "<bquote start='0' end='57'/>" + "<bquote start='11' end='34'/>" + "</markup>";
    MarkupElement.Builder m = MarkupElement.getBuilder();
    m.setBlockQuote(0, 57);
    m.setBlockQuote(11, 34);
    assertXmlSimilar(xml, m.build().toXML().toString());
    XmlPullParser parser = TestUtils.getParser(xml);
    MarkupElement parsed = new MarkupElementProvider().parse(parser);
    List<MarkupElement.MarkupChildElement> children = parsed.getChildElements();
    assertEquals(2, children.size());
    BlockQuoteElement q1 = (BlockQuoteElement) children.get(0);
    BlockQuoteElement q2 = (BlockQuoteElement) children.get(1);
    assertEquals(0, q1.getStart());
    assertEquals(57, q1.getEnd());
    assertEquals(11, q2.getStart());
    assertEquals(34, q2.getEnd());
}
Also used : MarkupElementProvider(org.jivesoftware.smackx.message_markup.provider.MarkupElementProvider) BlockQuoteElement(org.jivesoftware.smackx.message_markup.element.BlockQuoteElement) XmlPullParser(org.jivesoftware.smack.xml.XmlPullParser) MarkupElement(org.jivesoftware.smackx.message_markup.element.MarkupElement) Test(org.junit.jupiter.api.Test)

Aggregations

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