diff --git a/testfiles/ICFA.KC.BIA.1524-small.jpg b/testfiles/ICFA.KC.BIA.1524-small.jpg new file mode 100644 index 00000000..be638559 Binary files /dev/null and b/testfiles/ICFA.KC.BIA.1524-small.jpg differ diff --git a/testfiles/output/3426592.jpg_XmlUnitExpectedOutput.xml b/testfiles/output/3426592.jpg_XmlUnitExpectedOutput.xml new file mode 100644 index 00000000..a236770b --- /dev/null +++ b/testfiles/output/3426592.jpg_XmlUnitExpectedOutput.xml @@ -0,0 +1,244 @@ + + + + + + + + + + 1.01 + fmt/43 + + + + 1036284 + Adobe Photoshop Elements 2.0 + 2005:07:15 12:26:58 + 2005-07-15T12:26:58 + 2005:07:15 12:26:58 + /Users/dan179/git/git-daveneiman/fits/testfiles/3426592.jpg + 3426592.jpg + ac780de154d1eedff7fec0a22173f7d7 + 1460585102000 + + + true + true + Value offset not word-aligned: 75 offset=732 + Value offset not word-aligned: 91 offset=744 + Value offset not word-aligned: 139 offset=756 + Value offset not word-aligned: 163 offset=780 + + + + big endian + JPEG + 1220 + 1462 + YCbCr + 0 0 0 0 0 0 + 0.0 + 2 2 + 0 0 0 + 0.0 + Unknown (0) + 0 + normal* + in. + 1200 + 1200 + 8 8 8 + 3 + 0 + 0 + Adobe Photoshop Elements 2.0 + 0 + 0 + 0, 0 + 0 + 0 + unknown + 0 m + 0.0 + Flash did not fire + 0.0 + 0 + Unknown (0) + Not defined + 1 + 0.0 + 1.0 + 0.0 + 1.0 + 0.0 + 3737950.0 + + + + big endian + + JPEG + + + + + 1220 + 1462 + + YCbCr + + + 2 + 2 + + + + 0 + 100 + + + 0 + 100 + + + 0 + 100 + + + + + + Y + + 0 + 100 + + + 0 + 100 + + + + Cb + + 0 + 100 + + + 0 + 100 + + + + Cr + + 0 + 100 + + + 0 + 100 + + + + + + + + + 2005-07-15T16:26:58.0Z + + + + Adobe Photoshop Elements 2.0 + + + + + + + 0.0 + 0.0 + Not defined + + 1 + 1 + + + 100 + 100 + + + 0 + 1 + + + 0 + 1 + + + 100 + 100 + + unknown + Flash did not fire + 0.0 + + + + normal* + + + + in. + + 1200 + 1 + + + 1200 + 1 + + + + + 8 + 8 + 8 + integer + + 3 + + + 0 + 1 + + + 0 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testfiles/output/4072820.tif_XmlUnitExpectedOutput.xml b/testfiles/output/4072820.tif_XmlUnitExpectedOutput.xml new file mode 100644 index 00000000..eff17683 --- /dev/null +++ b/testfiles/output/4072820.tif_XmlUnitExpectedOutput.xml @@ -0,0 +1,152 @@ + + + + + + + 2.2 + x-fmt/387 + + + + 13941032 + Adobe Photoshop CS Macintosh + 2005:12:15 12:46:50 + 2005-12-15T12:46:50 + 2005:12:15 10:56:19-05:00 + /Users/dan179/git/git-daveneiman/fits/testfiles/4072820.tif + 4072820.tif + 4a333061a5619b94aa5afc3bb106eb54 + 1460585102000 + + + + + Uncompressed + 1867 + 2484 + RGB + sRGB IEC61966-2.1 + 2.1.0 + 300 + 300 + 8 8 8 + 3 + digital still camera + NIKON CORPORATION + NIKON D100 + Adobe Photoshop CS Macintosh + 8.0 + 0.0333 + Manual + 0220 + 0 + 2.8 + Pattern + unknown + Flash did not fire + 28.0 + One-chip color area sensor + [Green,Red][Blue,Green] + + + + + Uncompressed + + + + + 1867 + 2484 + + RGB + + + sRGB IEC61966-2.1 + 2.1.0 + + + + + + + + 2005-12-15T15:56:19.0Z + digital still camera + + + + Adobe Photoshop CS Macintosh + + + + NIKON CORPORATION + + NIKON D100 + + + + 8.0 + 0.0333 + Manual + 0220 + + 0 + 1 + + + 280 + 100 + + Pattern + unknown + Flash did not fire + 28.0 + One-chip color area sensor + + + + + + + + 300 + 1 + + + 300 + 1 + + + + + 8 + 8 + 8 + integer + + 3 + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testfiles/output/ICFA.KC.BIA.1524-small.jpg_XmlUnitExpectedOutput.xml b/testfiles/output/ICFA.KC.BIA.1524-small.jpg_XmlUnitExpectedOutput.xml new file mode 100644 index 00000000..cdcf5820 --- /dev/null +++ b/testfiles/output/ICFA.KC.BIA.1524-small.jpg_XmlUnitExpectedOutput.xml @@ -0,0 +1,183 @@ + + + + + + + + + + 2.2.1 + 5.5 + fmt/645 + + + + 38829 + Canon EOS 5D Mark II + Adobe Photoshop CS6 (Windows) + 2017:01:30 11:39:51 + 2017-01-30T11:39:51 + 2010:07:07 14:22:53 + 2017:01:30 11:39:51 + /Users/dan179/git/git-daveneiman/fits/testfiles/ICFA.KC.BIA.1524-small.jpg + ICFA.KC.BIA.1524-small.jpg + 0108175c9153da1d41278066a2e3c1a2 + 1487174117000 + + + true + true + Value offset not word-aligned: 239 offset=126 + Value offset not word-aligned: 247 offset=138 + Value offset not word-aligned: 255 offset=174 + Value offset not word-aligned: 285 offset=186 + + + + big endian + JPEG + Uncompressed + 109 + 150 + RGB + Adobe RGB (1998) + 1 1 + normal* + in. + 350 + 350 + 8 8 8 + 3 + Adobe Photoshop CS6 (Windows) + Canon EOS 5D Mark II + 11.0 + 0.125 + 100 + 0 + unknown + 50.0 + 2.1.0 + Canon + 0221 + 1220 + 1/8 + 11.0 + 6.918863 + 2.5 + 2.625 + + + + big endian + + JPEG + + + + + 109 + 150 + + RGB + + + Adobe RGB (1998) + 2.1.0 + + + + + 1 + 1 + + + + + + + + 2010-07-07T18:22:53.0Z + + + + Adobe Photoshop CS6 (Windows) + + + + Canon + + Canon EOS 5D Mark II + + + + 11.0 + 0.125 + 100 + 0221 + + 1 + 8 + + + 1100 + 100 + + + 0 + 1 + + + 250 + 100 + + unknown + 50.0 + + + + normal* + + + + in. + + 350 + 1 + + + 350 + 1 + + + + + 8 + 8 + 8 + integer + + 3 + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testfiles/output/topazscanner.tif_XmlUnitExpectedOutput.xml b/testfiles/output/topazscanner.tif_XmlUnitExpectedOutput.xml new file mode 100644 index 00000000..3367a67d --- /dev/null +++ b/testfiles/output/topazscanner.tif_XmlUnitExpectedOutput.xml @@ -0,0 +1,112 @@ + + + + + + + + + 5146108 + Adobe Photoshop CS Macintosh + 2006:11:28 13:30:06 + 2006-11-28T13:30:06 + 2006:11:28 12:22:59-05:00 + /Users/dan179/git/git-daveneiman/fits/testfiles/topazscanner.tif + topazscanner.tif + c2c36f561b1da65ff74ea2b22fe3fba0 + 1446674963000 + + + + + Uncompressed + 1060 + 1611 + RGB + Adobe RGB (1998) + 2.1.0 + 1200 + 1200 + 8 8 8 + 3 + HDPPKIEL + TOPAZ iX Scanner + Adobe Photoshop CS Macintosh + + + + + Uncompressed + + + + + 1060 + 1611 + + RGB + + + Adobe RGB (1998) + 2.1.0 + + + + + + + + 2006-11-28T17:22:59.0Z + + + HDPPKIEL + + TOPAZ iX Scanner + + + Adobe Photoshop CS Macintosh + + + + + + + 1200 + 1 + + + 1200 + 1 + + + + + 8 + 8 + 8 + integer + + 3 + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/edu/harvard/hul/ois/fits/junit/MixTest.java b/tests/edu/harvard/hul/ois/fits/junit/MixTest.java index 1c30c57f..93196905 100644 --- a/tests/edu/harvard/hul/ois/fits/junit/MixTest.java +++ b/tests/edu/harvard/hul/ois/fits/junit/MixTest.java @@ -125,4 +125,27 @@ public void testMixJpg() throws Exception { fitsOut.saveToDisk("test-generated-output/" + filename + "_Output.xml"); } + + @Test + public void testJpgExif() throws Exception { + + String filename = "ICFA.KC.BIA.1524-small.jpg"; + File input = new File("testfiles/" + filename); + + FitsOutput fitsOut = fits.examine(input); + + XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat()); + serializer.output(fitsOut.getFitsXml(), System.out); + + Mix mix = (Mix)fitsOut.getStandardXmlContent(); + mix.setRoot(true); + + XMLOutputFactory xmlof = XMLOutputFactory.newInstance(); + XMLStreamWriter writer = xmlof.createXMLStreamWriter(System.out); + + mix.output(writer); + fitsOut.addStandardCombinedFormat(); // output all data to file + fitsOut.saveToDisk("test-generated-output/" + filename + "_Output.xml"); + + } } diff --git a/tests/edu/harvard/hul/ois/fits/junit/MixXmlUnitTest.java b/tests/edu/harvard/hul/ois/fits/junit/MixXmlUnitTest.java new file mode 100644 index 00000000..14fd5721 --- /dev/null +++ b/tests/edu/harvard/hul/ois/fits/junit/MixXmlUnitTest.java @@ -0,0 +1,247 @@ +/* + * Copyright 2009 Harvard University Library + * + * This file is part of FITS (File Information Tool Set). + * + * FITS is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FITS is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with FITS. If not, see . + */ +package edu.harvard.hul.ois.fits.junit; + +import static org.custommonkey.xmlunit.XMLAssert.assertXMLIdentical; + +import java.io.File; +import java.io.IOException; +import java.util.List; +import java.util.Scanner; + +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamWriter; + +import org.custommonkey.xmlunit.DetailedDiff; +import org.custommonkey.xmlunit.Diff; +import org.custommonkey.xmlunit.Difference; +import org.custommonkey.xmlunit.XMLUnit; +import org.jdom.output.Format; +import org.jdom.output.XMLOutputter; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.xml.sax.SAXException; + +import edu.harvard.hul.ois.fits.Fits; +import edu.harvard.hul.ois.fits.FitsOutput; +import edu.harvard.hul.ois.fits.tests.AbstractLoggingTest; +import edu.harvard.hul.ois.ots.schemas.MIX.Mix; + +public class MixXmlUnitTest extends AbstractLoggingTest { + + private static final String ACTUAL_OUTPUT_FILE_SUFFIX = "_XmlUnitActualOutput.xml"; + private static final String EXPECTED_OUTPUT_FILE_SUFFIX = "_XmlUnitExpectedOutput.xml"; + private static final String[] IGNORED_XML_ELEMENTS = { + "version", + "created", + "toolversion", + "dateModified", + "fslastmodified", + "startDate", + "startTime", + "timestamp", + "fitsExecutionTime", + "executionTime", + "filepath", + "location", + "lastmodified"}; + + /* + * Only one Fits instance is needed to run all tests. + * This also speeds up the tests. + */ + private static Fits fits; + + @BeforeClass + public static void beforeClass() throws Exception { + // Set up XMLUnit and FITS for entire class. + XMLUnit.setIgnoreWhitespace(true); + XMLUnit.setNormalizeWhitespace(true); + fits = new Fits(); + // Use this instead of above line to turn on tool output. +// File fitsConfigFile = new File("testfiles/properties/fits-full-with-tool-output.xml"); +// fits = new Fits(null, fitsConfigFile); + } + + @AfterClass + public static void afterClass() { + fits = null; + } + + @Test + public void testMIX() throws Exception { + + String inputFilename = "topazscanner.tif"; + File input = new File("testfiles/" + inputFilename); + FitsOutput fitsOut = fits.examine(input); + + XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat()); + serializer.output(fitsOut.getFitsXml(), System.out); + + Mix mix = (Mix)fitsOut.getStandardXmlContent(); + mix.setRoot(true); + + XMLOutputFactory xmlof = XMLOutputFactory.newInstance(); + XMLStreamWriter writer = xmlof.createXMLStreamWriter(System.out); + + mix.output(writer); + fitsOut.addStandardCombinedFormat(); // output all data to file + fitsOut.saveToDisk("test-generated-output/" + inputFilename + ACTUAL_OUTPUT_FILE_SUFFIX); + + String actualXmlStr = serializer.outputString(fitsOut.getFitsXml()); + + // Read in the expected XML file + Scanner scan = new Scanner(new File( + "testfiles/output/" + inputFilename + EXPECTED_OUTPUT_FILE_SUFFIX)); + String expectedXmlStr = scan. + useDelimiter("\\Z").next(); + scan.close(); + + testActualAgainstExpected(actualXmlStr, expectedXmlStr, inputFilename); + } + + @Test + public void testUncompressedTif() throws Exception { + + String inputFilename = "4072820.tif"; + File input = new File("testfiles/" + inputFilename); + FitsOutput fitsOut = fits.examine(input); + + XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat()); + fitsOut.addStandardCombinedFormat(); + serializer.output(fitsOut.getFitsXml(), System.out); + + Mix mix = (Mix)fitsOut.getStandardXmlContent(); + + if(mix != null) { + mix.setRoot(true); + XMLOutputFactory xmlof = XMLOutputFactory.newInstance(); + XMLStreamWriter writer = xmlof.createXMLStreamWriter(System.out); + + mix.output(writer); + } + fitsOut.saveToDisk("test-generated-output/" + inputFilename + ACTUAL_OUTPUT_FILE_SUFFIX); + + String actualXmlStr = serializer.outputString(fitsOut.getFitsXml()); + + // Read in the expected XML file + Scanner scan = new Scanner(new File( + "testfiles/output/" + inputFilename + EXPECTED_OUTPUT_FILE_SUFFIX)); + String expectedXmlStr = scan. + useDelimiter("\\Z").next(); + scan.close(); + + testActualAgainstExpected(actualXmlStr, expectedXmlStr, inputFilename); + } + + @Test + public void testMixJpg() throws Exception { + + String inputFilename = "3426592.jpg"; + File input = new File("testfiles/" + inputFilename); + + FitsOutput fitsOut = fits.examine(input); + + XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat()); + serializer.output(fitsOut.getFitsXml(), System.out); + + Mix mix = (Mix)fitsOut.getStandardXmlContent(); + mix.setRoot(true); + + XMLOutputFactory xmlof = XMLOutputFactory.newInstance(); + XMLStreamWriter writer = xmlof.createXMLStreamWriter(System.out); + + mix.output(writer); + fitsOut.addStandardCombinedFormat(); // output all data to file + fitsOut.saveToDisk("test-generated-output/" + inputFilename + ACTUAL_OUTPUT_FILE_SUFFIX); + + String actualXmlStr = serializer.outputString(fitsOut.getFitsXml()); + + // Read in the expected XML file + Scanner scan = new Scanner(new File( + "testfiles/output/" + inputFilename + EXPECTED_OUTPUT_FILE_SUFFIX)); + String expectedXmlStr = scan. + useDelimiter("\\Z").next(); + scan.close(); + + testActualAgainstExpected(actualXmlStr, expectedXmlStr, inputFilename); + } + + @Test + public void testJpgExif() throws Exception { + + String inputFilename = "ICFA.KC.BIA.1524-small.jpg"; + File input = new File("testfiles/" + inputFilename); + + FitsOutput fitsOut = fits.examine(input); + + XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat()); + serializer.output(fitsOut.getFitsXml(), System.out); + + Mix mix = (Mix)fitsOut.getStandardXmlContent(); + mix.setRoot(true); + + XMLOutputFactory xmlof = XMLOutputFactory.newInstance(); + XMLStreamWriter writer = xmlof.createXMLStreamWriter(System.out); + + mix.output(writer); + fitsOut.addStandardCombinedFormat(); // output all data to file + fitsOut.saveToDisk("test-generated-output/" + inputFilename + ACTUAL_OUTPUT_FILE_SUFFIX); + + String actualXmlStr = serializer.outputString(fitsOut.getFitsXml()); + + // Read in the expected XML file + Scanner scan = new Scanner(new File( + "testfiles/output/" + inputFilename + EXPECTED_OUTPUT_FILE_SUFFIX)); + String expectedXmlStr = scan. + useDelimiter("\\Z").next(); + scan.close(); + + testActualAgainstExpected(actualXmlStr, expectedXmlStr, inputFilename); + } + + /* + * This method performs the actual test of actual FITS output against expected. + */ + private void testActualAgainstExpected(String actualXmlStr, String expectedXmlStr, String inputFilename) + throws SAXException, IOException { + Diff diff = new Diff(expectedXmlStr,actualXmlStr); + + // Initialize attributes or elements to ignore for difference checking + diff.overrideDifferenceListener(new IgnoreNamedElementsDifferenceListener(IGNORED_XML_ELEMENTS)); + + DetailedDiff detailedDiff = new DetailedDiff(diff); + + // Display any Differences + @SuppressWarnings("unchecked") + List 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()); + } + + } + assertXMLIdentical("Differences in XML for file: " + inputFilename, diff, true); + } +} diff --git a/version.properties b/version.properties index cf9c9cf9..cd516a90 100644 --- a/version.properties +++ b/version.properties @@ -1 +1 @@ -build.version=1.0.5 +build.version=1.0.6 diff --git a/xml/exiftool/exiftool_common_to_fits.xslt b/xml/exiftool/exiftool_common_to_fits.xslt index e41f69ee..187c1270 100644 --- a/xml/exiftool/exiftool_common_to_fits.xslt +++ b/xml/exiftool/exiftool_common_to_fits.xslt @@ -82,9 +82,6 @@ - - - diff --git a/xml/fileutility/fileutility_to_fits.xslt b/xml/fileutility/fileutility_to_fits.xslt index c1b7f334..d9042db5 100644 --- a/xml/fileutility/fileutility_to_fits.xslt +++ b/xml/fileutility/fileutility_to_fits.xslt @@ -116,7 +116,7 @@ - + diff --git a/xml/jhove/jhove_common_to_fits.xslt b/xml/jhove/jhove_common_to_fits.xslt index 0a8da2fd..466e04de 100644 --- a/xml/jhove/jhove_common_to_fits.xslt +++ b/xml/jhove/jhove_common_to_fits.xslt @@ -48,9 +48,6 @@ - - - diff --git a/xml/nlnz/fits/nlnz_jpeg_to_fits.xslt b/xml/nlnz/fits/nlnz_jpeg_to_fits.xslt index f0a60b3f..3e882e40 100644 --- a/xml/nlnz/fits/nlnz_jpeg_to_fits.xslt +++ b/xml/nlnz/fits/nlnz_jpeg_to_fits.xslt @@ -13,7 +13,7 @@ - +