Search in sources :

Example 1 with SpanElement

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

the class MessageMarkupTest method deletedTest.

@Test
public void deletedTest() throws Exception {
    String xml = "<markup xmlns='urn:xmpp:markup:0'>" + "<span start='9' end='15'>" + "<deleted/>" + "</span>" + "</markup>";
    MarkupElement.Builder m = MarkupElement.getBuilder();
    m.setDeleted(9, 15);
    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());
    SpanElement spanElement = (SpanElement) children.get(0);
    assertEquals(9, spanElement.getStart());
    assertEquals(15, spanElement.getEnd());
    assertEquals(1, spanElement.getStyles().size());
    assertEquals(SpanElement.SpanStyle.deleted, spanElement.getStyles().iterator().next());
}
Also used : SpanElement(org.jivesoftware.smackx.message_markup.element.SpanElement) MarkupElementProvider(org.jivesoftware.smackx.message_markup.provider.MarkupElementProvider) XmlPullParser(org.jivesoftware.smack.xml.XmlPullParser) MarkupElement(org.jivesoftware.smackx.message_markup.element.MarkupElement) Test(org.junit.jupiter.api.Test)

Example 2 with SpanElement

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

the class MessageMarkupTest method codeTest.

@Test
public void codeTest() throws Exception {
    String xml = "<markup xmlns='urn:xmpp:markup:0'>" + "<span start='9' end='15'>" + "<code/>" + "</span>" + "</markup>";
    MarkupElement.Builder m = MarkupElement.getBuilder();
    m.setCode(9, 15);
    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());
    SpanElement spanElement = (SpanElement) children.get(0);
    assertEquals(9, spanElement.getStart());
    assertEquals(15, spanElement.getEnd());
    assertEquals(1, spanElement.getStyles().size());
    assertEquals(SpanElement.SpanStyle.code, spanElement.getStyles().iterator().next());
}
Also used : SpanElement(org.jivesoftware.smackx.message_markup.element.SpanElement) MarkupElementProvider(org.jivesoftware.smackx.message_markup.provider.MarkupElementProvider) XmlPullParser(org.jivesoftware.smack.xml.XmlPullParser) MarkupElement(org.jivesoftware.smackx.message_markup.element.MarkupElement) Test(org.junit.jupiter.api.Test)

Example 3 with SpanElement

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

the class MessageMarkupTest method emphasisTest.

@Test
public void emphasisTest() throws Exception {
    String xml = "<markup xmlns='urn:xmpp:markup:0'>" + "<span start='9' end='15'>" + "<emphasis/>" + "</span>" + "</markup>";
    MarkupElement.Builder m = MarkupElement.getBuilder();
    m.setEmphasis(9, 15);
    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());
    SpanElement spanElement = (SpanElement) children.get(0);
    assertEquals(9, spanElement.getStart());
    assertEquals(15, spanElement.getEnd());
    assertEquals(1, spanElement.getStyles().size());
    assertEquals(SpanElement.SpanStyle.emphasis, spanElement.getStyles().iterator().next());
}
Also used : SpanElement(org.jivesoftware.smackx.message_markup.element.SpanElement) MarkupElementProvider(org.jivesoftware.smackx.message_markup.provider.MarkupElementProvider) 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)3 MarkupElement (org.jivesoftware.smackx.message_markup.element.MarkupElement)3 SpanElement (org.jivesoftware.smackx.message_markup.element.SpanElement)3 MarkupElementProvider (org.jivesoftware.smackx.message_markup.provider.MarkupElementProvider)3 Test (org.junit.jupiter.api.Test)3