Commit 1cccaced authored by Pakulin's avatar Pakulin
Browse files

Fine-tuning settings for difference engine in XmlDiff

parent a0f90621
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -8,13 +8,13 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.List;

import org.custommonkey.xmlunit.DetailedDiff;
import org.custommonkey.xmlunit.Diff;
import org.custommonkey.xmlunit.Difference;
import org.custommonkey.xmlunit.XMLUnit;
import org.xml.sax.SAXException;

/** This class implements an algorithm to compare two XML files.
@@ -71,13 +71,23 @@ public class XmlDiff {
		} catch (IOException e) {
			throw new XmlDiffError("Failed to read XML", e);
		}
		boolean result = differ.identical();
		
		XMLUnit.setIgnoreComments(true);
		XMLUnit.setIgnoreWhitespace(true);
		XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true);
		
		boolean result = differ.identical() || differ.similar();
		
		if (!result) {
			DetailedDiff details = new DetailedDiff(differ);
			@SuppressWarnings("unchecked")
			List<Difference> diffs = details.getAllDifferences();
			if (diffs.isEmpty()) {
				result = true;
			} else {
				for (Difference diff : diffs) {
				diffDetails.append(diff.getDescription());
					diffDetails.append(diff.toString()).append('\n');
				}
			}
		}
		return result;