use of org.jivesoftware.smack.xml.XmlPullParser 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());
}
use of org.jivesoftware.smack.xml.XmlPullParser 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());
}
use of org.jivesoftware.smack.xml.XmlPullParser in project Smack by igniterealtime.
the class SpoilerTest method emptySpoilerTest.
@Test
public void emptySpoilerTest() throws Exception {
final String xml = "<spoiler xmlns='urn:xmpp:spoiler:0'/>";
Message message = StanzaBuilder.buildMessage().build();
SpoilerElement.addSpoiler(message);
SpoilerElement empty = (SpoilerElement) message.getExtensionElement(SpoilerElement.ELEMENT, SpoilerManager.NAMESPACE_0);
assertNull(empty.getHint());
assertNull(empty.getLanguage());
assertXmlSimilar(xml, empty.toXML().toString());
XmlPullParser parser = TestUtils.getParser(xml);
SpoilerElement parsed = SpoilerProvider.INSTANCE.parse(parser);
assertXmlSimilar(xml, parsed.toXML().toString());
}
use of org.jivesoftware.smack.xml.XmlPullParser in project Smack by igniterealtime.
the class SpoilerTest method hintSpoilerTest.
@Test
public void hintSpoilerTest() throws Exception {
final String xml = "<spoiler xmlns='urn:xmpp:spoiler:0'>Love story end</spoiler>";
Message message = StanzaBuilder.buildMessage().build();
SpoilerElement.addSpoiler(message, "Love story end");
SpoilerElement withHint = (SpoilerElement) message.getExtensionElement(SpoilerElement.ELEMENT, SpoilerManager.NAMESPACE_0);
assertEquals("Love story end", withHint.getHint());
assertNull(withHint.getLanguage());
assertXmlSimilar(xml, withHint.toXML().toString());
XmlPullParser parser = TestUtils.getParser(xml);
SpoilerElement parsed = SpoilerProvider.INSTANCE.parse(parser);
assertXmlSimilar(xml, parsed.toXML().toString());
}
use of org.jivesoftware.smack.xml.XmlPullParser in project Smack by igniterealtime.
the class SpoilerTest method i18nHintSpoilerTest.
@Test
public void i18nHintSpoilerTest() throws Exception {
final String xml = "<spoiler xml:lang='de' xmlns='urn:xmpp:spoiler:0'>Der Kuchen ist eine Lüge!</spoiler>";
Message message = StanzaBuilder.buildMessage().build();
SpoilerElement.addSpoiler(message, "de", "Der Kuchen ist eine Lüge!");
SpoilerElement i18nHint = (SpoilerElement) message.getExtensionElement(SpoilerElement.ELEMENT, SpoilerManager.NAMESPACE_0);
assertEquals("Der Kuchen ist eine Lüge!", i18nHint.getHint());
assertEquals("de", i18nHint.getLanguage());
assertXmlSimilar(xml, i18nHint.toXML().toString());
XmlPullParser parser = TestUtils.getParser(xml);
SpoilerElement parsed = SpoilerProvider.INSTANCE.parse(parser);
assertEquals(i18nHint.getLanguage(), parsed.getLanguage());
assertXmlSimilar(xml, parsed.toXML().toString());
}
Aggregations