Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/harvard-lts/fits into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
daveneiman committed Apr 9, 2019
2 parents e175bf1 + aa678b2 commit 350c86c
Show file tree
Hide file tree
Showing 18 changed files with 439 additions and 68 deletions.
2 changes: 1 addition & 1 deletion License.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#### FITS Servlet Package License
Copyright ©2018 The President and Fellows of Harvard College
Copyright ©2019 The President and Fellows of Harvard College

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>edu.harvard.huit.lts</groupId>
<artifactId>fits</artifactId>
<version>1.4.0</version>
<version>1.4.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>FITS</name>
Expand All @@ -17,7 +17,7 @@
<bcmail.version>132</bcmail.version>
<log4j.version>1.2.17</log4j.version>
<slf4j.version>1.7.22</slf4j.version>
<tika.version>1.19.1</tika.version>
<tika.version>1.20</tika.version>
<jdom.version>1.1.3</jdom.version>
<woodstox.version>4.4.1</woodstox.version>
<xmlunit.version>1.6</xmlunit.version>
Expand Down
62 changes: 62 additions & 0 deletions src/test/java/edu/harvard/hul/ois/fits/junit/M4aTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
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.AbstractLoggingTest;


public class M4aTest extends AbstractLoggingTest {

/*
* 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 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 testM4a() throws Exception {

String fileName = "sample.m4a";
File input = new File("testfiles/" + fileName);
FitsOutput fitsOut = fits.examine(input);
fitsOut.addStandardCombinedFormat();
fitsOut.saveToDisk("test-generated-output/" + fileName + "_Output.xml");
}

}
93 changes: 93 additions & 0 deletions src/test/java/edu/harvard/hul/ois/fits/junit/M4aXmlUnitTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
package edu.harvard.hul.ois.fits.junit;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
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;


public class M4aXmlUnitTest extends AbstractXmlUnitTest {

/*
* 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 FITS for entire class.
fits = new Fits();
}

@AfterClass
public static void afterClass() {
fits = null;
}

@Override
protected String[] getIgnoredXmlElements() {
String[] ignored = super.getIgnoredXmlElements();
List<String> additionalIgnored = new ArrayList<>(Arrays.asList(ignored));
additionalIgnored.add("ID");
additionalIgnored.add("audioObjectRef");
additionalIgnored.add("formatRef");
additionalIgnored.add("faceRef");
additionalIgnored.add("faceRegionRef");
additionalIgnored.add("ownerRef");

return additionalIgnored.toArray(new String[additionalIgnored.size()]);
}

@Test
public void testM4a() throws Exception {

String inputFilename = "sample.m4a";
File input = new File("testfiles/" + inputFilename);
FitsOutput fitsOut = fits.examine(input);
fitsOut.addStandardCombinedFormat();
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);
}

}
15 changes: 15 additions & 0 deletions src/test/java/edu/harvard/hul/ois/fits/junit/MixTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
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;
Expand Down Expand Up @@ -153,5 +156,17 @@ public void testJp2_2() throws Exception {
fitsOut.addStandardCombinedFormat(); // output all data to file
fitsOut.saveToDisk("test-generated-output/" + inputFilename + "_Output.xml");
}

@Test
public void testNotWellFormedJp2() throws Exception {

String inputFilename = "2339337_not_well_formed.jp2";
File input = new File("testfiles/" + inputFilename);

FitsOutput fitsOut = fits.examine(input);

fitsOut.addStandardCombinedFormat(); // output all data to file
fitsOut.saveToDisk("test-generated-output/" + inputFilename + "_Output.xml");
}

}
24 changes: 24 additions & 0 deletions src/test/java/edu/harvard/hul/ois/fits/junit/MixXmlUnitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,5 +269,29 @@ public void testJp2_2() throws Exception {

testActualAgainstExpected(actualXmlStr, expectedXmlStr, inputFilename);
}

@Test
public void testNotWellFormedJp2() throws Exception {

String inputFilename = "2339337_not_well_formed.jp2";
File input = new File("testfiles/" + inputFilename);

FitsOutput fitsOut = fits.examine(input);

fitsOut.addStandardCombinedFormat(); // output all data to file
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);
}

}
Binary file added testfiles/2339337_not_well_formed.jp2
Binary file not shown.
13 changes: 7 additions & 6 deletions testfiles/output/006607203_00018.jp2_XmlUnitExpectedOutput.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<fits xmlns="http://hul.harvard.edu/ois/xml/ns/fits/fits_output" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://hul.harvard.edu/ois/xml/ns/fits/fits_output http://hul.harvard.edu/ois/xml/xsd/fits/fits_output.xsd" version="1.2.x" timestamp="2/13/18 2:58 PM">
<identification>
<identity format="JPEG 2000 JP2" mimetype="image/jp2" toolname="FITS" toolversion="1.2.x">
<tool toolname="Droid" toolversion="6.3" />
<tool toolname="Jhove" toolversion="1.16" />
<tool toolname="Exiftool" toolversion="10.00" />
<tool toolname="Tika" toolversion="1.10" />
<externalIdentifier toolname="Droid" toolversion="6.3" type="puid">x-fmt/392</externalIdentifier>
<identity format="JPEG 2000 JP2" mimetype="image/jp2" toolname="FITS" toolversion="1.4.1">
<tool toolname="Droid" toolversion="6.4" />
<tool toolname="Jhove" toolversion="1.20.1" />
<tool toolname="file utility" toolversion="5.31" />
<tool toolname="Exiftool" toolversion="11.14" />
<tool toolname="Tika" toolversion="1.19.1" />
<externalIdentifier toolname="Droid" toolversion="6.4" type="puid">x-fmt/392</externalIdentifier>
</identity>
</identification>
<fileinfo>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<fits xmlns="http://hul.harvard.edu/ois/xml/ns/fits/fits_output" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://hul.harvard.edu/ois/xml/ns/fits/fits_output http://hul.harvard.edu/ois/xml/xsd/fits/fits_output.xsd" version="1.4.0-SNAPSHOT" timestamp="4/2/19 4:22 PM">
<identification>
<identity format="JPEG 2000 JP2" mimetype="image/jp2" toolname="FITS" toolversion="1.4.1">
<tool toolname="Droid" toolversion="6.4" />
<tool toolname="Jhove" toolversion="1.20.1" />
<tool toolname="file utility" toolversion="5.31" />
<tool toolname="Exiftool" toolversion="11.14" />
<tool toolname="Tika" toolversion="1.19.1" />
<externalIdentifier toolname="Droid" toolversion="6.4" type="puid">x-fmt/392</externalIdentifier>
</identity>
</identification>
<fileinfo>
<size toolname="Jhove" toolversion="1.20.1">120521</size>
<filepath toolname="OIS File Information" toolversion="0.2" status="SINGLE_RESULT">/Users/dan179/git/git-daveneiman/fits/testfiles/2339337_not_well_formed.jp2</filepath>
<filename toolname="OIS File Information" toolversion="0.2" status="SINGLE_RESULT">2339337_not_well_formed.jp2</filename>
<md5checksum toolname="OIS File Information" toolversion="0.2" status="SINGLE_RESULT">1c9c7abb1cf187de78f550ec474f9952</md5checksum>
<fslastmodified toolname="OIS File Information" toolversion="0.2" status="SINGLE_RESULT">1554236769000</fslastmodified>
</fileinfo>
<filestatus>
<well-formed toolname="Jhove" toolversion="1.20.1" status="SINGLE_RESULT">false</well-formed>
<valid toolname="Jhove" toolversion="1.20.1" status="SINGLE_RESULT">false</valid>
<message toolname="Jhove" toolversion="1.20.1" status="SINGLE_RESULT">First box of JP2 header must be image header severity=error offset=48</message>
</filestatus>
<metadata>
<image>
<compressionScheme toolname="Exiftool" toolversion="11.14" status="SINGLE_RESULT">JPEG 2000</compressionScheme>
<imageWidth toolname="Exiftool" toolversion="11.14" status="SINGLE_RESULT">3039</imageWidth>
<imageHeight toolname="Exiftool" toolversion="11.14" status="SINGLE_RESULT">2490</imageHeight>
<iccProfileName toolname="Exiftool" toolversion="11.14" status="SINGLE_RESULT">Adobe RGB (1998)</iccProfileName>
<samplingFrequencyUnit toolname="Exiftool" toolversion="11.14" status="SINGLE_RESULT">cm</samplingFrequencyUnit>
<xSamplingFrequency toolname="Exiftool" toolversion="11.14" status="SINGLE_RESULT">3</xSamplingFrequency>
<ySamplingFrequency toolname="Exiftool" toolversion="11.14" status="SINGLE_RESULT">3</ySamplingFrequency>
<iccProfileVersion toolname="Exiftool" toolversion="11.14" status="SINGLE_RESULT">2.1.0</iccProfileVersion>
<standard>
<mix:mix xmlns:mix="http://www.loc.gov/mix/v20">
<mix:BasicDigitalObjectInformation>
<mix:Compression>
<mix:compressionScheme>JPEG 2000</mix:compressionScheme>
</mix:Compression>
</mix:BasicDigitalObjectInformation>
<mix:BasicImageInformation>
<mix:BasicImageCharacteristics>
<mix:imageWidth>3039</mix:imageWidth>
<mix:imageHeight>2490</mix:imageHeight>
<mix:PhotometricInterpretation>
<mix:ColorProfile>
<mix:IccProfile>
<mix:iccProfileName>Adobe RGB (1998)</mix:iccProfileName>
<mix:iccProfileVersion>2.1.0</mix:iccProfileVersion>
</mix:IccProfile>
</mix:ColorProfile>
</mix:PhotometricInterpretation>
</mix:BasicImageCharacteristics>
</mix:BasicImageInformation>
<mix:ImageCaptureMetadata>
<mix:GeneralCaptureInformation />
</mix:ImageCaptureMetadata>
<mix:ImageAssessmentMetadata>
<mix:SpatialMetrics>
<mix:samplingFrequencyUnit>cm</mix:samplingFrequencyUnit>
<mix:xSamplingFrequency>
<mix:numerator>3</mix:numerator>
<mix:denominator>1</mix:denominator>
</mix:xSamplingFrequency>
<mix:ySamplingFrequency>
<mix:numerator>3</mix:numerator>
<mix:denominator>1</mix:denominator>
</mix:ySamplingFrequency>
</mix:SpatialMetrics>
<mix:ImageColorEncoding />
</mix:ImageAssessmentMetadata>
</mix:mix>
</standard>
</image>
</metadata>
<statistics fitsExecutionTime="713">
<tool toolname="MediaInfo" toolversion="0.7.75" status="did not run" />
<tool toolname="OIS Audio Information" toolversion="0.1" status="did not run" />
<tool toolname="ADL Tool" toolversion="0.1" status="did not run" />
<tool toolname="VTT Tool" toolversion="0.1" status="did not run" />
<tool toolname="Droid" toolversion="6.4" executionTime="145" />
<tool toolname="Jhove" toolversion="1.20.1" executionTime="583" />
<tool toolname="file utility" toolversion="5.31" executionTime="643" />
<tool toolname="Exiftool" toolversion="11.14" executionTime="660" />
<tool toolname="NLNZ Metadata Extractor" toolversion="3.6GA" status="did not run" />
<tool toolname="OIS File Information" toolversion="0.2" executionTime="145" />
<tool toolname="OIS XML Metadata" toolversion="0.2" status="did not run" />
<tool toolname="ffident" toolversion="0.2" executionTime="497" />
<tool toolname="Tika" toolversion="1.19.1" executionTime="185" />
</statistics>
</fits>

Loading

0 comments on commit 350c86c

Please sign in to comment.