@Test public void testAudioMD_noMD5() throws Exception { Fits fits = new Fits(); // First generate the FITS output File input = new File("testfiles/test.wav"); FitsOutput fitsOut = fits.examine(input); XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat()); String actualXmlStr = serializer.outputString(fitsOut.getFitsXml()); // Read in the expected XML file Scanner scan = new Scanner(new File("testfiles/output/FITS_test_wav_NO_MD5.xml")); String expectedXmlStr = scan.useDelimiter("\\Z").next(); scan.close(); // Set up XMLUnit XMLUnit.setIgnoreWhitespace(true); XMLUnit.setNormalizeWhitespace(true); Diff diff = new Diff(expectedXmlStr, actualXmlStr); // Initialize attributes or elements to ignore for difference checking diff.overrideDifferenceListener( new IgnoreNamedElementsDifferenceListener( "version", "toolversion", "dateModified", "fslastmodified", "lastmodified", "startDate", "startTime", "timestamp", "fitsExecutionTime", "executionTime", "filepath", "location")); DetailedDiff detailedDiff = new DetailedDiff(diff); // Display any Differences List<Difference> diffs = detailedDiff.getAllDifferences(); if (!diff.identical()) { StringBuffer differenceDescription = new StringBuffer(); differenceDescription.append(diffs.size()).append(" differences"); System.out.println(differenceDescription.toString()); for (Difference difference : diffs) { System.out.println(difference.toString()); } } assertTrue("Differences in XML", diff.identical()); }
@Test public void testEquality() throws Exception { // convert FitsOutput xml doms to strings for the diff StringWriter sw = new StringWriter(); Document expectedDom = expected.getFitsXml(); Document actualDom = actual.getFitsXml(); serializer.output(actualDom, sw); String actualStr = sw.toString(); sw = new StringWriter(); serializer.output(expectedDom, sw); String expectedStr = sw.toString(); // get the file name in case of a failure FitsMetadataElement item = actual.getMetadataElement("filename"); DifferenceListener myDifferenceListener = new IgnoreAttributeValuesDifferenceListener(); Diff diff = new Diff(expectedStr, actualStr); diff.overrideDifferenceListener(myDifferenceListener); assertXMLIdentical("Error comparing: " + item.getValue(), diff, true); }