Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,6 @@
<version>${xmlunit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-legacy</artifactId>
<version>${xmlunit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,13 @@
import org.codehaus.mojo.jaxb2.shared.filters.Filter;
import org.codehaus.mojo.jaxb2.shared.filters.Filters;
import org.codehaus.mojo.jaxb2.shared.filters.pattern.PatternFileFilter;
import org.custommonkey.xmlunit.Diff;
import org.custommonkey.xmlunit.ElementNameAndAttributeQualifier;
import org.custommonkey.xmlunit.XMLAssert;
import org.custommonkey.xmlunit.XMLUnit;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.Diff;

import static org.junit.jupiter.api.Assertions.*;

Expand All @@ -57,10 +55,6 @@ class XsdGeneratorHelperTest {
@BeforeAll
static void setupSharedState() {

// Configure XMLUnit.
XMLUnit.setIgnoreWhitespace(true);
XMLUnit.setIgnoreAttributeOrder(true);

// Configure the TransformerFactory
try {

Expand Down Expand Up @@ -203,10 +197,12 @@ void validateProcessingNodes() {

// Assert
final Document expectedDocument = XsdGeneratorHelper.parseXmlStream(new StringReader(changedXml));
final Diff diff = new Diff(expectedDocument, processedDocument, null, new ElementNameAndAttributeQualifier());
diff.overrideElementQualifier(new ElementNameAndAttributeQualifier());

XMLAssert.assertXMLEqual(processedDocument, expectedDocument);
final Diff diff = DiffBuilder.compare(expectedDocument)
.withTest(processedDocument)
.ignoreWhitespace()
.checkForSimilar()
.build();
assertFalse(diff.hasDifferences(), diff.toString());
}

@Test
Expand Down Expand Up @@ -388,10 +384,12 @@ void validateProcessingXSDsWithEnumerations() throws Exception {

// Assert
final Document expectedDocument = XsdGeneratorHelper.parseXmlStream(new StringReader(processedEnumSchema));
final Diff diff = new Diff(expectedDocument, processedDocument, null, new ElementNameAndAttributeQualifier());
diff.overrideElementQualifier(new ElementNameAndAttributeQualifier());

XMLAssert.assertXMLEqual(processedDocument, expectedDocument);
final Diff diff = DiffBuilder.compare(expectedDocument)
.withTest(processedDocument)
.ignoreWhitespace()
.checkForSimilar()
.build();
assertFalse(diff.hasDifferences(), diff.toString());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
import org.codehaus.mojo.jaxb2.schemageneration.postprocessing.NodeProcessor;
import org.codehaus.mojo.jaxb2.shared.FileSystemUtilities;
import org.codehaus.mojo.jaxb2.shared.Validate;
import org.custommonkey.xmlunit.Diff;
import org.custommonkey.xmlunit.XMLUnit;
import org.junit.jupiter.api.BeforeEach;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.Diff;

import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down Expand Up @@ -310,7 +310,7 @@ protected static String readFully(final String path) {
*
* @param expected The expected document data.
* @param actual The actual document data.
* @return A DetailedDiff object, describing all differences in documents supplied.
* @return A Diff object, describing all differences in documents supplied.
* @throws org.xml.sax.SAXException If a SAXException was raised during parsing of the two Documents.
* @throws IOException If an I/O-related exception was raised while acquiring the data from the Readers.
*/
Expand All @@ -321,13 +321,8 @@ protected static Diff compareXmlIgnoringWhitespace(final String expected, final
Validate.notNull(expected, "Cannot handle null expected argument.");
Validate.notNull(actual, "Cannot handle null actual argument.");

// Ignore whitespace - and also normalize the Documents.
XMLUnit.setNormalize(true);
XMLUnit.setIgnoreWhitespace(true);
XMLUnit.setNormalize(true);

// Compare and return
return XMLUnit.compareXML(expected, actual);
return DiffBuilder.compare(expected).withTest(actual).ignoreWhitespace().build();
}

private List<File> resolveSourceFiles() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.w3c.dom.Document;
import org.w3c.dom.Node;

import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;

/**
* @author <a href="mailto:lj@jguru.se">Lennart J&ouml;relid</a>, jGuru Europe AB
Expand Down Expand Up @@ -35,7 +35,7 @@ void validateProcessingNodesInVanillaXSD() throws Exception {
final String processed = printDocument(document);
// System.out.println("Got: " + processed);

assertTrue(compareXmlIgnoringWhitespace(expected, processed).identical());
assertFalse(compareXmlIgnoringWhitespace(expected, processed).hasDifferences());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.w3c.dom.Document;
import org.w3c.dom.Node;

import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;

/**
* @author <a href="mailto:lj@jguru.se">Lennart J&ouml;relid</a>, jGuru Europe AB
Expand Down Expand Up @@ -36,7 +36,7 @@ void validateProcessingNodesInVanillaXSD() throws Exception {
final String processed = printDocument(document);
// System.out.println("Got: " + processed);

assertTrue(compareXmlIgnoringWhitespace(expected, processed).identical());
assertFalse(compareXmlIgnoringWhitespace(expected, processed).hasDifferences());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.w3c.dom.Document;
import org.w3c.dom.Node;

import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;

/**
* @author <a href="mailto:lj@jguru.se">Lennart J&ouml;relid</a>, jGuru Europe AB
Expand Down Expand Up @@ -39,7 +39,7 @@ void validateProcessingNodesInVanillaXSD() throws Exception {
final String processed = printDocument(xsdGeneratedFromClassesInMethod);
// System.out.println("Got: " + processed);

assertTrue(compareXmlIgnoringWhitespace(expected, processed).identical());
assertFalse(compareXmlIgnoringWhitespace(expected, processed).hasDifferences());
}

/**
Expand Down
Loading