本文整理匯總了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();
}