diff --git a/.gitignore b/.gitignore index 5f80b712..9ed47574 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ TAGS /build/ /fits-tests.log /javadoc/ +/target/ diff --git a/testfiles/output/test.xml_XmlUnitExpectedOutput.xml b/testfiles/output/test.xml_XmlUnitExpectedOutput.xml new file mode 100644 index 00000000..15e7ce3a --- /dev/null +++ b/testfiles/output/test.xml_XmlUnitExpectedOutput.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + 1.0 + fmt/101 + + + + 3219 + /Users/dan179/git/git-daveneiman/fits/testfiles/test.xml + test.xml + 43ebf426e75119483bbea6729ba567e9 + 1523306483000 + + + true + true + + + + utf-8 + XML + 1.0 + http://www.loc.gov/standards/mets/mets.xsd + + + + + + + + + + + + + + + + + + + diff --git a/testfiles/test.xml b/testfiles/test.xml new file mode 100644 index 00000000..cbb0e4a4 --- /dev/null +++ b/testfiles/test.xml @@ -0,0 +1,67 @@ + + + + + + + + Manks, Dorothy St. John + + + Massachusetts Horticultural Society library :a classification scheme for horticulture + + 123 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
diff --git a/tests/edu/harvard/hul/ois/fits/junit/XmlFileTest.java b/tests/edu/harvard/hul/ois/fits/junit/XmlFileTest.java new file mode 100644 index 00000000..f6e97ef2 --- /dev/null +++ b/tests/edu/harvard/hul/ois/fits/junit/XmlFileTest.java @@ -0,0 +1,66 @@ +/* + * Copyright 2016 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 java.io.File; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import edu.harvard.hul.ois.fits.Fits; +import edu.harvard.hul.ois.fits.FitsOutput; +import edu.harvard.hul.ois.fits.tests.AbstractXmlUnitTest; + +/** + * These generated FITS output with tool output on the given files files. + * + * @author dan179 + */ +public class XmlFileTest extends AbstractXmlUnitTest { + + /* + * Only one Fits instance is needed to run tests. + * This also speeds up the tests. + */ + private static Fits fits; + + @BeforeClass + public static void beforeClass() throws Exception { + // Set up FITS for entire class. + 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 testXmlFile() throws Exception { + + String inputFilename = "test.xml"; + File input = new File("testfiles/" + inputFilename); + FitsOutput fitsOut = fits.examine(input); + fitsOut.addStandardCombinedFormat(); + fitsOut.saveToDisk("test-generated-output/" + inputFilename + "_Output.xml"); + } + +} diff --git a/tests/edu/harvard/hul/ois/fits/junit/XmlFileXmlUnitTest.java b/tests/edu/harvard/hul/ois/fits/junit/XmlFileXmlUnitTest.java new file mode 100644 index 00000000..37590ab1 --- /dev/null +++ b/tests/edu/harvard/hul/ois/fits/junit/XmlFileXmlUnitTest.java @@ -0,0 +1,80 @@ +/* + * Copyright 2016 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 java.io.File; +import java.util.Scanner; + +import org.jdom.output.Format; +import org.jdom.output.XMLOutputter; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import edu.harvard.hul.ois.fits.Fits; +import edu.harvard.hul.ois.fits.FitsOutput; +import edu.harvard.hul.ois.fits.tests.AbstractXmlUnitTest; + +/** + * These generated FITS output with tool output on the given files files. + * These tests should be run with <display-tool-output>false</display-tool-output> in fits.xml. + * + * @author dan179 + */ +public class XmlFileXmlUnitTest extends AbstractXmlUnitTest { + + /* + * Only one Fits instance is needed to run tests. + * This also speeds up the tests. + */ + private static Fits fits; + + @BeforeClass + public static void beforeClass() throws Exception { + // Set up FITS for entire class. + fits = new Fits(); + } + + @AfterClass + public static void afterClass() { + fits = null; + } + + @Test + public void testXmlFile() throws Exception { + + String inputFilename = "test.xml"; + File input = new File("testfiles/" + inputFilename); + FitsOutput fitsOut = fits.examine(input); + fitsOut.saveToDisk("test-generated-output/" + inputFilename + ACTUAL_OUTPUT_FILE_SUFFIX); + + 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/" + inputFilename + EXPECTED_OUTPUT_FILE_SUFFIX)); + String expectedXmlStr = scan. + useDelimiter("\\Z").next(); + scan.close(); + + testActualAgainstExpected(actualXmlStr, expectedXmlStr, inputFilename); + } + +} diff --git a/tests/edu/harvard/hul/ois/fits/junit/ZipXmlTest.java b/tests/edu/harvard/hul/ois/fits/junit/ZipXmlTest.java index c788911f..5fb4ecf5 100644 --- a/tests/edu/harvard/hul/ois/fits/junit/ZipXmlTest.java +++ b/tests/edu/harvard/hul/ois/fits/junit/ZipXmlTest.java @@ -30,7 +30,6 @@ /** * These generated FITS output with tool output on the given files files. - * These tests should be run with <display-tool-output>false</display-tool-output> in fits.xml. * * @author dan179 */ diff --git a/xml/fileutility/fileutility_to_fits.xslt b/xml/fileutility/fileutility_to_fits.xslt index c2ccc639..0c4c1364 100644 --- a/xml/fileutility/fileutility_to_fits.xslt +++ b/xml/fileutility/fileutility_to_fits.xslt @@ -217,7 +217,7 @@ - +