本文整理汇总了Java中org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier类的典型用法代码示例。如果您正苦于以下问题:Java RecursiveElementNameAndTextQualifier类的具体用法?Java RecursiveElementNameAndTextQualifier怎么用?Java RecursiveElementNameAndTextQualifier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RecursiveElementNameAndTextQualifier类属于org.custommonkey.xmlunit.examples包,在下文中一共展示了RecursiveElementNameAndTextQualifier类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: assertModelEqualsFile
import org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier; //导入依赖的package包/类
protected void assertModelEqualsFile(String expectedPath) throws Exception {
File actualFile = tmpFolder.newFile();
Dmn.writeModelToFile(actualFile, modelInstance);
File expectedFile = ReflectUtil.getResourceAsFile(expectedPath);
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document actualDocument = docBuilder.parse(actualFile);
Document expectedDocument = docBuilder.parse(expectedFile);
Diff diff = new Diff(expectedDocument, actualDocument);
if (!diff.similar()) {
diff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());
DetailedDiff detailedDiff = new DetailedDiff(diff);
String failMsg = "XML differs:\n" + detailedDiff.getAllDifferences() + "\n\nActual XML:\n" + Dmn.convertToString(modelInstance);
fail(failMsg);
}
}
开发者ID:camunda,项目名称:camunda-dmn-model,代码行数:20,代码来源:DmnModelTest.java
示例2: testXmlMarshal
import org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier; //导入依赖的package包/类
@Test
public void testXmlMarshal() throws Exception {
final JAXBContext context = JAXBContext.newInstance(cls);
final Marshaller mr = context.createMarshaller();
mr.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
mr.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
XMLUnit.setIgnoreWhitespace(true);
for (final Map.Entry<T, String> entry : marshalTestData.entrySet()) {
final T obj = entry.getKey();
final String xml = entry.getValue();
final StringWriter writer = new StringWriter();
mr.marshal(obj, writer);
final String actual = writer.toString();
logger.info("Object is:\n{}", obj);
logger.info("Expected XML is:\n{}", XmlUtils.formatXml(xml));
logger.info("Actual XML is:\n{}\n", actual);
final Diff diff = new Diff(xml, actual);
// we don't care about ordering
diff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());
XMLAssert.assertXMLEqual(diff, true);
}
}
开发者ID:Haixing-Hu,项目名称:iLibrary,代码行数:23,代码来源:XmlSerializationTest.java
示例3: compareXml
import org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier; //导入依赖的package包/类
/**
* Compares two XML files without regard to the order of elements or attributes, and ignoring any element named \"releaseDate\".
* @return Whether the files are \"similar\"
*/
public static boolean compareXml(File expectedFile, File actualFile) {
try {
FileReader expectedFr = new FileReader(expectedFile);
FileReader actualFr = new FileReader(actualFile);
Diff diff = new Diff(expectedFr, actualFr);
// ignore order
// look at element, id, and weight (weight is a nested element)
diff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());
diff.overrideDifferenceListener(new ElementIgnoringDifferenceListener("releaseDate"));
final boolean isSimilar = diff.similar();
if (!isSimilar) printDetailedDiff(diff, System.err);
expectedFr.close();
actualFr.close();
return isSimilar;
} catch (IOException | SAXException e) {
throw new RuntimeException(e);
}
}
开发者ID:dmyersturnbull,项目名称:network_merge,代码行数:23,代码来源:TestUtils.java
示例4: doAssertXmlEquals
import org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier; //导入依赖的package包/类
private static void doAssertXmlEquals(String expectedXml, String actualXml) throws Exception {
Diff diff = new Diff(expectedXml, actualXml);
diff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());
if (!diff.similar()) {
fail(String.format("\nExpected the following XML\n" + formatXml(expectedXml) +
"\nbut actual XML was\n\n" +
formatXml(actualXml)));
}
}
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:10,代码来源:XmlAsserts.java
示例5: assertXMLEqual
import org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier; //导入依赖的package包/类
private void assertXMLEqual(String expectedXml, String resultXml) {
try {
Diff diff = new Diff(expectedXml, resultXml);
diff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());
XMLAssert.assertXMLEqual(diff, true);
} catch (Exception e) {
throw new RuntimeException("XML Assertion failure", e);
}
}
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:10,代码来源:XStreamBatchExecutionTest.java
示例6: assertXMLEqual
import org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier; //导入依赖的package包/类
public void assertXMLEqual(String expectedXml, String resultXml) {
try {
Diff diff = new Diff(expectedXml, resultXml);
diff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());
XMLAssert.assertXMLEqual(diff, true);
} catch (Exception e) {
throw new RuntimeException("XML Assertion failure", e);
}
}
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:10,代码来源:XStreamBatchTest.java
示例7: validateQuery
import org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier; //导入依赖的package包/类
protected void validateQuery(InputStream query, InputStream expectedResults) {
String actualResults = executeQuery(query) ;
XMLUnit.setIgnoreWhitespace(true) ;
Diff resultsDiff ;
try {
resultsDiff = new Diff(asString(expectedResults), actualResults) ;
} catch (Exception e) {
throw new RuntimeException("Exception comparing results.", e) ;
}
resultsDiff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier()) ;
assertTrue(resultsDiff.toString(), resultsDiff.similar()) ;
}
开发者ID:NCIP,项目名称:digital-model-repository,代码行数:13,代码来源:CvitDataServiceTests.java
示例8: testCarToXml
import org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier; //导入依赖的package包/类
public void testCarToXml() throws Exception {
String xml = beanXmlConverter.convertToXml(car);
XMLUnit.setIgnoreWhitespace(true);
Diff diff;
diff = new Diff(TestModel.Car.DEFAULT_XML, xml);
diff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());
XMLAssert.assertXMLEqual(diff, true);
}
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:9,代码来源:BeanXmlConverterTest.java
示例9: assertSimilar
import org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier; //导入依赖的package包/类
public static void assertSimilar(CharSequence expected, CharSequence actual) throws SAXException, IOException {
Diff diff = new Diff(expected.toString(), actual.toString());
diff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());
assertXMLEqual(diff, true);
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:6,代码来源:XmlUnitUtils.java
示例10: assertXMLEqual
import org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier; //导入依赖的package包/类
protected void assertXMLEqual(String expected, String result) throws Exception {
Diff diff = new Diff(expected, result);
diff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());
XMLAssert.assertXMLEqual(diff, true);
}
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:6,代码来源:KieCamelTestSupport.java
示例11: testXmlMarshalling
import org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier; //导入依赖的package包/类
/**
* Tests that {@link MetadataResource metadata resources} are marshalled to
* the expected XML format.
* @throws IOException if the {@link Diff} constructor fails
* @throws JAXBException if the {@link JAXBContext} or {@link Marshaller} fail
* @throws SAXException if the {@link Diff} constructor fails
*/
@Test
public void testXmlMarshalling() throws IOException, JAXBException,
SAXException
{
// Generate the expected output.
String expectedXml =
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
+ "<metadata>"
+ "<keyval><key>1</key><val>one</val></keyval>"
+ "<keyval><key>2</key><val>two</val></keyval>"
+ "<keyval><key>3</key><val>three</val></keyval>"
+ "<keyval><key>4</key><val>a</val><val>b</val><val>c</val></keyval>"
+ "</metadata>";
// Create a MetadataResource using a Metadata instance.
Hashtable metadataEntries = new Hashtable<String, Object>();
metadataEntries.put("1", "one");
metadataEntries.put("2", "two");
metadataEntries.put("3", "three");
List<String> list = new ArrayList<String>();
list.add("a");
list.add("b");
list.add("c");
metadataEntries.put("4", list);
Metadata metadata = new Metadata();
metadata.addMetadata(metadataEntries);
MetadataResource resource = new MetadataResource(metadata);
// Set up a JAXB context and marshall the ReferenceResource to XML.
JAXBContext context = JAXBContext.newInstance(resource.getClass());
Marshaller marshaller = context.createMarshaller();
StringWriter writer = new StringWriter();
marshaller.marshal(resource, writer);
// Compare the expected and actual outputs.
XMLUnit.setIgnoreWhitespace(true);
XMLUnit.setIgnoreComments(true);
XMLUnit.setIgnoreAttributeOrder(true);
Diff diff = new Diff(expectedXml, writer.toString());
diff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());
assertTrue("The output XML was different to the expected XML: "
+ diff.toString(), diff.similar());
}
开发者ID:apache,项目名称:oodt,代码行数:53,代码来源:MetadataResourceTest.java
注:本文中的org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论