From: <bo...@us...> - 2007-05-29 12:44:40
|
Revision: 217 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=217&view=rev Author: bodewig Date: 2007-05-29 05:44:41 -0700 (Tue, 29 May 2007) Log Message: ----------- duplicate code Modified Paths: -------------- trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLAssert.java Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLAssert.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLAssert.java 2007-05-29 12:31:26 UTC (rev 216) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLAssert.java 2007-05-29 12:44:41 UTC (rev 217) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001, Jeff Martin, Tim Bacon +Copyright (c) 2001-2007, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -450,14 +450,8 @@ String testXpath, Document testDocument) throws XpathException { - XpathEngine xpath = XMLUnit.newXpathEngine(); - Diff diff = new Diff(asXpathResultDocument(XMLUnit.newControlParser(), - xpath.getMatchingNodes(controlXpath, - controlDocument)), - asXpathResultDocument(XMLUnit.newTestParser(), - xpath.getMatchingNodes(testXpath, - testDocument))); - assertXMLEqual(diff, true); + assertXpathEquality(controlXpath, controlDocument, testXpath, + testDocument, true); } /** @@ -559,6 +553,25 @@ String testXpath, Document testDocument) throws XpathException { + assertXpathEquality(controlXpath, controlDocument, testXpath, + testDocument, false); + } + + /** + * Assert that the node lists of two Xpaths in two documents are + * equal or not. + * @param xpathOne + * @param xpathTwo + * @param document + * @param equality whether the values should be equal. + * @see XpathEngine + */ + private static void assertXpathEquality(String controlXpath, + Document controlDocument, + String testXpath, + Document testDocument, + boolean equal) + throws XpathException { XpathEngine xpath = XMLUnit.newXpathEngine(); Diff diff = new Diff(asXpathResultDocument(XMLUnit.newControlParser(), xpath.getMatchingNodes(controlXpath, @@ -566,7 +579,7 @@ asXpathResultDocument(XMLUnit.newTestParser(), xpath.getMatchingNodes(testXpath, testDocument))); - assertXMLEqual(diff, false); + assertXMLEqual(diff, equal); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |