use of org.custommonkey.xmlunit.DetailedDiff in project opennms by OpenNMS.
the class AccessPointMonitorConfigTest method getDiff.
@SuppressWarnings("unchecked")
private DetailedDiff getDiff(StringWriter objectXML, StringBuffer exampleXML) throws SAXException, IOException {
DetailedDiff myDiff = new DetailedDiff(XMLUnit.compareXML(exampleXML.toString(), objectXML.toString()));
List<Difference> allDifferences = myDiff.getAllDifferences();
if (allDifferences.size() > 0) {
for (Difference d : allDifferences) {
System.err.println(d);
}
}
return myDiff;
}
use of org.custommonkey.xmlunit.DetailedDiff in project opennms by OpenNMS.
the class TcaDataCollectionConfigTest method generateXML.
/**
* Generate XML.
*
* @throws Exception the exception
*/
@Test
public void generateXML() throws Exception {
// Marshal the test object to an XML string
StringWriter objectXML = new StringWriter();
marshaller.marshal(tcadcc, objectXML);
// Read the example XML from src/test/resources
StringBuffer exampleXML = new StringBuffer();
File tcaCollectionConfig = getSourceFile();
assertTrue(TcaDataCollectionConfig.TCA_DATACOLLECTION_CONFIG_FILE + " is readable", tcaCollectionConfig.canRead());
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(tcaCollectionConfig), StandardCharsets.UTF_8));
String line;
while (true) {
line = reader.readLine();
if (line == null) {
reader.close();
break;
}
exampleXML.append(line).append("\n");
}
System.err.println("========================================================================");
System.err.println("Object XML:");
System.err.println("========================================================================");
System.err.print(objectXML.toString());
System.err.println("========================================================================");
System.err.println("Example XML:");
System.err.println("========================================================================");
System.err.print(exampleXML.toString());
DetailedDiff myDiff = getDiff(objectXML, exampleXML);
assertEquals("number of XMLUnit differences between the example XML and the mock object XML is 0", 0, myDiff.getAllDifferences().size());
}
use of org.custommonkey.xmlunit.DetailedDiff in project opennms by OpenNMS.
the class JdbcDataCollectionConfigTest method generateXML.
@Test
public void generateXML() throws Exception {
// Marshal the test object to an XML string
StringWriter objectXML = new StringWriter();
JaxbUtils.marshal(jdcc, objectXML);
// Read the example XML from src/test/resources
final StringBuilder exampleXML = new StringBuilder();
File jdbcCollectionConfig = new File(ClassLoader.getSystemResource("jdbc-datacollection-config.xml").getFile());
assertTrue("jdbc-datacollection-config.xml is readable", jdbcCollectionConfig.canRead());
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(jdbcCollectionConfig), StandardCharsets.UTF_8));
String line;
while (true) {
line = reader.readLine();
if (line == null) {
reader.close();
break;
}
exampleXML.append(line).append("\n");
}
System.err.println("========================================================================");
System.err.println("Object XML:");
System.err.println("========================================================================");
System.err.print(objectXML.toString());
System.err.println("========================================================================");
System.err.println("Example XML:");
System.err.println("========================================================================");
System.err.print(exampleXML.toString());
DetailedDiff myDiff = getDiff(objectXML, exampleXML);
assertEquals("number of XMLUnit differences between the example XML and the mock object XML is 0", 0, myDiff.getAllDifferences().size());
}
use of org.custommonkey.xmlunit.DetailedDiff in project opennms by OpenNMS.
the class PersistenceSerializationTest method getDiff.
@SuppressWarnings("unchecked")
private static DetailedDiff getDiff(StringWriter objectXML, StringBuilder exampleXML) throws SAXException, IOException {
DetailedDiff myDiff = new DetailedDiff(XMLUnit.compareXML(exampleXML.toString(), objectXML.toString()));
List<Difference> allDifferences = myDiff.getAllDifferences();
if (allDifferences.size() > 0) {
for (Difference d : allDifferences) {
System.err.println(d);
}
}
return myDiff;
}
use of org.custommonkey.xmlunit.DetailedDiff in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityEntityToModelMapperTest method testMapToFLUXFAReportMessage.
@Test
@Parameters(method = "resources")
public void testMapToFLUXFAReportMessage(String resource) throws Exception {
FLUXFAReportMessage fluxfaReportMessage = sourceToEntity(resource);
FluxFaReportMessageEntity entity = incomingFAReportMapper.mapToFluxFaReportMessage(fluxfaReportMessage, FaReportSourceEnum.MANUAL, new FluxFaReportMessageEntity());
FLUXFAReportMessage target = modelMapper.mapToFLUXFAReportMessage(new ArrayList<>(entity.getFaReportDocuments()));
String controlSource = JAXBUtils.marshallJaxBObjectToString(getFirstElement(fluxfaReportMessage));
String testSource = JAXBUtils.marshallJaxBObjectToString(getFirstElement(target));
XMLUnit.setIgnoreWhitespace(true);
XMLUnit.setIgnoreComments(true);
XMLUnit.setIgnoreAttributeOrder(true);
DetailedDiff diff = new DetailedDiff(new org.custommonkey.xmlunit.Diff(clearEmptyTags(controlSource), clearEmptyTags(testSource)));
diff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());
assertTrue("XML are similar " + diff, diff.similar());
}
Aggregations