From e1ed035beb517a38eb0ca66d90465057f1d1409f Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Tue, 7 May 2019 18:51:52 +0200 Subject: [PATCH] Remove xmlunit-lagacy and add xmlunit-assertj --- smack-core/build.gradle | 10 ++- .../smack/compress/packet/FailureTest.java | 6 +- .../smack/packet/MessageTest.java | 18 +++-- .../smack/packet/PresenceTest.java | 16 ++--- .../smack/test/util/XmlUnitUtils.java | 38 +++++++---- .../smack/util/PacketParserUtilsTest.java | 65 +++++++++---------- .../smackx/httpfileupload/SlotCreateTest.java | 4 +- .../httpfileupload/SlotRequestCreateTest.java | 6 +- .../provider/SlotProviderTest.java | 8 +-- .../message_markup/MessageMarkupTest.java | 16 ++--- .../smackx/reference/ReferenceTest.java | 10 +-- .../smackx/sid/StableUniqueStanzaIdTest.java | 6 +- .../smackx/spoiler/SpoilerTest.java | 14 ++-- .../smackx/pubsub/SubscriberUseCases.java | 16 ++--- .../bytestreams/ibb/packet/CloseTest.java | 4 +- .../ibb/packet/DataPacketExtensionTest.java | 4 +- .../bytestreams/ibb/packet/DataTest.java | 4 +- .../bytestreams/ibb/packet/OpenTest.java | 4 +- .../smackx/last_interaction/IdleTest.java | 4 +- .../smackx/mood/MoodConcretisationTest.java | 6 +- .../smackx/mood/MoodElementTest.java | 4 +- .../pubsub/AffiliationsExtensionTest.java | 4 +- .../smackx/pubsub/ItemValidationTest.java | 20 +++--- .../smackx/ox/OpenPgpElementTest.java | 10 +-- .../smackx/ox/PubkeyElementTest.java | 4 +- .../smackx/ox/PublicKeysListElementTest.java | 4 +- .../smackx/ox/SecretkeyElementTest.java | 4 +- 27 files changed, 163 insertions(+), 146 deletions(-) diff --git a/smack-core/build.gradle b/smack-core/build.gradle index c2ce38504..40e9026d6 100644 --- a/smack-core/build.gradle +++ b/smack-core/build.gradle @@ -14,7 +14,15 @@ dependencies { testCompile project(':smack-xmlparser-xpp3') testCompile "org.jxmpp:jxmpp-jid:$jxmppVersion:tests" testCompile "org.xmlunit:xmlunit-core:$xmlUnitVersion" - testCompile "org.xmlunit:xmlunit-legacy:$xmlUnitVersion" + // Explictily add assertj-core which is a dependency of + // xmlunit-assertj, but gradle fails to resolves it with: + // Execution failed for task ':smack-core:compileTestJava'. + // > Could not resolve all files for configuration ':smack-core:testCompileClasspath'. + // > Could not find org.assertj:assertj-core:. + // Required by: + // project :smack-core > org.xmlunit:xmlunit-assertj:2.6.2 + testCompile "org.assertj:assertj-core:3.11.1" + testCompile "org.xmlunit:xmlunit-assertj:$xmlUnitVersion" testCompile 'com.jamesmurty.utils:java-xmlbuilder:1.2' } diff --git a/smack-core/src/test/java/org/jivesoftware/smack/compress/packet/FailureTest.java b/smack-core/src/test/java/org/jivesoftware/smack/compress/packet/FailureTest.java index aadbdb38e..cbc5ba88f 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/compress/packet/FailureTest.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/compress/packet/FailureTest.java @@ -16,7 +16,7 @@ */ package org.jivesoftware.smack.compress.packet; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar; import java.io.IOException; @@ -35,7 +35,7 @@ public class FailureTest { final String expectedXml = ""; - assertXMLEqual(expectedXml, xml.toString()); + assertXmlSimilar(expectedXml, xml.toString()); } @Test @@ -53,6 +53,6 @@ public class FailureTest { + "" + ""; - assertXMLEqual(expectedXml, xml.toString()); + assertXmlSimilar(expectedXml, xml.toString()); } } diff --git a/smack-core/src/test/java/org/jivesoftware/smack/packet/MessageTest.java b/smack-core/src/test/java/org/jivesoftware/smack/packet/MessageTest.java index b2290aeef..82ff71bf8 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/packet/MessageTest.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/packet/MessageTest.java @@ -16,7 +16,7 @@ */ package org.jivesoftware.smack.packet; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -26,8 +26,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import org.jivesoftware.smack.test.util.XmlUnitUtils; - import org.junit.Test; import org.xml.sax.SAXException; @@ -49,7 +47,7 @@ public class MessageTest { Message messageTypeInConstructor = new Message(null, Message.Type.chat); messageTypeInConstructor.setStanzaId(null); assertEquals(type, messageTypeInConstructor.getType()); - assertXMLEqual(control, messageTypeInConstructor.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); + assertXmlSimilar(control, messageTypeInConstructor.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); controlBuilder = new StringBuilder(); controlBuilder.append(" languages = message.getBodyLanguages(); List controlLanguages = new ArrayList<>(); @@ -183,7 +181,7 @@ public class MessageTest { message.setThread(messageThread); assertEquals(messageThread, message.getThread()); - assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); + assertXmlSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); } @Test @@ -201,7 +199,7 @@ public class MessageTest { Message message = getNewMessage(); message.setLanguage(lang); - assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); + assertXmlSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); } private static Message getNewMessage() { diff --git a/smack-core/src/test/java/org/jivesoftware/smack/packet/PresenceTest.java b/smack-core/src/test/java/org/jivesoftware/smack/packet/PresenceTest.java index c79463b42..9f6adca2e 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/packet/PresenceTest.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/packet/PresenceTest.java @@ -16,7 +16,7 @@ */ package org.jivesoftware.smack.packet; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -43,7 +43,7 @@ public class PresenceTest { Presence presenceTypeInConstructor = new Presence(type); presenceTypeInConstructor.setStanzaId(null); assertEquals(type, presenceTypeInConstructor.getType()); - assertXMLEqual(control, presenceTypeInConstructor.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); + assertXmlSimilar(control, presenceTypeInConstructor.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); controlBuilder = new StringBuilder(); controlBuilder.append("") @@ -155,7 +155,7 @@ public class PresenceTest { Presence presenceModeSet = getNewPresence(); presenceModeSet.setMode(mode2); assertEquals(mode2, presenceModeSet.getMode()); - assertXMLEqual(control, presenceModeSet.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); + assertXmlSimilar(control, presenceModeSet.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); } @Test @@ -183,7 +183,7 @@ public class PresenceTest { Presence presence = getNewPresence(); presence.setLanguage(lang); - assertXMLEqual(control, presence.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); + assertXmlSimilar(control, presence.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); } private static Presence getNewPresence() { diff --git a/smack-core/src/test/java/org/jivesoftware/smack/test/util/XmlUnitUtils.java b/smack-core/src/test/java/org/jivesoftware/smack/test/util/XmlUnitUtils.java index dfde2efc7..18404f70f 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/test/util/XmlUnitUtils.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/test/util/XmlUnitUtils.java @@ -1,6 +1,6 @@ /** * - * Copyright 2014-2018 Florian Schmaus + * Copyright 2014-2019 Florian Schmaus * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,24 +16,36 @@ */ package org.jivesoftware.smack.test.util; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import java.io.StringReader; -import java.io.IOException; +import javax.xml.transform.stream.StreamSource; -import org.custommonkey.xmlunit.Diff; -import org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier; -import org.xml.sax.SAXException; +import org.xmlunit.assertj.CompareAssert; +import org.xmlunit.assertj.XmlAssert; +import org.xmlunit.diff.DefaultNodeMatcher; +import org.xmlunit.diff.ElementSelectors; +import org.xmlunit.input.NormalizedSource; +// TODO: Rename this class to XmlAssertUtil public class XmlUnitUtils { - // TOOD: Remove this method. - public static void assertSimilar(CharSequence expected, CharSequence actual) throws SAXException, IOException { - assertXmlSimilar(expected, actual); + public static void assertXmlNotSimilar(CharSequence xmlOne, CharSequence xmlTwo) { + normalizedCompare(xmlOne, xmlTwo).areNotSimilar(); } - public static void assertXmlSimilar(CharSequence expected, CharSequence actual) throws SAXException, IOException { - Diff diff = new Diff(expected.toString(), actual.toString()); - diff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier()); - assertXMLEqual(diff, true); + public static void assertXmlSimilar(CharSequence expected, CharSequence actual) { + normalizedCompare(expected, actual).areSimilar(); + } + + private static CompareAssert normalizedCompare(CharSequence expectedCharSequence, CharSequence actualCharSequence) { + String expectedString = expectedCharSequence.toString(); + String actualString = actualCharSequence.toString(); + + NormalizedSource expected = new NormalizedSource(new StreamSource(new StringReader(expectedString))); + NormalizedSource actual = new NormalizedSource(new StreamSource(new StringReader(actualString))); + return XmlAssert.assertThat(expected).and(actual) + .ignoreChildNodesOrder() + .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndAllAttributes, ElementSelectors.byNameAndText)) + .normalizeWhitespace(); } } diff --git a/smack-core/src/test/java/org/jivesoftware/smack/util/PacketParserUtilsTest.java b/smack-core/src/test/java/org/jivesoftware/smack/util/PacketParserUtilsTest.java index 1f23eed5a..0df754f8c 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/util/PacketParserUtilsTest.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/util/PacketParserUtilsTest.java @@ -16,8 +16,8 @@ */ package org.jivesoftware.smack.util; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLNotEqual; +import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlNotSimilar; +import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; @@ -46,7 +46,6 @@ import org.jivesoftware.smack.sasl.packet.SaslStreamElements; import org.jivesoftware.smack.sasl.packet.SaslStreamElements.SASLFailure; import org.jivesoftware.smack.test.util.SmackTestUtil; import org.jivesoftware.smack.test.util.TestUtils; -import org.jivesoftware.smack.test.util.XmlUnitUtils; import org.jivesoftware.smack.xml.XmlPullParser; import org.jivesoftware.smack.xml.XmlPullParserException; @@ -91,7 +90,7 @@ public class PacketParserUtilsTest { assertTrue(message.getBodyLanguages().isEmpty()); assertEquals(defaultLanguage, message.getBody(defaultLanguage)); assertNull(message.getBody(otherLanguage)); - assertXMLEqual(control, message.toXML().toString()); + assertXmlSimilar(control, message.toXML().toString()); // message has non-default language, body has no language control = XMLBuilder.create("message") @@ -111,7 +110,7 @@ public class PacketParserUtilsTest { assertTrue(message.getBodyLanguages().isEmpty()); assertEquals(otherLanguage, message.getBody(otherLanguage)); assertNull(message.getBody(defaultLanguage)); - assertXMLEqual(control, message.toXML().toString()); + assertXmlSimilar(control, message.toXML().toString()); // message has no language, body has no language control = XMLBuilder.create("message") @@ -130,7 +129,7 @@ public class PacketParserUtilsTest { assertTrue(message.getBodyLanguages().isEmpty()); assertEquals(defaultLanguage, message.getBody(null)); assertNull(message.getBody(otherLanguage)); - assertXMLEqual(control, message.toXML().toString()); + assertXmlSimilar(control, message.toXML().toString()); // message has no language, body has default language control = XMLBuilder.create("message") @@ -151,7 +150,7 @@ public class PacketParserUtilsTest { assertEquals(defaultLanguage, message.getBody(defaultLanguage)); assertNull(message.getBody(otherLanguage)); - assertXMLEqual(control, message.toXML().toString()); + assertXmlSimilar(control, message.toXML().toString()); // message has no language, body has non-default language control = XMLBuilder.create("message") @@ -172,7 +171,7 @@ public class PacketParserUtilsTest { assertTrue(message.getBodyLanguages().contains(otherLanguage)); assertEquals(otherLanguage, message.getBody(otherLanguage)); assertNull(message.getBody(defaultLanguage)); - assertXMLEqual(control, message.toXML().toString()); + assertXmlSimilar(control, message.toXML().toString()); // message has default language, body has non-default language control = XMLBuilder.create("message") @@ -194,7 +193,7 @@ public class PacketParserUtilsTest { assertTrue(message.getBodyLanguages().contains(otherLanguage)); assertEquals(otherLanguage, message.getBody(otherLanguage)); assertNull(message.getBody(defaultLanguage)); - assertXMLEqual(control, message.toXML().toString()); + assertXmlSimilar(control, message.toXML().toString()); // message has non-default language, body has default language control = XMLBuilder.create("message") @@ -216,7 +215,7 @@ public class PacketParserUtilsTest { assertTrue(message.getBodyLanguages().contains(defaultLanguage)); assertEquals(defaultLanguage, message.getBody(defaultLanguage)); assertNull(message.getBody(otherLanguage)); - assertXMLEqual(control, message.toXML().toString()); + assertXmlSimilar(control, message.toXML().toString()); } @@ -245,7 +244,7 @@ public class PacketParserUtilsTest { assertTrue(message.getSubjectLanguages().isEmpty()); assertEquals(defaultLanguage, message.getSubject(defaultLanguage)); assertNull(message.getSubject(otherLanguage)); - assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); + assertXmlSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); // message has non-default language, subject has no language control = XMLBuilder.create("message") @@ -264,7 +263,7 @@ public class PacketParserUtilsTest { assertTrue(message.getSubjectLanguages().isEmpty()); assertEquals(otherLanguage, message.getSubject(otherLanguage)); assertNull(message.getSubject(defaultLanguage)); - assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); + assertXmlSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); // message has no language, subject has no language control = XMLBuilder.create("message") @@ -282,7 +281,7 @@ public class PacketParserUtilsTest { assertTrue(message.getSubjectLanguages().isEmpty()); assertEquals(defaultLanguage, message.getSubject(null)); assertNull(message.getSubject(otherLanguage)); - assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); + assertXmlSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); // message has no language, subject has default language control = XMLBuilder.create("message") @@ -301,7 +300,7 @@ public class PacketParserUtilsTest { assertEquals(defaultLanguage, message.getSubject(defaultLanguage)); assertNull(message.getSubject(otherLanguage)); - assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); + assertXmlSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); // message has no language, subject has non-default language control = XMLBuilder.create("message") @@ -321,7 +320,7 @@ public class PacketParserUtilsTest { assertTrue(message.getSubjectLanguages().contains(otherLanguage)); assertEquals(otherLanguage, message.getSubject(otherLanguage)); assertNull(message.getSubject(defaultLanguage)); - assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); + assertXmlSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); // message has default language, subject has non-default language control = XMLBuilder.create("message") @@ -342,7 +341,7 @@ public class PacketParserUtilsTest { assertTrue(message.getSubjectLanguages().contains(otherLanguage)); assertEquals(otherLanguage, message.getSubject(otherLanguage)); assertNull(message.getSubject(defaultLanguage)); - assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); + assertXmlSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); // message has non-default language, subject has default language control = XMLBuilder.create("message") @@ -363,7 +362,7 @@ public class PacketParserUtilsTest { assertTrue(message.getSubjectLanguages().contains(defaultLanguage)); assertEquals(defaultLanguage, message.getSubject(defaultLanguage)); assertNull(message.getSubject(otherLanguage)); - assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); + assertXmlSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); } @@ -399,7 +398,7 @@ public class PacketParserUtilsTest { assertEquals(2, message.getBodies().size()); assertEquals(1, message.getBodyLanguages().size()); assertTrue(message.getBodyLanguages().contains(otherLanguage)); - assertXMLEqual(control, message.toXML().toString()); + assertXmlSimilar(control, message.toXML().toString()); // message has non-default language, first body no language, second body default language control = XMLBuilder.create("message") @@ -425,7 +424,7 @@ public class PacketParserUtilsTest { assertEquals(2, message.getBodies().size()); assertEquals(1, message.getBodyLanguages().size()); assertTrue(message.getBodyLanguages().contains(defaultLanguage)); - assertXMLEqual(control, message.toXML().toString()); + assertXmlSimilar(control, message.toXML().toString()); } // TODO: Re-enable once we throw an exception on duplicate body elements. @@ -458,7 +457,7 @@ public class PacketParserUtilsTest { assertEquals(defaultLanguage, message.getBody(defaultLanguage)); assertEquals(1, message.getBodies().size()); assertEquals(0, message.getBodyLanguages().size()); - assertXMLNotEqual(control, message.toXML().toString()); + assertXmlNotSimilar(control, message.toXML().toString()); } @Ignore @@ -516,7 +515,7 @@ public class PacketParserUtilsTest { assertEquals(otherLanguage, message.getBody(otherLanguage)); assertEquals(2, message.getBodies().size()); assertEquals(1, message.getBodyLanguages().size()); - assertXMLEqual(control, message.toXML().toString()); + assertXmlSimilar(control, message.toXML().toString()); } @Test @@ -550,7 +549,7 @@ public class PacketParserUtilsTest { assertEquals(2, message.getSubjects().size()); assertEquals(1, message.getSubjectLanguages().size()); assertTrue(message.getSubjectLanguages().contains(otherLanguage)); - assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); + assertXmlSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); // message has default language, first subject no language, second subject default language control = XMLBuilder.create("message") @@ -574,7 +573,7 @@ public class PacketParserUtilsTest { assertEquals(defaultLanguage, message.getSubject(defaultLanguage)); assertEquals(1, message.getSubjects().size()); assertEquals(0, message.getSubjectLanguages().size()); - assertXMLNotEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); + assertXmlNotSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); // message has non-default language, first subject no language, second subject default language control = XMLBuilder.create("message") @@ -599,7 +598,7 @@ public class PacketParserUtilsTest { assertEquals(2, message.getSubjects().size()); assertEquals(1, message.getSubjectLanguages().size()); assertTrue(message.getSubjectLanguages().contains(defaultLanguage)); - assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); + assertXmlSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); /* // message has no language, first subject no language, second subject default language @@ -647,7 +646,7 @@ public class PacketParserUtilsTest { assertEquals(otherLanguage, message.getSubject(otherLanguage)); assertEquals(2, message.getSubjects().size()); assertEquals(1, message.getSubjectLanguages().size()); - assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); + assertXmlSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); // message has no language, first subject no language, second subject no language control = XMLBuilder.create("message") @@ -777,7 +776,7 @@ public class PacketParserUtilsTest { .asString(outputProperties); Stanza message = PacketParserUtils.parseStanza(control); - XmlUnitUtils.assertSimilar(control, message.toXML()); + assertXmlSimilar(control, message.toXML()); } @Test @@ -787,7 +786,7 @@ public class PacketParserUtilsTest { Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza)); - assertXMLEqual(stanza, presence.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); + assertXmlSimilar(stanza, presence.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); // CHECKSTYLE:ON } @@ -798,7 +797,7 @@ public class PacketParserUtilsTest { Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza)); - assertXMLEqual(stanza, presence.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); + assertXmlSimilar(stanza, presence.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); assertEquals(Presence.Type.unsubscribed, presence.getType()); // CHECKSTYLE:ON } @@ -813,7 +812,7 @@ public class PacketParserUtilsTest { + ""; Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza)); - assertXMLEqual(stanza, presence.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); + assertXmlSimilar(stanza, presence.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); assertEquals(Presence.Type.unsubscribed, presence.getType()); assertEquals("dnd", presence.getMode().name()); assertEquals("en", presence.getLanguage()); @@ -844,7 +843,7 @@ public class PacketParserUtilsTest { // @formatter:on XmlPullParser parser = TestUtils.getParser(stanza, "outer"); CharSequence result = PacketParserUtils.parseElement(parser, true); - assertXMLEqual(stanza, result.toString()); + assertXmlSimilar(stanza, result.toString()); } @Test @@ -857,7 +856,7 @@ public class PacketParserUtilsTest { // @formatter:on XmlPullParser parser = TestUtils.getParser(saslFailureString, SASLFailure.ELEMENT); SASLFailure saslFailure = PacketParserUtils.parseSASLFailure(parser); - assertXMLEqual(saslFailureString, saslFailure.toString()); + assertXmlSimilar(saslFailureString, saslFailure.toString()); } @Test @@ -879,7 +878,7 @@ public class PacketParserUtilsTest { // @formatter:on XmlPullParser parser = TestUtils.getParser(saslFailureString, SASLFailure.ELEMENT); SASLFailure saslFailure = PacketParserUtils.parseSASLFailure(parser); - XmlUnitUtils.assertSimilar(saslFailureString, saslFailure.toXML(StreamOpen.CLIENT_NAMESPACE)); + assertXmlSimilar(saslFailureString, saslFailure.toXML(StreamOpen.CLIENT_NAMESPACE)); } @SuppressWarnings("ReferenceEquality") @@ -923,7 +922,7 @@ public class PacketParserUtilsTest { .element("internal-server-error", StanzaError.ERROR_CONDITION_AND_TEXT_NAMESPACE).up() .element("text", StanzaError.ERROR_CONDITION_AND_TEXT_NAMESPACE).t(text).up() .asString(); - XmlUnitUtils.assertSimilar(errorXml, error.toXML(StreamOpen.CLIENT_NAMESPACE)); + assertXmlSimilar(errorXml, error.toXML(StreamOpen.CLIENT_NAMESPACE)); } @Test diff --git a/smack-experimental/src/test/java/org/jivesoftware/smackx/httpfileupload/SlotCreateTest.java b/smack-experimental/src/test/java/org/jivesoftware/smackx/httpfileupload/SlotCreateTest.java index 36bc6931f..3dc287098 100644 --- a/smack-experimental/src/test/java/org/jivesoftware/smackx/httpfileupload/SlotCreateTest.java +++ b/smack-experimental/src/test/java/org/jivesoftware/smackx/httpfileupload/SlotCreateTest.java @@ -16,7 +16,7 @@ */ package org.jivesoftware.smackx.httpfileupload; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar; import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; @@ -44,6 +44,6 @@ public class SlotCreateTest { assertEquals(new URL("https://download.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my_juliet.png"), slot.getGetUrl()); - assertXMLEqual(testSlot, slot.getChildElementXML().toString()); + assertXmlSimilar(testSlot, slot.getChildElementXML().toString()); } } diff --git a/smack-experimental/src/test/java/org/jivesoftware/smackx/httpfileupload/SlotRequestCreateTest.java b/smack-experimental/src/test/java/org/jivesoftware/smackx/httpfileupload/SlotRequestCreateTest.java index 7a32fd2fe..e30a60c99 100644 --- a/smack-experimental/src/test/java/org/jivesoftware/smackx/httpfileupload/SlotRequestCreateTest.java +++ b/smack-experimental/src/test/java/org/jivesoftware/smackx/httpfileupload/SlotRequestCreateTest.java @@ -16,7 +16,7 @@ */ package org.jivesoftware.smackx.httpfileupload; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -51,7 +51,7 @@ public class SlotRequestCreateTest { assertEquals(23456, slotRequest.getSize()); assertEquals("image/jpeg", slotRequest.getContentType()); - assertXMLEqual(testRequest, slotRequest.getChildElementXML().toString()); + assertXmlSimilar(testRequest, slotRequest.getChildElementXML().toString()); } @Test @@ -62,7 +62,7 @@ public class SlotRequestCreateTest { assertEquals(52523, slotRequest.getSize()); assertEquals(null, slotRequest.getContentType()); - assertXMLEqual(testRequestWithoutContentType, slotRequest.getChildElementXML().toString()); + assertXmlSimilar(testRequestWithoutContentType, slotRequest.getChildElementXML().toString()); } @Test diff --git a/smack-experimental/src/test/java/org/jivesoftware/smackx/httpfileupload/provider/SlotProviderTest.java b/smack-experimental/src/test/java/org/jivesoftware/smackx/httpfileupload/provider/SlotProviderTest.java index 9ef246d1b..17c85f32d 100644 --- a/smack-experimental/src/test/java/org/jivesoftware/smackx/httpfileupload/provider/SlotProviderTest.java +++ b/smack-experimental/src/test/java/org/jivesoftware/smackx/httpfileupload/provider/SlotProviderTest.java @@ -16,7 +16,7 @@ */ package org.jivesoftware.smackx.httpfileupload.provider; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar; import static org.junit.jupiter.api.Assertions.assertEquals; import java.net.MalformedURLException; @@ -69,7 +69,7 @@ public class SlotProviderTest { checkUrls(slot); - assertXMLEqual(SLOT_IQ, slot.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); + assertXmlSimilar(SLOT_IQ, slot.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); } private static final String SLOT_V0_2_IQ = @@ -90,7 +90,7 @@ public class SlotProviderTest { checkUrls(slot); String slotXml = slot.toXML(StreamOpen.CLIENT_NAMESPACE).toString(); - assertXMLEqual(SLOT_V0_2_IQ, slotXml); + assertXmlSimilar(SLOT_V0_2_IQ, slotXml); } private static final String SLOT_WITH_HEADERS_IQ = @@ -114,7 +114,7 @@ public class SlotProviderTest { checkUrls(slot); String slotXml = slot.toXML(StreamOpen.CLIENT_NAMESPACE).toString(); - assertXMLEqual(SLOT_WITH_HEADERS_IQ, slotXml); + assertXmlSimilar(SLOT_WITH_HEADERS_IQ, slotXml); } private static void checkUrls(Slot slot) { diff --git a/smack-experimental/src/test/java/org/jivesoftware/smackx/message_markup/MessageMarkupTest.java b/smack-experimental/src/test/java/org/jivesoftware/smackx/message_markup/MessageMarkupTest.java index d6cce75a3..19bd428bf 100644 --- a/smack-experimental/src/test/java/org/jivesoftware/smackx/message_markup/MessageMarkupTest.java +++ b/smack-experimental/src/test/java/org/jivesoftware/smackx/message_markup/MessageMarkupTest.java @@ -16,7 +16,7 @@ */ package org.jivesoftware.smackx.message_markup; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -47,7 +47,7 @@ public class MessageMarkupTest extends SmackTestSuite { ""; MarkupElement.Builder m = MarkupElement.getBuilder(); m.setEmphasis(9, 15); - assertXMLEqual(xml, m.build().toXML().toString()); + assertXmlSimilar(xml, m.build().toXML().toString()); XmlPullParser parser = TestUtils.getParser(xml); MarkupElement parsed = new MarkupElementProvider().parse(parser); @@ -71,7 +71,7 @@ public class MessageMarkupTest extends SmackTestSuite { ""; MarkupElement.Builder m = MarkupElement.getBuilder(); m.setCode(9, 15); - assertXMLEqual(xml, m.build().toXML().toString()); + assertXmlSimilar(xml, m.build().toXML().toString()); XmlPullParser parser = TestUtils.getParser(xml); MarkupElement parsed = new MarkupElementProvider().parse(parser); @@ -95,7 +95,7 @@ public class MessageMarkupTest extends SmackTestSuite { ""; MarkupElement.Builder m = MarkupElement.getBuilder(); m.setDeleted(9, 15); - assertXMLEqual(xml, m.build().toXML().toString()); + assertXmlSimilar(xml, m.build().toXML().toString()); XmlPullParser parser = TestUtils.getParser(xml); MarkupElement parsed = new MarkupElementProvider().parse(parser); @@ -131,7 +131,7 @@ public class MessageMarkupTest extends SmackTestSuite { ""; MarkupElement.Builder m = MarkupElement.getBuilder(); m.setCodeBlock(23, 48); - assertXMLEqual(xml, m.build().toXML().toString()); + assertXmlSimilar(xml, m.build().toXML().toString()); XmlPullParser parser = TestUtils.getParser(xml); MarkupElement parsed = new MarkupElementProvider().parse(parser); @@ -161,7 +161,7 @@ public class MessageMarkupTest extends SmackTestSuite { .addEntry(61, 69) .addEntry(69, 89) .endList(); - assertXMLEqual(xml, m.build().toXML().toString()); + assertXmlSimilar(xml, m.build().toXML().toString()); XmlPullParser parser = TestUtils.getParser(xml); MarkupElement parsed = new MarkupElementProvider().parse(parser); @@ -191,7 +191,7 @@ public class MessageMarkupTest extends SmackTestSuite { ""; MarkupElement.Builder m = MarkupElement.getBuilder(); m.setBlockQuote(9 ,32); - assertXMLEqual(xml, m.build().toXML().toString()); + assertXmlSimilar(xml, m.build().toXML().toString()); XmlPullParser parser = TestUtils.getParser(xml); MarkupElement parsed = new MarkupElementProvider().parse(parser); @@ -213,7 +213,7 @@ public class MessageMarkupTest extends SmackTestSuite { MarkupElement.Builder m = MarkupElement.getBuilder(); m.setBlockQuote(0, 57); m.setBlockQuote(11, 34); - assertXMLEqual(xml, m.build().toXML().toString()); + assertXmlSimilar(xml, m.build().toXML().toString()); XmlPullParser parser = TestUtils.getParser(xml); MarkupElement parsed = new MarkupElementProvider().parse(parser); diff --git a/smack-experimental/src/test/java/org/jivesoftware/smackx/reference/ReferenceTest.java b/smack-experimental/src/test/java/org/jivesoftware/smackx/reference/ReferenceTest.java index 5ab9614d0..e69f0a584 100644 --- a/smack-experimental/src/test/java/org/jivesoftware/smackx/reference/ReferenceTest.java +++ b/smack-experimental/src/test/java/org/jivesoftware/smackx/reference/ReferenceTest.java @@ -16,7 +16,7 @@ */ package org.jivesoftware.smackx.reference; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -43,7 +43,7 @@ public class ReferenceTest extends SmackTestSuite { "uri='xmpp:juliet@capulet.lit' />"; URI uri = new URI("xmpp:juliet@capulet.lit"); ReferenceElement element = new ReferenceElement(72, 78, ReferenceElement.Type.mention, null, uri); - assertXMLEqual(xml, element.toXML().toString()); + assertXmlSimilar(xml, element.toXML().toString()); assertEquals(72, (int) element.getBegin()); assertEquals(78, (int) element.getEnd()); assertEquals(ReferenceElement.Type.mention, element.getType()); @@ -51,7 +51,7 @@ public class ReferenceTest extends SmackTestSuite { assertEquals(uri, element.getUri()); ReferenceElement parsed = ReferenceProvider.TEST_PROVIDER.parse(TestUtils.getParser(xml)); - assertXMLEqual(xml, parsed.toXML().toString()); + assertXmlSimilar(xml, parsed.toXML().toString()); } /** @@ -66,7 +66,7 @@ public class ReferenceTest extends SmackTestSuite { "uri='xmpp:fdp.shakespeare.lit?;node=fdp/submitted/stan.isode.net/accidentreport;item=ndina872be' />"; URI uri = new URI("xmpp:fdp.shakespeare.lit?;node=fdp/submitted/stan.isode.net/accidentreport;item=ndina872be"); ReferenceElement element = new ReferenceElement(null, null, ReferenceElement.Type.data, null, uri); - assertXMLEqual(xml, element.toXML().toString()); + assertXmlSimilar(xml, element.toXML().toString()); assertNull(element.getBegin()); assertNull(element.getEnd()); @@ -75,7 +75,7 @@ public class ReferenceTest extends SmackTestSuite { assertEquals(uri, element.getUri()); ReferenceElement parsed = ReferenceProvider.TEST_PROVIDER.parse(TestUtils.getParser(xml)); - assertXMLEqual(xml, parsed.toXML().toString()); + assertXmlSimilar(xml, parsed.toXML().toString()); } @Test diff --git a/smack-experimental/src/test/java/org/jivesoftware/smackx/sid/StableUniqueStanzaIdTest.java b/smack-experimental/src/test/java/org/jivesoftware/smackx/sid/StableUniqueStanzaIdTest.java index ecaef0e1d..edafc0b9a 100644 --- a/smack-experimental/src/test/java/org/jivesoftware/smackx/sid/StableUniqueStanzaIdTest.java +++ b/smack-experimental/src/test/java/org/jivesoftware/smackx/sid/StableUniqueStanzaIdTest.java @@ -16,7 +16,7 @@ */ package org.jivesoftware.smackx.sid; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -42,7 +42,7 @@ public class StableUniqueStanzaIdTest extends SmackTestSuite { StanzaIdElement element = new StanzaIdElement("de305d54-75b4-431b-adb2-eb6b9e546013", "alice@wonderland.lit"); assertEquals("de305d54-75b4-431b-adb2-eb6b9e546013", element.getId()); assertEquals("alice@wonderland.lit", element.getBy()); - assertXMLEqual(xml, element.toXML().toString()); + assertXmlSimilar(xml, element.toXML().toString()); StanzaIdElement parsed = StanzaIdProvider.INSTANCE.parse(TestUtils.getParser(xml)); assertEquals(element.getId(), parsed.getId()); @@ -54,7 +54,7 @@ public class StableUniqueStanzaIdTest extends SmackTestSuite { String xml = ""; OriginIdElement element = new OriginIdElement("de305d54-75b4-431b-adb2-eb6b9e546013"); assertEquals("de305d54-75b4-431b-adb2-eb6b9e546013", element.getId()); - assertXMLEqual(xml, element.toXML().toString()); + assertXmlSimilar(xml, element.toXML().toString()); OriginIdElement parsed = OriginIdProvider.INSTANCE.parse(TestUtils.getParser(xml)); assertEquals(element.getId(), parsed.getId()); diff --git a/smack-experimental/src/test/java/org/jivesoftware/smackx/spoiler/SpoilerTest.java b/smack-experimental/src/test/java/org/jivesoftware/smackx/spoiler/SpoilerTest.java index de1fdabf3..748035f9d 100644 --- a/smack-experimental/src/test/java/org/jivesoftware/smackx/spoiler/SpoilerTest.java +++ b/smack-experimental/src/test/java/org/jivesoftware/smackx/spoiler/SpoilerTest.java @@ -16,7 +16,7 @@ */ package org.jivesoftware.smackx.spoiler; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -48,11 +48,11 @@ public class SpoilerTest extends SmackTestSuite { assertNull(empty.getHint()); assertNull(empty.getLanguage()); - assertXMLEqual(xml, empty.toXML().toString()); + assertXmlSimilar(xml, empty.toXML().toString()); XmlPullParser parser = TestUtils.getParser(xml); SpoilerElement parsed = SpoilerProvider.INSTANCE.parse(parser); - assertXMLEqual(xml, parsed.toXML().toString()); + assertXmlSimilar(xml, parsed.toXML().toString()); } @Test @@ -67,12 +67,12 @@ public class SpoilerTest extends SmackTestSuite { assertEquals("Love story end", withHint.getHint()); assertNull(withHint.getLanguage()); - assertXMLEqual(xml, withHint.toXML().toString()); + assertXmlSimilar(xml, withHint.toXML().toString()); XmlPullParser parser = TestUtils.getParser(xml); SpoilerElement parsed = SpoilerProvider.INSTANCE.parse(parser); - assertXMLEqual(xml, parsed.toXML().toString()); + assertXmlSimilar(xml, parsed.toXML().toString()); } @Test @@ -87,13 +87,13 @@ public class SpoilerTest extends SmackTestSuite { assertEquals("Der Kuchen ist eine Lüge!", i18nHint.getHint()); assertEquals("de", i18nHint.getLanguage()); - assertXMLEqual(xml, i18nHint.toXML().toString()); + assertXmlSimilar(xml, i18nHint.toXML().toString()); XmlPullParser parser = TestUtils.getParser(xml); SpoilerElement parsed = SpoilerProvider.INSTANCE.parse(parser); assertEquals(i18nHint.getLanguage(), parsed.getLanguage()); - assertXMLEqual(xml, parsed.toXML().toString()); + assertXmlSimilar(xml, parsed.toXML().toString()); } @Test diff --git a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/pubsub/SubscriberUseCases.java b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/pubsub/SubscriberUseCases.java index c6580e30c..a5ff116cc 100644 --- a/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/pubsub/SubscriberUseCases.java +++ b/smack-extensions/src/integration-test/java/org/jivesoftware/smackx/pubsub/SubscriberUseCases.java @@ -16,7 +16,7 @@ */ package org.jivesoftware.smackx.pubsub; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar; import java.util.ArrayList; import java.util.Calendar; @@ -206,19 +206,19 @@ public class SubscriberUseCases extends SingleUserTestCase PayloadItem testItem = idMap.get("6-" + curTime); assertNotNull(testItem); - assertXMLEqual("", testItem.getPayload().toXML()); + assertXmlSimilar("", testItem.getPayload().toXML()); testItem = idMap.get("7-" + curTime); assertNotNull(testItem); - assertXMLEqual("", testItem.getPayload().toXML()); + assertXmlSimilar("", testItem.getPayload().toXML()); testItem = idMap.get("8-" + curTime); assertNotNull(testItem); - assertXMLEqual("texta", testItem.getPayload().toXML()); + assertXmlSimilar("texta", testItem.getPayload().toXML()); testItem = idMap.get("9-" + curTime); assertNotNull(testItem); - assertXMLEqual("b", testItem.getPayload().toXML()); + assertXmlSimilar("b", testItem.getPayload().toXML()); } public void testGetSpecifiedItems() throws Exception @@ -239,11 +239,11 @@ public class SubscriberUseCases extends SingleUserTestCase List> items = node.getItems(ids); assertEquals(3, items.size()); assertEquals("1", items.get(0).getId()); - assertXMLEqual("", items.get(0).getPayload().toXML()); + assertXmlSimilar("", items.get(0).getPayload().toXML()); assertEquals( "3", items.get(1).getId()); - assertXMLEqual("", items.get(1).getPayload().toXML()); + assertXmlSimilar("", items.get(1).getPayload().toXML()); assertEquals("4", items.get(2).getId()); - assertXMLEqual("", items.get(2).getPayload().toXML()); + assertXmlSimilar("", items.get(2).getPayload().toXML()); } public void testGetLastNItems() throws XMPPException diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/packet/CloseTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/packet/CloseTest.java index 4adb4857b..f43c0e365 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/packet/CloseTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/packet/CloseTest.java @@ -16,7 +16,7 @@ */ package org.jivesoftware.smackx.bytestreams.ibb.packet; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar; import static org.junit.Assert.assertEquals; import java.util.Properties; @@ -81,7 +81,7 @@ public class CloseTest extends InitExtensions { close.setTo(JidCreate.from("juliet@capulet.lit/balcony")); close.setStanzaId("us71g45j"); - assertXMLEqual(control, close.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); + assertXmlSimilar(control, close.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); } } diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/packet/DataPacketExtensionTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/packet/DataPacketExtensionTest.java index f29e15e49..e35959783 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/packet/DataPacketExtensionTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/packet/DataPacketExtensionTest.java @@ -16,7 +16,7 @@ */ package org.jivesoftware.smackx.bytestreams.ibb.packet; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @@ -96,7 +96,7 @@ public class DataPacketExtensionTest extends InitExtensions { .asString(outputProperties); DataPacketExtension data = new DataPacketExtension("i781hf64", 0, "DATA"); - assertXMLEqual(control, data.toXML().toString()); + assertXmlSimilar(control, data.toXML().toString()); } } diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/packet/DataTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/packet/DataTest.java index ea53cf94c..974033a49 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/packet/DataTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/packet/DataTest.java @@ -16,7 +16,7 @@ */ package org.jivesoftware.smackx.bytestreams.ibb.packet; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; @@ -78,7 +78,7 @@ public class DataTest extends InitExtensions { data.setTo(JidCreate.from("juliet@capulet.lit/balcony")); data.setStanzaId("kr91n475"); - assertXMLEqual(control, data.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); + assertXmlSimilar(control, data.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); } } diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/packet/OpenTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/packet/OpenTest.java index 730035ced..611c68894 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/packet/OpenTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/ibb/packet/OpenTest.java @@ -16,7 +16,7 @@ */ package org.jivesoftware.smackx.bytestreams.ibb.packet; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar; import static org.junit.Assert.assertEquals; import java.util.Properties; @@ -103,7 +103,7 @@ public class OpenTest extends InitExtensions { open.setTo(JidCreate.from("juliet@capulet.lit/balcony")); open.setStanzaId("jn3h8g65"); - assertXMLEqual(control, open.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); + assertXmlSimilar(control, open.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); } diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/last_interaction/IdleTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/last_interaction/IdleTest.java index 02baa5bd9..74247bba1 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/last_interaction/IdleTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/last_interaction/IdleTest.java @@ -18,7 +18,7 @@ package org.jivesoftware.smackx.last_interaction; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar; import java.util.Date; @@ -45,7 +45,7 @@ public class IdleTest extends SmackTestSuite { assertEquals(date, parsed.getSince()); IdleElement element = new IdleElement(date); - assertXMLEqual("", element.toXML().toString()); + assertXmlSimilar("", element.toXML().toString()); } @Test diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/mood/MoodConcretisationTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/mood/MoodConcretisationTest.java index 8bfaf9d8a..0c9c83c93 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/mood/MoodConcretisationTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/mood/MoodConcretisationTest.java @@ -19,7 +19,7 @@ package org.jivesoftware.smackx.mood; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertFalse; import static junit.framework.TestCase.assertTrue; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar; import org.jivesoftware.smack.provider.ProviderManager; import org.jivesoftware.smack.test.util.SmackTestSuite; @@ -61,11 +61,11 @@ public class MoodConcretisationTest extends SmackTestSuite { new EcstaticMoodConcretisation()), "Yay, the mood spec has been approved!"); - assertXMLEqual(xml, element.toXML().toString()); + assertXmlSimilar(xml, element.toXML().toString()); XmlPullParser parser = TestUtils.getParser(xml); MoodElement parsed = MoodProvider.INSTANCE.parse(parser); - assertXMLEqual(xml, parsed.toXML().toString()); + assertXmlSimilar(xml, parsed.toXML().toString()); assertTrue(parsed.hasConcretisation()); assertTrue(parsed.hasText()); diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/mood/MoodElementTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/mood/MoodElementTest.java index 2d68cc52e..69e2c5671 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/mood/MoodElementTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/mood/MoodElementTest.java @@ -19,7 +19,7 @@ package org.jivesoftware.smackx.mood; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertFalse; import static junit.framework.TestCase.assertNull; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar; import org.jivesoftware.smack.test.util.SmackTestSuite; import org.jivesoftware.smack.test.util.TestUtils; @@ -42,7 +42,7 @@ public class MoodElementTest extends SmackTestSuite { ""; MoodElement moodElement = new MoodElement(new MoodElement.MoodSubjectElement(Mood.happy, null), "Yay, the mood spec has been approved!"); - assertXMLEqual(xml, moodElement.toXML().toString()); + assertXmlSimilar(xml, moodElement.toXML().toString()); assertFalse(moodElement.hasConcretisation()); assertEquals(Mood.happy, moodElement.getMood()); diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/AffiliationsExtensionTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/AffiliationsExtensionTest.java index 079733aab..bbbed2771 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/AffiliationsExtensionTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/AffiliationsExtensionTest.java @@ -16,7 +16,7 @@ */ package org.jivesoftware.smackx.pubsub; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar; import java.io.IOException; import java.util.ArrayList; @@ -42,7 +42,7 @@ public class AffiliationsExtensionTest { CharSequence xml = affiliationsExtension.toXML(); - assertXMLEqual("", + assertXmlSimilar("", xml.toString()); } diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ItemValidationTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ItemValidationTest.java index 1f36293fc..631a64ac0 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ItemValidationTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ItemValidationTest.java @@ -16,7 +16,7 @@ */ package org.jivesoftware.smackx.pubsub; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -62,15 +62,15 @@ public class ItemValidationTest extends InitExtensions { public void verifyBasicItem() throws Exception { Item simpleItem = new Item(); String simpleCtrl = ""; - assertXMLEqual(simpleCtrl, simpleItem.toXML().toString()); + assertXmlSimilar(simpleCtrl, simpleItem.toXML().toString()); Item idItem = new Item("uniqueid"); String idCtrl = ""; - assertXMLEqual(idCtrl, idItem.toXML().toString()); + assertXmlSimilar(idCtrl, idItem.toXML().toString()); Item itemWithNodeId = new Item("testId", "testNode"); String nodeIdCtrl = ""; - assertXMLEqual(nodeIdCtrl, itemWithNodeId.toXML().toString()); + assertXmlSimilar(nodeIdCtrl, itemWithNodeId.toXML().toString()); } @Test @@ -79,15 +79,15 @@ public class ItemValidationTest extends InitExtensions { PayloadItem simpleItem = new PayloadItem<>(payload); String simpleCtrl = "" + payload.toXML() + ""; - assertXMLEqual(simpleCtrl, simpleItem.toXML().toString()); + assertXmlSimilar(simpleCtrl, simpleItem.toXML().toString()); PayloadItem idItem = new PayloadItem<>("uniqueid", payload); String idCtrl = "" + payload.toXML() + ""; - assertXMLEqual(idCtrl, idItem.toXML().toString()); + assertXmlSimilar(idCtrl, idItem.toXML().toString()); PayloadItem itemWithNodeId = new PayloadItem<>("testId", "testNode", payload); String nodeIdCtrl = "" + payload.toXML() + ""; - assertXMLEqual(nodeIdCtrl, itemWithNodeId.toXML().toString()); + assertXmlSimilar(nodeIdCtrl, itemWithNodeId.toXML().toString()); } @Test @@ -145,7 +145,7 @@ public class ItemValidationTest extends InitExtensions { SimplePayload payload = (SimplePayload) item.getPayload(); assertEquals("foo", payload.getElementName()); assertEquals("smack:test", payload.getNamespace()); - assertXMLEqual(itemContent, payload.toXML().toString()); + assertXmlSimilar(itemContent, payload.toXML().toString()); } @Test @@ -191,7 +191,7 @@ public class ItemValidationTest extends InitExtensions { SimplePayload payload = (SimplePayload) item.getPayload(); assertEquals("entry", payload.getElementName()); assertEquals("http://www.w3.org/2005/Atom", payload.getNamespace()); - assertXMLEqual(itemContent, payload.toXML().toString()); + assertXmlSimilar(itemContent, payload.toXML().toString()); } @Test @@ -226,6 +226,6 @@ public class ItemValidationTest extends InitExtensions { assertEquals("testid1", item.getId()); assertTrue(item.getPayload() instanceof SimplePayload); - assertXMLEqual(itemContent, item.getPayload().toXML().toString()); + assertXmlSimilar(itemContent, item.getPayload().toXML().toString()); } } diff --git a/smack-openpgp/src/test/java/org/jivesoftware/smackx/ox/OpenPgpElementTest.java b/smack-openpgp/src/test/java/org/jivesoftware/smackx/ox/OpenPgpElementTest.java index 9d42f57fa..2d8d55419 100644 --- a/smack-openpgp/src/test/java/org/jivesoftware/smackx/ox/OpenPgpElementTest.java +++ b/smack-openpgp/src/test/java/org/jivesoftware/smackx/ox/OpenPgpElementTest.java @@ -18,7 +18,7 @@ package org.jivesoftware.smackx.ox; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar; import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.IOException; @@ -72,7 +72,7 @@ public class OpenPgpElementTest extends SmackTestSuite { OpenPgpElement element = new OpenPgpElement("BASE64_OPENPGP_MESSAGE"); - assertXMLEqual(expected, element.toXML().toString()); + assertXmlSimilar(expected, element.toXML().toString()); XmlPullParser parser = TestUtils.getParser(expected); OpenPgpElement parsed = OpenPgpElementProvider.TEST_INSTANCE.parse(parser); @@ -104,7 +104,7 @@ public class OpenPgpElementTest extends SmackTestSuite { payload.add(new Message.Body("en", "Hello World!")); SignElement element = new SignElement(recipients, testDate, payload); - assertXMLEqual(expected, element.toXML().toString()); + assertXmlSimilar(expected, element.toXML().toString()); XmlPullParser parser = TestUtils.getParser(expected); SignElement parsed = (SignElement) OpenPgpContentElementProvider.parseOpenPgpContentElement(parser); @@ -134,7 +134,7 @@ public class OpenPgpElementTest extends SmackTestSuite { testDate, payload); - assertXMLEqual(expected, element.toXML().toString()); + assertXmlSimilar(expected, element.toXML().toString()); XmlPullParser parser = TestUtils.getParser(expected); CryptElement parsed = (CryptElement) OpenPgpContentElementProvider.parseOpenPgpContentElement(parser); @@ -164,7 +164,7 @@ public class OpenPgpElementTest extends SmackTestSuite { "f0rm1l4n4-mT8y33j!Y%fRSrcd^ZE4Q7VDt1L%WEgR!kv", testDate, payload); - assertXMLEqual(expected, element.toXML().toString()); + assertXmlSimilar(expected, element.toXML().toString()); XmlPullParser parser = TestUtils.getParser(expected); SigncryptElement parsed = (SigncryptElement) OpenPgpContentElementProvider.parseOpenPgpContentElement(parser); diff --git a/smack-openpgp/src/test/java/org/jivesoftware/smackx/ox/PubkeyElementTest.java b/smack-openpgp/src/test/java/org/jivesoftware/smackx/ox/PubkeyElementTest.java index f619d5c4a..72b69941a 100644 --- a/smack-openpgp/src/test/java/org/jivesoftware/smackx/ox/PubkeyElementTest.java +++ b/smack-openpgp/src/test/java/org/jivesoftware/smackx/ox/PubkeyElementTest.java @@ -18,7 +18,7 @@ package org.jivesoftware.smackx.ox; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertTrue; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar; import java.nio.charset.Charset; import java.util.Arrays; @@ -49,7 +49,7 @@ public class PubkeyElementTest extends SmackTestSuite { byte[] key = "BASE64_OPENPGP_PUBLIC_KEY".getBytes(Charset.forName("UTF-8")); PubkeyElement element = new PubkeyElement(new PubkeyElement.PubkeyDataElement(key), date); - assertXMLEqual(expected, element.toXML().toString()); + assertXmlSimilar(expected, element.toXML().toString()); XmlPullParser parser = TestUtils.getParser(expected); PubkeyElement parsed = PubkeyElementProvider.TEST_INSTANCE.parse(parser); diff --git a/smack-openpgp/src/test/java/org/jivesoftware/smackx/ox/PublicKeysListElementTest.java b/smack-openpgp/src/test/java/org/jivesoftware/smackx/ox/PublicKeysListElementTest.java index 0b99d7edd..54f2f98cc 100644 --- a/smack-openpgp/src/test/java/org/jivesoftware/smackx/ox/PublicKeysListElementTest.java +++ b/smack-openpgp/src/test/java/org/jivesoftware/smackx/ox/PublicKeysListElementTest.java @@ -17,7 +17,7 @@ package org.jivesoftware.smackx.ox; import static junit.framework.TestCase.assertEquals; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar; import java.util.Date; @@ -63,7 +63,7 @@ public class PublicKeysListElementTest extends SmackTestSuite { .addMetadata(child2) .build(); - assertXMLEqual(expected, element.toXML().toString()); + assertXmlSimilar(expected, element.toXML().toString()); XmlPullParser parser = TestUtils.getParser(expected); PublicKeysListElement parsed = PublicKeysListElementProvider.TEST_INSTANCE.parse(parser); diff --git a/smack-openpgp/src/test/java/org/jivesoftware/smackx/ox/SecretkeyElementTest.java b/smack-openpgp/src/test/java/org/jivesoftware/smackx/ox/SecretkeyElementTest.java index f6d1edb77..56902d75f 100644 --- a/smack-openpgp/src/test/java/org/jivesoftware/smackx/ox/SecretkeyElementTest.java +++ b/smack-openpgp/src/test/java/org/jivesoftware/smackx/ox/SecretkeyElementTest.java @@ -17,7 +17,7 @@ package org.jivesoftware.smackx.ox; import static junit.framework.TestCase.assertTrue; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar; import java.nio.charset.Charset; import java.util.Arrays; @@ -43,7 +43,7 @@ public class SecretkeyElementTest extends SmackTestSuite { SecretkeyElement element = new SecretkeyElement(key); - assertXMLEqual(expected, element.toXML().toString()); + assertXmlSimilar(expected, element.toXML().toString()); XmlPullParser parser = TestUtils.getParser(expected); SecretkeyElement parsed = SecretkeyElementProvider.TEST_INSTANCE.parse(parser);