mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-22 02:27:58 +01:00
[core] Fix parseContentDepthWithRoundtrip() and add tests
This commit is contained in:
parent
821bdf6d86
commit
ca497a2199
2 changed files with 38 additions and 3 deletions
|
@ -377,10 +377,9 @@ public class PacketParserUtils {
|
|||
outerloop: while (true) {
|
||||
switch (event) {
|
||||
case START_ELEMENT:
|
||||
if (startElementJustSeen) {
|
||||
sb.rightAngleBracket();
|
||||
}
|
||||
startElementJustSeen = true;
|
||||
String openElementTag = parser.getText();
|
||||
sb.append(openElementTag);
|
||||
break;
|
||||
case END_ELEMENT:
|
||||
boolean isEmptyElement = false;
|
||||
|
|
|
@ -854,4 +854,40 @@ public class PacketParserUtilsTest {
|
|||
StanzaError error = PacketParserUtils.parseError(parser);
|
||||
assertEquals(text, error.getDescriptiveText());
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@EnumSource(SmackTestUtil.XmlPullParserKind.class)
|
||||
public void testParseElementSimple(SmackTestUtil.XmlPullParserKind parserKind) throws TransformerException, ParserConfigurationException, FactoryConfigurationError, XmlPullParserException, IOException {
|
||||
String unknownElement = XMLBuilder.create("unknown-element")
|
||||
.ns("https://example.org/non-existent")
|
||||
.e("inner")
|
||||
.t("test")
|
||||
.asString(outputProperties);
|
||||
|
||||
XmlPullParser xmlPullParser = SmackTestUtil.getParserFor(unknownElement, parserKind);
|
||||
|
||||
CharSequence unknownElementParsed = PacketParserUtils.parseElement(xmlPullParser);
|
||||
assertXmlSimilar(unknownElement, unknownElementParsed);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@EnumSource(SmackTestUtil.XmlPullParserKind.class)
|
||||
public void testParseElementExtended(SmackTestUtil.XmlPullParserKind parserKind) throws TransformerException, ParserConfigurationException, FactoryConfigurationError, XmlPullParserException, IOException {
|
||||
String unknownElement = XMLBuilder.create("unknown-element")
|
||||
.ns("https://example.org/non-existent")
|
||||
.a("attribute-outer", "foo")
|
||||
.e("inner")
|
||||
.a("attribute-inner", "bar")
|
||||
.a("attribute-inner-2", "baz")
|
||||
.t("test")
|
||||
.up()
|
||||
.e("empty-element")
|
||||
.up()
|
||||
.asString(outputProperties);
|
||||
|
||||
XmlPullParser xmlPullParser = SmackTestUtil.getParserFor(unknownElement, parserKind);
|
||||
|
||||
CharSequence unknownElementParsed = PacketParserUtils.parseElement(xmlPullParser);
|
||||
assertXmlSimilar(unknownElement, unknownElementParsed);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue