Skip to content

Commit

Permalink
Merge pull request #188 from daveneiman/dev
Browse files Browse the repository at this point in the history
Add m4a to file utility exclusion; update Tika.
  • Loading branch information
daveneiman authored Feb 5, 2019
2 parents be66a2e + 9dc8ad3 commit 5b7e573
Show file tree
Hide file tree
Showing 10 changed files with 237 additions and 7 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);
}

}
75 changes: 75 additions & 0 deletions testfiles/output/sample.m4a_XmlUnitExpectedOutput.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?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.1-SNAPSHOT" timestamp="2/5/19 11:05 AM">
<identification status="SINGLE_RESULT">
<identity format="MPEG-4 Audio" mimetype="audio/mp4" toolname="FITS" toolversion="1.4.1-SNAPSHOT">
<tool toolname="Exiftool" toolversion="11.14" />
</identity>
</identification>
<fileinfo>
<lastmodified toolname="Exiftool" toolversion="11.14" status="SINGLE_RESULT">0000:00:00 00:00:00</lastmodified>
<created toolname="Exiftool" toolversion="11.14" status="SINGLE_RESULT">0000:00:00 00:00:00</created>
<filepath toolname="OIS File Information" toolversion="0.2" status="SINGLE_RESULT">/Users/dan179/git/git-daveneiman/fits/testfiles/sample.m4a</filepath>
<filename toolname="OIS File Information" toolversion="0.2" status="SINGLE_RESULT">sample.m4a</filename>
<size toolname="OIS File Information" toolversion="0.2" status="SINGLE_RESULT">34535</size>
<md5checksum toolname="OIS File Information" toolversion="0.2" status="SINGLE_RESULT">ece7c8360447c620faf055b20279f483</md5checksum>
<fslastmodified toolname="OIS File Information" toolversion="0.2" status="SINGLE_RESULT">1549382585000</fslastmodified>
</fileinfo>
<filestatus />
<metadata>
<audio>
<duration toolname="Exiftool" toolversion="11.14" status="SINGLE_RESULT">3.41 s</duration>
<bitDepth toolname="Exiftool" toolversion="11.14" status="SINGLE_RESULT">16</bitDepth>
<sampleRate toolname="Exiftool" toolversion="11.14" status="SINGLE_RESULT">44100</sampleRate>
<channels toolname="Exiftool" toolversion="11.14" status="SINGLE_RESULT">2</channels>
<standard>
<aes:audioObject xmlns:aes="http://www.aes.org/audioObject" xsi:schemaLocation="http://www.aes.org/audioObject http://www.aes.org/standards/schemas/aes57-2011-08-27.xsd" disposition="" schemaVersion="1.0.0" analogDigitalFlag="FILE_DIGITAL" ID="AUDIO_OBJECT_38694746-aa2d-425a-a54e-265fd0489bc0">
<aes:format>MPEG-4 Audio</aes:format>
<aes:use useType="OTHER" otherType="unknown" />
<aes:primaryIdentifier identifierType="FILE_NAME">sample.m4a</aes:primaryIdentifier>
<aes:face audioObjectRef="AUDIO_OBJECT_38694746-aa2d-425a-a54e-265fd0489bc0" label="face 1" ID="FACE_0a4244fb-583d-46fa-a201-650d9bc1dfcc" direction="NONE">
<aes:timeline>
<aes:startTime editRate="1">0</aes:startTime>
<aes:duration editRate="1">0</aes:duration>
</aes:timeline>
<aes:region faceRef="FACE_0a4244fb-583d-46fa-a201-650d9bc1dfcc" formatRef="FORMAT_REGION_b946c7b7-f856-430d-9389-b9d7c8bfa31e" ID="REGION_b8d8bfc2-90c1-4632-9566-8d222339e902" label="region 1">
<aes:timeRange>
<aes:startTime editRate="1">0</aes:startTime>
<aes:duration editRate="1">0</aes:duration>
</aes:timeRange>
<aes:numChannels>2</aes:numChannels>
<aes:stream ID="STREAM_c4562d04-79ba-4f58-9251-406d8259f712" label="stream 0" faceRegionRef="REGION_b8d8bfc2-90c1-4632-9566-8d222339e902">
<aes:channelAssignment leftRightPosition="0.0" channelNum="0" frontRearPosition="0.0" />
</aes:stream>
<aes:stream ID="STREAM_1edaadb9-4966-4048-a72e-cce462d79d95" label="stream 1" faceRegionRef="REGION_b8d8bfc2-90c1-4632-9566-8d222339e902">
<aes:channelAssignment leftRightPosition="0.0" channelNum="1" frontRearPosition="0.0" />
</aes:stream>
</aes:region>
</aes:face>
<aes:formatList>
<aes:formatRegion ownerRef="REGION_b8d8bfc2-90c1-4632-9566-8d222339e902" xsi:type="aes:formatRegionType" ID="FORMAT_REGION_b946c7b7-f856-430d-9389-b9d7c8bfa31e" label="format region 1">
<aes:bitDepth>16</aes:bitDepth>
<aes:sampleRate>44100.0</aes:sampleRate>
<aes:soundField>STEREO</aes:soundField>
</aes:formatRegion>
</aes:formatList>
</aes:audioObject>
</standard>
</audio>
</metadata>
<statistics fitsExecutionTime="696">
<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" status="did not run" />
<tool toolname="Jhove" toolversion="1.20.1" executionTime="679" />
<tool toolname="file utility" toolversion="5.31" status="did not run" />
<tool toolname="Exiftool" toolversion="11.14" executionTime="680" />
<tool toolname="NLNZ Metadata Extractor" toolversion="3.6GA" status="did not run" />
<tool toolname="OIS File Information" toolversion="0.2" executionTime="189" />
<tool toolname="OIS XML Metadata" toolversion="0.2" status="did not run" />
<tool toolname="ffident" toolversion="0.2" executionTime="677" />
<tool toolname="Tika" toolversion="1.19.1" executionTime="268" />
</statistics>
</fits>

2 changes: 1 addition & 1 deletion testfiles/properties/fits-full-with-tool-output.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<tool class="edu.harvard.hul.ois.fits.tools.oisfileinfo.VTTTool" include-exts="vtt" />
<tool class="edu.harvard.hul.ois.fits.tools.droid.Droid" exclude-exts="odm,m4a" classpath-dirs="lib/droid" />
<tool class="edu.harvard.hul.ois.fits.tools.jhove.Jhove" exclude-exts="dng,mbx,mbox,arw,adl,eml,java,doc,docx,docm,odt,rtf,pages,wpd,wp,epub,csv,avi,mov,mpg,mpeg,mkv,mp3,mp4,mpeg4,m2ts,mxf,ogv,mj2,divx,dv,m4v,m2v,ismv,pcd,zip" classpath-dirs="lib/jhove" />
<tool class="edu.harvard.hul.ois.fits.tools.fileutility.FileUtility" exclude-exts="dng,wps,adl,jar,epub,csv" classpath-dirs="lib/fileutility" />
<tool class="edu.harvard.hul.ois.fits.tools.fileutility.FileUtility" exclude-exts="dng,wps,adl,jar,epub,csv,m4a" classpath-dirs="lib/fileutility" />
<tool class="edu.harvard.hul.ois.fits.tools.exiftool.Exiftool" exclude-exts="txt,wps,vsd,jar,avi,mov,mpg,mpeg,mkv,mp4,mxf,ogv,mj2,divx,dv,m4v,m2v,ismv,m2ts,mpeg4" classpath-dirs="lib/exiftool" />
<tool class="edu.harvard.hul.ois.fits.tools.nlnz.MetadataExtractor" include-exts="bmp,gif,jpg,jpeg,wp,wpd,odt,doc,pdf,mp3,bfw,flac,html,xml,arc" classpath-dirs="lib/nzmetool,xml/nlnz"/>
<tool class="edu.harvard.hul.ois.fits.tools.oisfileinfo.FileInfo" classpath-dirs="lib/fileinfo" />
Expand Down
2 changes: 1 addition & 1 deletion testfiles/properties/fits_no_md5_audio.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<tool class="edu.harvard.hul.ois.fits.tools.oisfileinfo.ADLTool" include-exts="adl" classpath-dirs="lib/adltool" />
<tool class="edu.harvard.hul.ois.fits.tools.droid.Droid" exclude-exts="odm,m4a" classpath-dirs="lib/droid" />
<tool class="edu.harvard.hul.ois.fits.tools.jhove.Jhove" exclude-exts="dng,mbx,mbox,arw,adl,eml,java,doc,docx,docm,odt,rtf,pages,wpd,wp,epub,csv,avi,mov,mpg,mpeg,mkv,mp3,mp4,mpeg4,m2ts,mxf,ogv,mj2,divx,dv,m4v,m2v,ismv,pcd,zip" classpath-dirs="lib/jhove" />
<tool class="edu.harvard.hul.ois.fits.tools.fileutility.FileUtility" exclude-exts="dng,wps,adl,jar" classpath-dirs="lib/fileutility" />
<tool class="edu.harvard.hul.ois.fits.tools.fileutility.FileUtility" exclude-exts="dng,wps,adl,jar,epub,csv,m4a" classpath-dirs="lib/fileutility" />
<tool class="edu.harvard.hul.ois.fits.tools.exiftool.Exiftool" exclude-exts="txt,wps,vsd,jar,avi,mov,mpg,mpeg,mkv,mp4,mxf,ogv,mj2,divx,dv,m4v,m2v,ismv" classpath-dirs="lib/exiftool" />
<tool class="edu.harvard.hul.ois.fits.tools.nlnz.MetadataExtractor" exclude-exts="dng,zip,odb,ott,odg,otg,odp,otp,ods,ots,odc,otc,odi,oti,odf,otf,odm,oth,tif,tiff,wav" classpath-dirs="lib/nzmetool,xml/nlnz"/>
<tool class="edu.harvard.hul.ois.fits.tools.oisfileinfo.FileInfo" classpath-dirs="lib/fileinfo" />
Expand Down
2 changes: 1 addition & 1 deletion testfiles/properties/fits_no_md5_video.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<tool class="edu.harvard.hul.ois.fits.tools.oisfileinfo.ADLTool" include-exts="adl" classpath-dirs="lib/adltool" />
<tool class="edu.harvard.hul.ois.fits.tools.droid.Droid" exclude-exts="odm,m4a" classpath-dirs="lib/droid" />
<tool class="edu.harvard.hul.ois.fits.tools.jhove.Jhove" exclude-exts="dng,mbx,mbox,arw,adl,eml,java,doc,docx,docm,odt,rtf,pages,wpd,wp,epub,csv,avi,mov,mpg,mpeg,mkv,mp3,mp4,mpeg4,m2ts,mxf,ogv,mj2,divx,dv,m4v,m2v,ismv,pcd,zip" classpath-dirs="lib/jhove" />
<tool class="edu.harvard.hul.ois.fits.tools.fileutility.FileUtility" exclude-exts="dng,wps,adl,jar" classpath-dirs="lib/fileutility" />
<tool class="edu.harvard.hul.ois.fits.tools.fileutility.FileUtility" exclude-exts="dng,wps,adl,jar,epub,csv,m4a" classpath-dirs="lib/fileutility" />
<tool class="edu.harvard.hul.ois.fits.tools.exiftool.Exiftool" exclude-exts="txt,wps,vsd,jar,avi,mov,mpg,mpeg,mkv,mp4,mxf,ogv,mj2,divx,dv,m4v,m2v,ismv" classpath-dirs="lib/exiftool" />
<tool class="edu.harvard.hul.ois.fits.tools.nlnz.MetadataExtractor" exclude-exts="dng,zip,odb,ott,odg,otg,odp,otp,ods,ots,odc,otc,odi,oti,odf,otf,odm,oth,tif,tiff,wav" classpath-dirs="lib/nzmetool,xml/nlnz"/>
<tool class="edu.harvard.hul.ois.fits.tools.oisfileinfo.FileInfo" classpath-dirs="lib/fileinfo" />
Expand Down
Binary file added testfiles/sample.m4a
Binary file not shown.
2 changes: 1 addition & 1 deletion xml/fits.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<tool class="edu.harvard.hul.ois.fits.tools.oisfileinfo.VTTTool" include-exts="vtt" />
<tool class="edu.harvard.hul.ois.fits.tools.droid.Droid" exclude-exts="odm,m4a" classpath-dirs="lib/droid" />
<tool class="edu.harvard.hul.ois.fits.tools.jhove.Jhove" exclude-exts="dng,mbx,mbox,arw,adl,eml,java,doc,docx,docm,odt,rtf,pages,wpd,wp,epub,csv,avi,mov,mpg,mpeg,mkv,mp3,mp4,mpeg4,m2ts,mxf,ogv,mj2,divx,dv,m4v,m2v,ismv,pcd,zip" classpath-dirs="lib/jhove" />
<tool class="edu.harvard.hul.ois.fits.tools.fileutility.FileUtility" exclude-exts="dng,wps,adl,jar,epub,csv" classpath-dirs="lib/fileutility" />
<tool class="edu.harvard.hul.ois.fits.tools.fileutility.FileUtility" exclude-exts="dng,wps,adl,jar,epub,csv,m4a" classpath-dirs="lib/fileutility" />
<tool class="edu.harvard.hul.ois.fits.tools.exiftool.Exiftool" exclude-exts="txt,wps,vsd,jar,avi,mov,mpg,mpeg,mkv,mp4,mxf,ogv,mj2,divx,dv,m4v,m2v,ismv,m2ts,mpeg4" classpath-dirs="lib/exiftool" />
<tool class="edu.harvard.hul.ois.fits.tools.nlnz.MetadataExtractor" include-exts="bmp,gif,jpg,jpeg,wp,wpd,odt,doc,pdf,mp3,bfw,flac,html,xml,arc" classpath-dirs="lib/nzmetool,xml/nlnz"/>
<tool class="edu.harvard.hul.ois.fits.tools.oisfileinfo.FileInfo" classpath-dirs="lib/fileinfo" />
Expand Down

0 comments on commit 5b7e573

Please sign in to comment.