mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 12:02:05 +01:00
Merge pull request #623 from hamed-sb/master
[core] fix toXml for UnparsedIQ
This commit is contained in:
commit
5633d0e6c2
2 changed files with 23 additions and 1 deletions
|
@ -16,6 +16,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smack.packet;
|
package org.jivesoftware.smack.packet;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An IQ stanzas that could not be parsed because no provider was found.
|
* An IQ stanzas that could not be parsed because no provider was found.
|
||||||
*/
|
*/
|
||||||
|
@ -34,7 +36,12 @@ public class UnparsedIQ extends IQ {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
|
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
|
||||||
|
if (StringUtils.isEmpty(content)) {
|
||||||
|
xml.setEmptyElement();
|
||||||
|
} else {
|
||||||
|
xml.rightAngleBracket();
|
||||||
xml.escape(content);
|
xml.escape(content);
|
||||||
|
}
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,4 +58,19 @@ public class IqTest {
|
||||||
IQ iq = PacketParserUtils.parseIQ(parser);
|
IQ iq = PacketParserUtils.parseIQ(parser);
|
||||||
assertXmlSimilar(iqXml, iq.toXML());
|
assertXmlSimilar(iqXml, iq.toXML());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@EnumSource(SmackTestUtil.XmlPullParserKind.class)
|
||||||
|
public void testUnparsedIq(SmackTestUtil.XmlPullParserKind parserKind) throws Exception {
|
||||||
|
final String iqXml = "<iq xmlns='jabber:client' type='get' id='test-1'>" +
|
||||||
|
"<query xmlns='jabber:iq:version'/>" +
|
||||||
|
"</iq>";
|
||||||
|
final String expected = "<iq xmlns='jabber:client' id='test-1' type='get'>"
|
||||||
|
+ "<query xmlns='jabber:iq:version'><query xmlns='jabber:iq:version'/></query>"
|
||||||
|
+ "</iq>";
|
||||||
|
|
||||||
|
XmlPullParser parser = SmackTestUtil.getParserFor(iqXml, "iq", parserKind);
|
||||||
|
IQ iq = PacketParserUtils.parseIQ(parser);
|
||||||
|
assertXmlSimilar(expected, iq.toXML());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue