本文整理匯總了Java中org.custommonkey.xmlunit.XMLUnit.setNormalize方法的典型用法代碼示例。如果您正苦於以下問題:Java XMLUnit.setNormalize方法的具體用法?Java XMLUnit.setNormalize怎麽用?Java XMLUnit.setNormalize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.custommonkey.xmlunit.XMLUnit
的用法示例。
在下文中一共展示了XMLUnit.setNormalize方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: compareXmlIgnoringWhitespace
import org.custommonkey.xmlunit.XMLUnit; //導入方法依賴的package包/類
/**
* Compares XML documents provided by the two Readers.
*
* @param expected The expected document data.
* @param actual The actual document data.
* @return A DetailedDiff 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.
*/
protected static Diff compareXmlIgnoringWhitespace(final String expected, final String actual) throws SAXException,
IOException {
// Check sanity
org.apache.commons.lang3.Validate.notNull(expected, "Cannot handle null expected argument.");
org.apache.commons.lang3.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);
}
示例2: assertXMLEquals
import org.custommonkey.xmlunit.XMLUnit; //導入方法依賴的package包/類
private void assertXMLEquals(String expectedXML, String actualXML) throws SAXException, IOException {
XMLUnit.setIgnoreWhitespace(true);
XMLUnit.setIgnoreAttributeOrder(true);
XMLUnit.setNormalize(true);
DetailedDiff diff = new DetailedDiff(XMLUnit.compareXML(expectedXML, actualXML));
List<?> allDifferences = diff.getAllDifferences();
Assert.assertEquals("XML differences found: " + diff.toString(), 0, allDifferences.size());
}