1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-12-22 12:37:58 +01:00

Remove xmlunit-lagacy and add xmlunit-assertj

This commit is contained in:
Florian Schmaus 2019-05-07 18:51:52 +02:00
parent 95dbf5bb36
commit e1ed035beb
27 changed files with 163 additions and 146 deletions

View file

@ -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'
}

View file

@ -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 = "<failure xmlns='http://jabber.org/protocol/compress'><processing-failed/></failure>";
assertXMLEqual(expectedXml, xml.toString());
assertXmlSimilar(expectedXml, xml.toString());
}
@Test
@ -53,6 +53,6 @@ public class FailureTest {
+ "</error>"
+ "</failure>";
assertXMLEqual(expectedXml, xml.toString());
assertXmlSimilar(expectedXml, xml.toString());
}
}

View file

@ -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("<message")
@ -62,7 +60,7 @@ public class MessageTest {
Message messageTypeSet = getNewMessage();
messageTypeSet.setType(type2);
assertEquals(type2, messageTypeSet.getType());
assertXMLEqual(control, messageTypeSet.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
assertXmlSimilar(control, messageTypeSet.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
}
@Test(expected = NullPointerException.class)
@ -87,7 +85,7 @@ public class MessageTest {
message.setSubject(messageSubject);
assertEquals(messageSubject, message.getSubject());
assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
assertXmlSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
}
@Test
@ -106,7 +104,7 @@ public class MessageTest {
message.setBody(messageBody);
assertEquals(messageBody, message.getBody());
assertXMLEqual(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
assertXmlSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
}
@Test
@ -139,7 +137,7 @@ public class MessageTest {
message.addBody(null, messageBody1);
message.addBody(lang2, messageBody2);
message.addBody(lang3, messageBody3);
XmlUnitUtils.assertSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE));
assertXmlSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE));
Collection<String> languages = message.getBodyLanguages();
List<String> 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() {

View file

@ -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("<presence")
@ -56,7 +56,7 @@ public class PresenceTest {
Presence presenceTypeSet = getNewPresence();
presenceTypeSet.setType(type2);
assertEquals(type2, presenceTypeSet.getType());
assertXMLEqual(control, presenceTypeSet.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
assertXmlSimilar(control, presenceTypeSet.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
}
@Test(expected = NullPointerException.class)
@ -90,7 +90,7 @@ public class PresenceTest {
presence.setStatus(status);
assertEquals(status, presence.getStatus());
assertXMLEqual(control, presence.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
assertXmlSimilar(control, presence.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
}
@Test
@ -109,7 +109,7 @@ public class PresenceTest {
presence.setPriority(priority);
assertEquals(priority, presence.getPriority());
assertXMLEqual(control, presence.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
assertXmlSimilar(control, presence.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
}
@Test(expected = IllegalArgumentException.class)
@ -142,7 +142,7 @@ public class PresenceTest {
mode1);
presenceModeInConstructor.setStanzaId(null);
assertEquals(mode1, presenceModeInConstructor.getMode());
assertXMLEqual(control, presenceModeInConstructor.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
assertXmlSimilar(control, presenceModeInConstructor.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
controlBuilder = new StringBuilder();
controlBuilder.append("<presence>")
@ -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() {

View file

@ -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();
}
}

View file

@ -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 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

View file

@ -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());
}
}

View file

@ -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

View file

@ -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) {

View file

@ -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 {
"</markup>";
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 {
"</markup>";
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 {
"</markup>";
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 {
"</markup>";
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 {
"</markup>";
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);

View file

@ -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

View file

@ -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 = "<origin-id xmlns='urn:xmpp:sid:0' id='de305d54-75b4-431b-adb2-eb6b9e546013' />";
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());

View file

@ -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

View file

@ -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<SimplePayload> testItem = idMap.get("6-" + curTime);
assertNotNull(testItem);
assertXMLEqual("<a xmlns='pubsub:test'/>", testItem.getPayload().toXML());
assertXmlSimilar("<a xmlns='pubsub:test'/>", testItem.getPayload().toXML());
testItem = idMap.get("7-" + curTime);
assertNotNull(testItem);
assertXMLEqual("<a xmlns='pubsub:test' href=\'/up/here\'/>", testItem.getPayload().toXML());
assertXmlSimilar("<a xmlns='pubsub:test' href=\'/up/here\'/>", testItem.getPayload().toXML());
testItem = idMap.get("8-" + curTime);
assertNotNull(testItem);
assertXMLEqual("<entity xmlns='pubsub:test'>text<inner>a</inner></entity>", testItem.getPayload().toXML());
assertXmlSimilar("<entity xmlns='pubsub:test'>text<inner>a</inner></entity>", testItem.getPayload().toXML());
testItem = idMap.get("9-" + curTime);
assertNotNull(testItem);
assertXMLEqual("<entity xmlns='pubsub:test'><inner><text>b</text></inner></entity>", testItem.getPayload().toXML());
assertXmlSimilar("<entity xmlns='pubsub:test'><inner><text>b</text></inner></entity>", testItem.getPayload().toXML());
}
public void testGetSpecifiedItems() throws Exception
@ -239,11 +239,11 @@ public class SubscriberUseCases extends SingleUserTestCase
List<PayloadItem<SimplePayload>> items = node.getItems(ids);
assertEquals(3, items.size());
assertEquals("1", items.get(0).getId());
assertXMLEqual("<a xmlns='pubsub:test' href='1'/>", items.get(0).getPayload().toXML());
assertXmlSimilar("<a xmlns='pubsub:test' href='1'/>", items.get(0).getPayload().toXML());
assertEquals( "3", items.get(1).getId());
assertXMLEqual("<a xmlns='pubsub:test' href='3'/>", items.get(1).getPayload().toXML());
assertXmlSimilar("<a xmlns='pubsub:test' href='3'/>", items.get(1).getPayload().toXML());
assertEquals("4", items.get(2).getId());
assertXMLEqual("<a xmlns='pubsub:test' href='4'/>", items.get(2).getPayload().toXML());
assertXmlSimilar("<a xmlns='pubsub:test' href='4'/>", items.get(2).getPayload().toXML());
}
public void testGetLastNItems() throws XMPPException

View file

@ -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());
}
}

View file

@ -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());
}
}

View file

@ -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());
}
}

View file

@ -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());
}

View file

@ -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("<idle xmlns='urn:xmpp:idle:1' since='1969-07-21T02:56:15.000+00:00'/>", element.toXML().toString());
assertXmlSimilar("<idle xmlns='urn:xmpp:idle:1' since='1969-07-21T02:56:15.000+00:00'/>", element.toXML().toString());
}
@Test

View file

@ -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());

View file

@ -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 {
"</mood>";
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());

View file

@ -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("<affiliations node='testNode'><affiliation xmlns='http://jabber.org/protocol/pubsub#owner' jid='one@exampleone.org' affiliation='member'/></affiliations>",
assertXmlSimilar("<affiliations node='testNode'><affiliation xmlns='http://jabber.org/protocol/pubsub#owner' jid='one@exampleone.org' affiliation='member'/></affiliations>",
xml.toString());
}

View file

@ -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 = "<item xmlns='http://jabber.org/protocol/pubsub' />";
assertXMLEqual(simpleCtrl, simpleItem.toXML().toString());
assertXmlSimilar(simpleCtrl, simpleItem.toXML().toString());
Item idItem = new Item("uniqueid");
String idCtrl = "<item xmlns='http://jabber.org/protocol/pubsub' id='uniqueid'/>";
assertXMLEqual(idCtrl, idItem.toXML().toString());
assertXmlSimilar(idCtrl, idItem.toXML().toString());
Item itemWithNodeId = new Item("testId", "testNode");
String nodeIdCtrl = "<item xmlns='http://jabber.org/protocol/pubsub' id='testId' node='testNode' />";
assertXMLEqual(nodeIdCtrl, itemWithNodeId.toXML().toString());
assertXmlSimilar(nodeIdCtrl, itemWithNodeId.toXML().toString());
}
@Test
@ -79,15 +79,15 @@ public class ItemValidationTest extends InitExtensions {
PayloadItem<SimplePayload> simpleItem = new PayloadItem<>(payload);
String simpleCtrl = "<item xmlns='http://jabber.org/protocol/pubsub'>" + payload.toXML() + "</item>";
assertXMLEqual(simpleCtrl, simpleItem.toXML().toString());
assertXmlSimilar(simpleCtrl, simpleItem.toXML().toString());
PayloadItem<SimplePayload> idItem = new PayloadItem<>("uniqueid", payload);
String idCtrl = "<item xmlns='http://jabber.org/protocol/pubsub' id='uniqueid'>" + payload.toXML() + "</item>";
assertXMLEqual(idCtrl, idItem.toXML().toString());
assertXmlSimilar(idCtrl, idItem.toXML().toString());
PayloadItem<SimplePayload> itemWithNodeId = new PayloadItem<>("testId", "testNode", payload);
String nodeIdCtrl = "<item xmlns='http://jabber.org/protocol/pubsub' id='testId' node='testNode'>" + payload.toXML() + "</item>";
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());
}
}

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);