From 1836537c42966f50d45fdf22e184e875e6cc8e84 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 20 May 2024 15:12:11 +0200 Subject: [PATCH] [core] Add unit test for IQ parsing Motivated by https://discourse.igniterealtime.org/t/question-about-tigase-server-8-3-1-and-smack-4-4-7/93796/ --- .../org/jivesoftware/smack/packet/IqTest.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/smack-core/src/test/java/org/jivesoftware/smack/packet/IqTest.java b/smack-core/src/test/java/org/jivesoftware/smack/packet/IqTest.java index b8f192bd7..041c66981 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/packet/IqTest.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/packet/IqTest.java @@ -1,6 +1,6 @@ /** * - * Copyright © 2023 Florian Schmaus + * Copyright © 2023-2024 Florian Schmaus * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,13 @@ package org.jivesoftware.smack.packet; import static org.jivesoftware.smack.test.util.XmlAssertUtil.assertXmlSimilar; +import org.jivesoftware.smack.test.util.SmackTestUtil; +import org.jivesoftware.smack.util.PacketParserUtils; +import org.jivesoftware.smack.xml.XmlPullParser; + import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; public class IqTest { @@ -35,4 +41,21 @@ public class IqTest { assertXmlSimilar(expected, errorIq.toXML()); } + @ParameterizedTest + @EnumSource(SmackTestUtil.XmlPullParserKind.class) + public void testIqWithXmlns(SmackTestUtil.XmlPullParserKind parserKind) throws Exception { + final String iqXml = "" + + "" + + "foo@tigase.mydomain.org/myresource" + + "" + + ""; + final String xml = + "" + + iqXml + + ""; + + XmlPullParser parser = SmackTestUtil.getParserFor(xml, "iq", parserKind); + IQ iq = PacketParserUtils.parseIQ(parser); + assertXmlSimilar(iqXml, iq.toXML()); + } }