本文整理汇总了Java中org.custommonkey.xmlunit.XMLUnit.setIgnoreDiffBetweenTextAndCDATA方法的典型用法代码示例。如果您正苦于以下问题:Java XMLUnit.setIgnoreDiffBetweenTextAndCDATA方法的具体用法?Java XMLUnit.setIgnoreDiffBetweenTextAndCDATA怎么用?Java XMLUnit.setIgnoreDiffBetweenTextAndCDATA使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.custommonkey.xmlunit.XMLUnit
的用法示例。
在下文中一共展示了XMLUnit.setIgnoreDiffBetweenTextAndCDATA方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertXMLEquals
import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
public static void assertXMLEquals(String expectedXML, String actualXML) throws Exception {
XMLUnit.setIgnoreWhitespace(true);
XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true);
XMLUnit.setIgnoreAttributeOrder(true);
DetailedDiff diff = new DetailedDiff(XMLUnit.compareXML(expectedXML, actualXML));
List<?> allDifferences = diff.getAllDifferences();
Assert.assertEquals("Differences found: "+ diff.toString(), 0, allDifferences.size());
}
示例2: isXMLEqual
import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
protected void isXMLEqual(Document control, Document test)
throws SAXException, IOException {
XMLUnit.setIgnoreWhitespace(true);
XMLUnit.setIgnoreAttributeOrder(true);
XMLUnit.setIgnoreComments(true);
XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true);
// XMLUnit.setNormalize(true);
// Diff diff = compareXML (control, test);
assertXMLEqual(control, test);
}
示例3: testEString
import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
private byte[] testEString(String xmlAsString) throws EXIException, IOException, SAXException, TransformerException {
/* DTR Map */
QName type = new QName("", "es");
QName representation = new QName(Constants.W3C_EXI_NS_URI, "estring");
QName[] dtrMapTypes = { type };
QName[] dtrMapRepresentations = { representation };
// factory
EXIFactory ef = DefaultEXIFactory.newInstance();
ef.setFidelityOptions(FidelityOptions.createStrict());
ef.setGrammars(GrammarFactory.newInstance().createGrammars(new ByteArrayInputStream(xsdAsStringEString.getBytes())));
ef.setDatatypeRepresentationMap(dtrMapTypes, dtrMapRepresentations);
// encode
ByteArrayOutputStream baos = new ByteArrayOutputStream();
EXIResult exiResult = new EXIResult(ef);
exiResult.setOutputStream(baos);
XMLReader xmlReader = XMLReaderFactory.createXMLReader();
xmlReader.setContentHandler( exiResult.getHandler() );
xmlReader.parse(new InputSource(new ByteArrayInputStream(xmlAsString.getBytes()))); // parse XML input
// decode
ByteArrayOutputStream baosXML = new ByteArrayOutputStream();
Result result = new StreamResult(baosXML);
InputSource is = new InputSource(new ByteArrayInputStream(baos.toByteArray()));
SAXSource exiSource = new EXISource(ef);
exiSource.setInputSource(is);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = tf.newTransformer();
transformer.transform(exiSource, result);
// System.out.println(new String(baosXML.toByteArray()));
XMLUnit.setIgnoreWhitespace(true);
XMLUnit.setIgnoreAttributeOrder(true);
XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true);
XMLAssert.assertXMLEqual(new StringReader(xmlAsString), new StringReader(new String(baosXML.toByteArray())));
return baos.toByteArray();
}