Added: tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/image/ImageParserTest.java URL: http://svn.apache.org/viewvc/tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/image/ImageParserTest.java?rev=1722029&view=auto ============================================================================== --- tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/image/ImageParserTest.java (added) +++ tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/image/ImageParserTest.java Mon Dec 28 23:22:46 2015 @@ -0,0 +1,161 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tika.parser.image; + +import static org.junit.Assert.assertEquals; + +import java.io.InputStream; + +import org.apache.tika.metadata.Metadata; +import org.apache.tika.metadata.TikaCoreProperties; +import org.apache.tika.parser.ParseContext; +import org.apache.tika.parser.Parser; +import org.junit.Test; +import org.xml.sax.helpers.DefaultHandler; + +public class ImageParserTest { + + private final Parser parser = new ImageParser(); + + @Test + public void testBMP() throws Exception { + Metadata metadata = new Metadata(); + metadata.set(Metadata.CONTENT_TYPE, "image/bmp"); + InputStream stream = + getClass().getResourceAsStream("/test-documents/testBMP.bmp"); + parser.parse(stream, new DefaultHandler(), metadata, new ParseContext()); + + assertEquals("75", metadata.get("height")); + assertEquals("100", metadata.get("width")); + assertEquals("8 8 8", metadata.get("Data BitsPerSample")); + assertEquals("1.0", metadata.get("Dimension PixelAspectRatio")); + assertEquals("0", metadata.get("Dimension VerticalPhysicalPixelSpacing")); + assertEquals("0", metadata.get("Dimension HorizontalPhysicalPixelSpacing")); + assertEquals("BI_RGB", metadata.get("Compression CompressionTypeName")); + assertEquals("image/bmp", metadata.get("Content-Type")); + + assertEquals("100", metadata.get(Metadata.IMAGE_WIDTH)); + assertEquals("75", metadata.get(Metadata.IMAGE_LENGTH)); + assertEquals("8 8 8", metadata.get(Metadata.BITS_PER_SAMPLE)); + } + + @Test + public void testGIF() throws Exception { + Metadata metadata = new Metadata(); + metadata.set(Metadata.CONTENT_TYPE, "image/gif"); + InputStream stream = + getClass().getResourceAsStream("/test-documents/testGIF.gif"); + parser.parse(stream, new DefaultHandler(), metadata, new ParseContext()); + + assertEquals("75", metadata.get("height")); + assertEquals("100", metadata.get("width")); + assertEquals("true", metadata.get("Compression Lossless")); + assertEquals("Normal", metadata.get("Dimension ImageOrientation")); + assertEquals("lzw", metadata.get("Compression CompressionTypeName")); + assertEquals("0", metadata.get("Dimension HorizontalPixelOffset")); + assertEquals("imageLeftPosition=0, imageTopPosition=0, imageWidth=100, imageHeight=75, interlaceFlag=false", metadata.get("ImageDescriptor")); + assertEquals("Index", metadata.get("Data SampleFormat")); + assertEquals("3", metadata.get("Chroma NumChannels")); + assertEquals("1", metadata.get("Compression NumProgressiveScans")); + assertEquals("RGB", metadata.get("Chroma ColorSpaceType")); + assertEquals("Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership.", metadata.get("CommentExtensions CommentExtension")); + assertEquals("value=Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership., encoding=ISO-8859-1, compression=none", metadata.get("Text TextEntry")); + assertEquals("true", metadata.get("Chroma BlackIsZero")); + assertEquals("disposalMethod=none, userInputFlag=false, transparentColorFlag=false, delayTime=0, transparentColorIndex=0", metadata.get("GraphicControlExtension")); + assertEquals("0", metadata.get("Dimension VerticalPixelOffset")); + assertEquals("image/gif", metadata.get("Content-Type")); + + assertEquals("100", metadata.get(Metadata.IMAGE_WIDTH)); + assertEquals("75", metadata.get(Metadata.IMAGE_LENGTH)); + assertEquals("Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership.", metadata.get(TikaCoreProperties.COMMENTS)); + } + + @Test + public void testJPEG() throws Exception { + Metadata metadata = new Metadata(); + metadata.set(Metadata.CONTENT_TYPE, "image/jpeg"); + InputStream stream = + getClass().getResourceAsStream("/test-documents/testJPEG.jpg"); + parser.parse(stream, new DefaultHandler(), metadata, new ParseContext()); + + assertEquals("75", metadata.get("height")); + assertEquals("100", metadata.get("width")); + assertEquals("0.35277778", metadata.get("Dimension VerticalPixelSize")); + assertEquals("false", metadata.get("Compression Lossless")); + assertEquals("class=0, htableId=0", metadata.get("markerSequence dht dhtable")); + assertEquals("majorVersion=1, minorVersion=1, resUnits=1, Xdensity=72, Ydensity=72, thumbWidth=0, thumbHeight=0", metadata.get("JPEGvariety app0JFIF")); + assertEquals("225", metadata.get("markerSequence unknown")); + assertEquals("componentSelector=1, dcHuffTable=0, acHuffTable=0", metadata.get("markerSequence sos scanComponentSpec")); + assertEquals("normal", metadata.get("Dimension ImageOrientation")); + assertEquals("1.0", metadata.get("Dimension PixelAspectRatio")); + assertEquals("elementPrecision=0, qtableId=0", metadata.get("markerSequence dqt dqtable")); + assertEquals("numScanComponents=3, startSpectralSelection=0, endSpectralSelection=63, approxHigh=0, approxLow=0", metadata.get("markerSequence sos")); + assertEquals("componentId=1, HsamplingFactor=1, VsamplingFactor=1, QtableSelector=0", metadata.get("markerSequence sof componentSpec")); + assertEquals("JPEG", metadata.get("Compression CompressionTypeName")); + assertEquals("0.35277778", metadata.get("Dimension HorizontalPixelSize")); + assertEquals("Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership.", metadata.get("markerSequence com")); + assertEquals("3", metadata.get("Chroma NumChannels")); + assertEquals("1", metadata.get("Compression NumProgressiveScans")); + assertEquals("YCbCr", metadata.get("Chroma ColorSpaceType")); + assertEquals("keyword=comment, value=Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership.", metadata.get("Text TextEntry")); + assertEquals("image/jpeg", metadata.get("Content-Type")); + assertEquals("process=0, samplePrecision=8, numLines=75, samplesPerLine=100, numFrameComponents=3", metadata.get("markerSequence sof")); + + assertEquals("100", metadata.get(Metadata.IMAGE_WIDTH)); + assertEquals("75", metadata.get(Metadata.IMAGE_LENGTH)); + assertEquals("Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership.", metadata.get(TikaCoreProperties.COMMENTS)); + } + + @Test + public void testPNG() throws Exception { + Metadata metadata = new Metadata(); + metadata.set(Metadata.CONTENT_TYPE, "image/png"); + InputStream stream = + getClass().getResourceAsStream("/test-documents/testPNG.png"); + parser.parse(stream, new DefaultHandler(), metadata, new ParseContext()); + + assertEquals("75", metadata.get("height")); + assertEquals("100", metadata.get("width")); + assertEquals("0.35273367", metadata.get("Dimension VerticalPixelSize")); + assertEquals("8 8 8", metadata.get("Data BitsPerSample")); + assertEquals("Perceptual", metadata.get("sRGB")); + assertEquals("true", metadata.get("Compression Lossless")); + assertEquals("year=2008, month=5, day=6, hour=6, minute=18, second=47", metadata.get("tIME")); + assertEquals("Normal", metadata.get("Dimension ImageOrientation")); + assertEquals("1.0", metadata.get("Dimension PixelAspectRatio")); + assertEquals("keyword=Comment, value=Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership.", metadata.get("tEXt tEXtEntry")); + assertEquals("deflate", metadata.get("Compression CompressionTypeName")); + assertEquals("UnsignedIntegral", metadata.get("Data SampleFormat")); + assertEquals("0.35273367", metadata.get("Dimension HorizontalPixelSize")); + assertEquals("none", metadata.get("Transparency Alpha")); + assertEquals("pixelsPerUnitXAxis=2835, pixelsPerUnitYAxis=2835, unitSpecifier=meter", metadata.get("pHYs")); + assertEquals("3", metadata.get("Chroma NumChannels")); + assertEquals("1", metadata.get("Compression NumProgressiveScans")); + assertEquals("RGB", metadata.get("Chroma ColorSpaceType")); + assertEquals("keyword=Comment, value=Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership., encoding=ISO-8859-1, compression=none", metadata.get("Text TextEntry")); + assertEquals("PixelInterleaved", metadata.get("Data PlanarConfiguration")); + assertEquals("width=100, height=75, bitDepth=8, colorType=RGB, compressionMethod=deflate, filterMethod=adaptive, interlaceMethod=none", metadata.get("IHDR")); + assertEquals("true", metadata.get("Chroma BlackIsZero")); + assertEquals("year=2008, month=5, day=6, hour=6, minute=18, second=47", metadata.get("Document ImageModificationTime")); + assertEquals("image/png", metadata.get("Content-Type")); + + assertEquals("100", metadata.get(Metadata.IMAGE_WIDTH)); + assertEquals("75", metadata.get(Metadata.IMAGE_LENGTH)); + assertEquals("8 8 8", metadata.get(Metadata.BITS_PER_SAMPLE)); + } + +}
Added: tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/image/MetadataFieldsTest.java URL: http://svn.apache.org/viewvc/tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/image/MetadataFieldsTest.java?rev=1722029&view=auto ============================================================================== --- tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/image/MetadataFieldsTest.java (added) +++ tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/image/MetadataFieldsTest.java Mon Dec 28 23:22:46 2015 @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tika.parser.image; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.apache.tika.metadata.TIFF; +import org.apache.tika.metadata.TikaCoreProperties; +import org.junit.Test; + +public class MetadataFieldsTest { + + @Test + public void testIsMetadataField() { + assertFalse(MetadataFields.isMetadataField("random string that is not a field")); + assertFalse(MetadataFields.isMetadataField("xyz")); + assertTrue(MetadataFields.isMetadataField(TikaCoreProperties.KEYWORDS)); + assertTrue(MetadataFields.isMetadataField(TIFF.F_NUMBER.getName())); + } + +} Added: tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/image/PSDParserTest.java URL: http://svn.apache.org/viewvc/tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/image/PSDParserTest.java?rev=1722029&view=auto ============================================================================== --- tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/image/PSDParserTest.java (added) +++ tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/image/PSDParserTest.java Mon Dec 28 23:22:46 2015 @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tika.parser.image; + +import static org.junit.Assert.assertEquals; + +import java.io.InputStream; + +import org.apache.tika.metadata.Metadata; +import org.apache.tika.parser.ParseContext; +import org.apache.tika.parser.Parser; +import org.junit.Test; +import org.xml.sax.helpers.DefaultHandler; + +public class PSDParserTest { + + private final Parser parser = new PSDParser(); + + /** + * Tests a very basic file, without much metadata + */ + @Test + public void testPSD() throws Exception { + Metadata metadata = new Metadata(); + metadata.set(Metadata.CONTENT_TYPE, "image/x-psd"); + InputStream stream = + getClass().getResourceAsStream("/test-documents/testPSD.psd"); + parser.parse(stream, new DefaultHandler(), metadata, new ParseContext()); + + assertEquals("537", metadata.get(Metadata.IMAGE_WIDTH)); + assertEquals("51", metadata.get(Metadata.IMAGE_LENGTH)); + assertEquals("8", metadata.get(Metadata.BITS_PER_SAMPLE)); + } + + /** + * Tests a very basic file, without much metadata, + * where some of the data lengths are padded to be even + */ + @Test + public void testOddPSD() throws Exception { + Metadata metadata = new Metadata(); + metadata.set(Metadata.CONTENT_TYPE, "image/x-psd"); + InputStream stream = + getClass().getResourceAsStream("/test-documents/testPSD2.psd"); + parser.parse(stream, new DefaultHandler(), metadata, new ParseContext()); + assertEquals("69", metadata.get(Metadata.IMAGE_WIDTH)); + assertEquals("70", metadata.get(Metadata.IMAGE_LENGTH)); + assertEquals("8", metadata.get(Metadata.BITS_PER_SAMPLE)); + } +} Added: tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/image/TiffParserTest.java URL: http://svn.apache.org/viewvc/tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/image/TiffParserTest.java?rev=1722029&view=auto ============================================================================== --- tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/image/TiffParserTest.java (added) +++ tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/image/TiffParserTest.java Mon Dec 28 23:22:46 2015 @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tika.parser.image; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.InputStream; +import java.util.Arrays; +import java.util.List; + +import org.apache.tika.metadata.Metadata; +import org.apache.tika.metadata.TikaCoreProperties; +import org.apache.tika.parser.ParseContext; +import org.apache.tika.parser.Parser; +import org.junit.Test; +import org.xml.sax.helpers.DefaultHandler; + +public class TiffParserTest { + private final Parser parser = new TiffParser(); + + @Test + public void testTIFF() throws Exception { + Metadata metadata = new Metadata(); + metadata.set(Metadata.CONTENT_TYPE, "image/tiff"); + InputStream stream = + getClass().getResourceAsStream("/test-documents/testTIFF.tif"); + parser.parse(stream, new DefaultHandler(), metadata, new ParseContext()); + + assertEquals("Licensed to the Apache Software Foundation (ASF) under one or " + + "more contributor license agreements. See the NOTICE file " + + "distributed with this work for additional information regarding " + + "copyright ownership.", metadata.get(TikaCoreProperties.DESCRIPTION)); + + // All EXIF/TIFF tags + assertEquals("Inch", metadata.get(Metadata.RESOLUTION_UNIT)); + + // Core EXIF/TIFF tags + assertEquals("100", metadata.get(Metadata.IMAGE_WIDTH)); + assertEquals("75", metadata.get(Metadata.IMAGE_LENGTH)); + assertEquals("8", metadata.get(Metadata.BITS_PER_SAMPLE)); + assertEquals("3", metadata.get(Metadata.SAMPLES_PER_PIXEL)); + + // Embedded XMP + List<String> keywords = Arrays.asList(metadata.getValues(TikaCoreProperties.KEYWORDS)); + assertTrue("got " + keywords, keywords.contains("cat")); + assertTrue("got " + keywords, keywords.contains("garden")); + List<String> subject = Arrays.asList(metadata.getValues(Metadata.SUBJECT)); + assertTrue("got " + subject, subject.contains("cat")); + assertTrue("got " + subject, subject.contains("garden")); + } +} Added: tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/image/WebPParserTest.java URL: http://svn.apache.org/viewvc/tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/image/WebPParserTest.java?rev=1722029&view=auto ============================================================================== --- tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/image/WebPParserTest.java (added) +++ tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/image/WebPParserTest.java Mon Dec 28 23:22:46 2015 @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.tika.parser.image; + +import static org.junit.Assert.assertEquals; + +import java.io.InputStream; + +import org.apache.commons.io.IOUtils; +import org.apache.tika.metadata.Metadata; +import org.apache.tika.parser.AutoDetectParser; +import org.apache.tika.parser.ParseContext; +import org.apache.tika.parser.Parser; +import org.junit.Test; +import org.xml.sax.helpers.DefaultHandler; + + +public class WebPParserTest { + + Parser parser = new AutoDetectParser(); + + /* + Two photos in test-documents (testWebp_Alpha_Lossy.webp and testWebp_Alpha_Lossless.webp) + are in the public domain. These files were retrieved from: + https://github.com/drewnoakes/metadata-extractor-images/tree/master/webp + These photos are also available here: + https://developers.google.com/speed/webp/gallery2#webp_links + Credits for the photo: + "Free Stock Photo in High Resolution - Yellow Rose 3 - Flowers" + Image Author: Jon Sullivan + */ + @Test + public void testSimple() throws Exception { + Metadata metadata = new Metadata(); + InputStream stream = + getClass().getResourceAsStream("/test-documents/testWebp_Alpha_Lossy.webp"); + + parser.parse(stream, new DefaultHandler(), metadata, new ParseContext()); + + assertEquals("301", metadata.get("Image Height")); + assertEquals("400", metadata.get("Image Width")); + assertEquals("true", metadata.get("Has Alpha")); + assertEquals("false", metadata.get("Is Animation")); + assertEquals("image/webp", metadata.get(Metadata.CONTENT_TYPE)); + + IOUtils.closeQuietly(stream); + + metadata = new Metadata(); + stream = getClass().getResourceAsStream("/test-documents/testWebp_Alpha_Lossless.webp"); + parser.parse(stream, new DefaultHandler(), metadata, new ParseContext()); + + //unfortunately, there isn't much metadata in lossless + assertEquals("image/webp", metadata.get(Metadata.CONTENT_TYPE)); + + } + +} Added: tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/image/xmp/JempboxExtractorTest.java URL: http://svn.apache.org/viewvc/tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/image/xmp/JempboxExtractorTest.java?rev=1722029&view=auto ============================================================================== --- tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/image/xmp/JempboxExtractorTest.java (added) +++ tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/image/xmp/JempboxExtractorTest.java Mon Dec 28 23:22:46 2015 @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tika.parser.image.xmp; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Arrays; +import java.util.Collection; + +import org.apache.tika.exception.TikaException; +import org.apache.tika.metadata.Metadata; +import org.apache.tika.metadata.TikaCoreProperties; +import org.junit.Test; + +public class JempboxExtractorTest { + + @Test + public void testParseJpeg() throws IOException, TikaException { + Metadata metadata = new Metadata(); + InputStream stream = getClass().getResourceAsStream("/test-documents/testJPEG_commented.jpg"); + // set some values before extraction to see that they are overridden + metadata.set(TikaCoreProperties.TITLE, "old title"); + metadata.set(TikaCoreProperties.DESCRIPTION, "old description"); + metadata.set(TikaCoreProperties.CREATOR, "previous author"); + // ... or kept in case the field is multi-value + metadata.add(TikaCoreProperties.KEYWORDS, "oldkeyword"); + + JempboxExtractor extractor = new JempboxExtractor(metadata); + extractor.parse(stream); + + // DublinCore fields + assertEquals("Tosteberga \u00C4ngar", metadata.get(TikaCoreProperties.TITLE)); + assertEquals("Bird site in north eastern Sk\u00E5ne, Sweden.\n(new line)", metadata.get(TikaCoreProperties.DESCRIPTION)); + assertEquals("Some Tourist", metadata.get(TikaCoreProperties.CREATOR)); + Collection<String> keywords = Arrays.asList(metadata.getValues(TikaCoreProperties.KEYWORDS)); + assertTrue(keywords.contains("oldkeyword")); + assertTrue(keywords.contains("grazelands")); + assertTrue(keywords.contains("nature reserve")); + assertTrue(keywords.contains("bird watching")); + assertTrue(keywords.contains("coast")); + Collection<String> subject = Arrays.asList(metadata.getValues(Metadata.SUBJECT)); + assertTrue(subject.contains("oldkeyword")); + assertTrue(subject.contains("grazelands")); + assertTrue(subject.contains("nature reserve")); + assertTrue(subject.contains("bird watching")); + assertTrue(subject.contains("coast")); + } + + @Test + public void testParseJpegPhotoshop() throws IOException, TikaException { + Metadata metadata = new Metadata(); + InputStream stream = getClass().getResourceAsStream("/test-documents/testJPEG_commented_pspcs2mac.jpg"); + + JempboxExtractor extractor = new JempboxExtractor(metadata); + extractor.parse(stream); + + // DublinCore fields + assertEquals("Tosteberga \u00C4ngar", metadata.get(TikaCoreProperties.TITLE)); + assertEquals("Bird site in north eastern Sk\u00E5ne, Sweden.\n(new line)", metadata.get(TikaCoreProperties.DESCRIPTION)); + assertEquals("Some Tourist", metadata.get(TikaCoreProperties.CREATOR)); + Collection<String> keywords = Arrays.asList(metadata.getValues(TikaCoreProperties.KEYWORDS)); + assertTrue(keywords.contains("bird watching")); + assertTrue(keywords.contains("coast")); + } + + @Test + public void testParseJpegXnviewmp() throws IOException, TikaException { + Metadata metadata = new Metadata(); + InputStream stream = getClass().getResourceAsStream("/test-documents/testJPEG_commented_xnviewmp026.jpg"); + + JempboxExtractor extractor = new JempboxExtractor(metadata); + extractor.parse(stream); + + // XnViewMp fields not understood by Jempbox + assertEquals("Bird site in north eastern Sk\u00E5ne, Sweden.\n(new line)", metadata.get(TikaCoreProperties.DESCRIPTION)); + Collection<String> keywords = Arrays.asList(metadata.getValues(TikaCoreProperties.KEYWORDS)); + assertTrue(keywords.contains("coast")); + assertTrue(keywords.contains("nature reserve")); + } + + @Test + public void testJoinCreators() { + assertEquals("Mr B", new JempboxExtractor(null).joinCreators( + Arrays.asList("Mr B"))); + // TODO use multi-value property instead? + assertEquals("Mr B, Mr A", new JempboxExtractor(null).joinCreators( + Arrays.asList("Mr B", "Mr A"))); + } + +} Added: tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/jpeg/JpegParserTest.java URL: http://svn.apache.org/viewvc/tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/jpeg/JpegParserTest.java?rev=1722029&view=auto ============================================================================== --- tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/jpeg/JpegParserTest.java (added) +++ tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/jpeg/JpegParserTest.java Mon Dec 28 23:22:46 2015 @@ -0,0 +1,250 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tika.parser.jpeg; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.io.InputStream; +import java.util.Arrays; +import java.util.List; + +import org.apache.tika.metadata.Metadata; +import org.apache.tika.metadata.TIFF; +import org.apache.tika.metadata.TikaCoreProperties; +import org.apache.tika.parser.ParseContext; +import org.apache.tika.parser.Parser; +import org.junit.Test; +import org.xml.sax.helpers.DefaultHandler; + +public class JpegParserTest { + + private final Parser parser = new JpegParser(); + + @Test + public void testJPEG() throws Exception { + Metadata metadata = new Metadata(); + metadata.set(Metadata.CONTENT_TYPE, "image/jpeg"); + InputStream stream = + getClass().getResourceAsStream("/test-documents/testJPEG_EXIF.jpg"); + parser.parse(stream, new DefaultHandler(), metadata, new ParseContext()); + + // Core EXIF/TIFF tags + assertEquals("100", metadata.get(Metadata.IMAGE_WIDTH)); + assertEquals("68", metadata.get(Metadata.IMAGE_LENGTH)); + assertEquals("8", metadata.get(Metadata.BITS_PER_SAMPLE)); + assertEquals(null, metadata.get(Metadata.SAMPLES_PER_PIXEL)); + + assertEquals("6.25E-4", metadata.get(Metadata.EXPOSURE_TIME)); // 1/1600 + assertEquals("5.6", metadata.get(Metadata.F_NUMBER)); + assertEquals("false", metadata.get(Metadata.FLASH_FIRED)); + assertEquals("194.0", metadata.get(Metadata.FOCAL_LENGTH)); + assertEquals("400", metadata.get(Metadata.ISO_SPEED_RATINGS)); + assertEquals("Canon", metadata.get(Metadata.EQUIPMENT_MAKE)); + assertEquals("Canon EOS 40D", metadata.get(Metadata.EQUIPMENT_MODEL)); + assertEquals("Adobe Photoshop CS3 Macintosh", metadata.get(Metadata.SOFTWARE)); + assertEquals(null, metadata.get(Metadata.ORIENTATION)); // Not present + assertEquals("240.0", metadata.get(Metadata.RESOLUTION_HORIZONTAL)); + assertEquals("240.0", metadata.get(Metadata.RESOLUTION_VERTICAL)); + assertEquals("Inch", metadata.get(Metadata.RESOLUTION_UNIT)); + + // Check that EXIF/TIFF tags come through with their raw values too + // (This may be removed for Tika 1.0, as we support more of them + // with explicit Metadata entries) + assertEquals("Canon EOS 40D", metadata.get("Model")); + + // Common tags + //assertEquals("2009-10-02T23:02:49", metadata.get(Metadata.LAST_MODIFIED)); + assertEquals("Date/Time Original for when the photo was taken, unspecified time zone", + "2009-08-11T09:09:45", metadata.get(TikaCoreProperties.CREATED)); + List<String> keywords = Arrays.asList(metadata.getValues(TikaCoreProperties.KEYWORDS)); + assertTrue("'canon-55-250' expected in " + keywords, keywords.contains("canon-55-250")); + assertTrue("'moscow-birds' expected in " + keywords, keywords.contains("moscow-birds")); + assertTrue("'serbor' expected in " + keywords, keywords.contains("serbor")); + assertFalse(keywords.contains("canon-55-250 moscow-birds serbor")); + List<String> subject = Arrays.asList(metadata.getValues(Metadata.SUBJECT)); + assertTrue("'canon-55-250' expected in " + subject, subject.contains("canon-55-250")); + assertTrue("'moscow-birds' expected in " + subject, subject.contains("moscow-birds")); + assertTrue("'serbor' expected in " + subject, subject.contains("serbor")); + assertFalse(subject.contains("canon-55-250 moscow-birds serbor")); + } + + /** + * Test for a file with Geographic information (lat, long etc) in it + */ + @Test + public void testJPEGGeo() throws Exception { + Metadata metadata = new Metadata(); + metadata.set(Metadata.CONTENT_TYPE, "image/jpeg"); + InputStream stream = + getClass().getResourceAsStream("/test-documents/testJPEG_GEO.jpg"); + parser.parse(stream, new DefaultHandler(), metadata, new ParseContext()); + + // Geo tags + assertEquals("12.54321", metadata.get(Metadata.LATITUDE)); + assertEquals("-54.1234", metadata.get(Metadata.LONGITUDE)); + + // Core EXIF/TIFF tags + assertEquals("100", metadata.get(Metadata.IMAGE_WIDTH)); + assertEquals("68", metadata.get(Metadata.IMAGE_LENGTH)); + assertEquals("8", metadata.get(Metadata.BITS_PER_SAMPLE)); + assertEquals(null, metadata.get(Metadata.SAMPLES_PER_PIXEL)); + + assertEquals("6.25E-4", metadata.get(Metadata.EXPOSURE_TIME)); // 1/1600 + assertEquals("5.6", metadata.get(Metadata.F_NUMBER)); + assertEquals("false", metadata.get(Metadata.FLASH_FIRED)); + assertEquals("194.0", metadata.get(Metadata.FOCAL_LENGTH)); + assertEquals("400", metadata.get(Metadata.ISO_SPEED_RATINGS)); + assertEquals("Canon", metadata.get(Metadata.EQUIPMENT_MAKE)); + assertEquals("Canon EOS 40D", metadata.get(Metadata.EQUIPMENT_MODEL)); + assertEquals("Adobe Photoshop CS3 Macintosh", metadata.get(Metadata.SOFTWARE)); + assertEquals(null, metadata.get(Metadata.ORIENTATION)); // Not present + assertEquals("240.0", metadata.get(Metadata.RESOLUTION_HORIZONTAL)); + assertEquals("240.0", metadata.get(Metadata.RESOLUTION_VERTICAL)); + assertEquals("Inch", metadata.get(Metadata.RESOLUTION_UNIT)); + + // Common tags + assertEquals("Date/Time Original for when the photo was taken, unspecified time zone", + "2009-08-11T09:09:45", metadata.get(TikaCoreProperties.CREATED)); + assertEquals("This image has different Date/Time than Date/Time Original, so it is probably modification date", + "2009-10-02T23:02:49", metadata.get(Metadata.LAST_MODIFIED)); + assertEquals("Date/Time Original should be stored in EXIF field too", + "2009-08-11T09:09:45", metadata.get(TIFF.ORIGINAL_DATE)); + assertEquals("canon-55-250", metadata.getValues(TikaCoreProperties.KEYWORDS)[0]); + assertEquals("canon-55-250", metadata.getValues(Metadata.KEYWORDS)[0]); + } + + /** + * Test for an image with the geographic information stored in a slightly + * different way, see TIKA-915 for details + * Disabled for now, pending a fix to the underlying library + */ + @Test + public void testJPEGGeo2() throws Exception { + Metadata metadata = new Metadata(); + metadata.set(Metadata.CONTENT_TYPE, "image/jpeg"); + InputStream stream = + getClass().getResourceAsStream("/test-documents/testJPEG_GEO_2.jpg"); + parser.parse(stream, new DefaultHandler(), metadata, new ParseContext()); + + // Geo tags should be there with 5dp, and not rounded + assertEquals("51.575762", metadata.get(Metadata.LATITUDE)); + assertEquals("-1.567886", metadata.get(Metadata.LONGITUDE)); + } + + @Test + public void testJPEGTitleAndDescription() throws Exception { + Metadata metadata = new Metadata(); + metadata.set(Metadata.CONTENT_TYPE, "image/jpeg"); + InputStream stream = + getClass().getResourceAsStream("/test-documents/testJPEG_commented.jpg"); + parser.parse(stream, new DefaultHandler(), metadata, new ParseContext()); + + // embedded comments with non-ascii characters + assertEquals("Tosteberga \u00C4ngar", metadata.get(TikaCoreProperties.TITLE)); + assertEquals("Bird site in north eastern Sk\u00E5ne, Sweden.\n(new line)", metadata.get(TikaCoreProperties.DESCRIPTION)); + assertEquals("Some Tourist", metadata.get(TikaCoreProperties.CREATOR)); // Dublin Core + // xmp handles spaces in keywords, returns "bird watching, nature reserve, coast, grazelands" + // but we have to replace them with underscore + + List<String> keywords = Arrays.asList(metadata.getValues(Metadata.KEYWORDS)); + assertTrue(keywords.contains("coast")); + assertTrue(keywords.contains("bird watching")); + assertEquals(keywords, Arrays.asList(metadata.getValues(TikaCoreProperties.KEYWORDS))); + + // Core EXIF/TIFF tags + assertEquals("103", metadata.get(Metadata.IMAGE_WIDTH)); + assertEquals("77", metadata.get(Metadata.IMAGE_LENGTH)); + assertEquals("8", metadata.get(Metadata.BITS_PER_SAMPLE)); + assertEquals(null, metadata.get(Metadata.SAMPLES_PER_PIXEL)); + + assertEquals("1.0E-6", metadata.get(Metadata.EXPOSURE_TIME)); // 1/1000000 + assertEquals("2.8", metadata.get(Metadata.F_NUMBER)); + assertEquals("4.6", metadata.get(Metadata.FOCAL_LENGTH)); + assertEquals("114", metadata.get(Metadata.ISO_SPEED_RATINGS)); + assertEquals(null, metadata.get(Metadata.EQUIPMENT_MAKE)); + assertEquals(null, metadata.get(Metadata.EQUIPMENT_MODEL)); + assertEquals(null, metadata.get(Metadata.SOFTWARE)); + assertEquals("1", metadata.get(Metadata.ORIENTATION)); // Not present + assertEquals("300.0", metadata.get(Metadata.RESOLUTION_HORIZONTAL)); + assertEquals("300.0", metadata.get(Metadata.RESOLUTION_VERTICAL)); + assertEquals("Inch", metadata.get(Metadata.RESOLUTION_UNIT)); + } + + @Test + public void testJPEGTitleAndDescriptionPhotoshop() throws Exception { + Metadata metadata = new Metadata(); + metadata.set(Metadata.CONTENT_TYPE, "image/jpeg"); + InputStream stream = + getClass().getResourceAsStream("/test-documents/testJPEG_commented_pspcs2mac.jpg"); + parser.parse(stream, new DefaultHandler(), metadata, new ParseContext()); + + // embedded comments with non-ascii characters + assertEquals("Tosteberga \u00C4ngar", metadata.get(TikaCoreProperties.TITLE)); + assertEquals("Bird site in north eastern Sk\u00E5ne, Sweden.\n(new line)", metadata.get(TikaCoreProperties.DESCRIPTION)); + assertEquals("Some Tourist", metadata.get(TikaCoreProperties.CREATOR)); + List<String> keywords = Arrays.asList(metadata.getValues(TikaCoreProperties.KEYWORDS)); + assertTrue("got " + keywords, keywords.contains("bird watching")); + List<String> subject = Arrays.asList(metadata.getValues(Metadata.SUBJECT)); + assertTrue("got " + subject, subject.contains("bird watching")); + } + + @Test + public void testJPEGTitleAndDescriptionXnviewmp() throws Exception { + Metadata metadata = new Metadata(); + metadata.set(Metadata.CONTENT_TYPE, "image/jpeg"); + InputStream stream = + getClass().getResourceAsStream("/test-documents/testJPEG_commented_xnviewmp026.jpg"); + parser.parse(stream, new DefaultHandler(), metadata, new ParseContext()); + + // XnViewMp's default comment dialog has only comment, not headline. + // Comment is embedded only if "Write comments in XMP" is enabled in settings + assertEquals("Bird site in north eastern Sk\u00E5ne, Sweden.\n(new line)", metadata.get(TikaCoreProperties.DESCRIPTION)); + // xmp handles spaces in keywords, returns "bird watching, nature reserve, coast, grazelands" + // but we have to replace them with underscore + String[] subject = metadata.getValues(TikaCoreProperties.KEYWORDS); + List<String> keywords = Arrays.asList(subject); + assertTrue("'coast'" + " not in " + keywords, keywords.contains("coast")); + assertTrue("'nature reserve'" + " not in " + keywords, keywords.contains("nature reserve")); + } + + @Test + public void testJPEGoddTagComponent() throws Exception { + Metadata metadata = new Metadata(); + metadata.set(Metadata.CONTENT_TYPE, "image/jpeg"); + InputStream stream = + getClass().getResourceAsStream("/test-documents/testJPEG_oddTagComponent.jpg"); + parser.parse(stream, new DefaultHandler(), metadata, new ParseContext()); + + assertEquals(null, metadata.get(TikaCoreProperties.TITLE)); + assertEquals(null, metadata.get(TikaCoreProperties.DESCRIPTION)); + assertEquals("251", metadata.get(Metadata.IMAGE_WIDTH)); + assertEquals("384", metadata.get(Metadata.IMAGE_LENGTH)); + } + + @Test + public void testJPEGEmptyEXIFDateTime() throws Exception { + Metadata metadata = new Metadata(); + metadata.set(Metadata.CONTENT_TYPE, "image/jpeg"); + InputStream stream = + getClass().getResourceAsStream("/test-documents/testJPEG_EXIF_emptyDateTime.jpg"); + parser.parse(stream, new DefaultHandler(), metadata, new ParseContext()); + assertEquals("300.0", metadata.get(TIFF.RESOLUTION_HORIZONTAL)); + assertEquals("300.0", metadata.get(TIFF.RESOLUTION_VERTICAL)); + } +} Added: tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/mp3/Mp3ParserTest.java URL: http://svn.apache.org/viewvc/tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/mp3/Mp3ParserTest.java?rev=1722029&view=auto ============================================================================== --- tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/mp3/Mp3ParserTest.java (added) +++ tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/mp3/Mp3ParserTest.java Mon Dec 28 23:22:46 2015 @@ -0,0 +1,414 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tika.parser.mp3; + +import static org.apache.tika.TikaTest.assertContains; +import static org.junit.Assert.assertEquals; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; + +import org.apache.tika.metadata.Metadata; +import org.apache.tika.metadata.TikaCoreProperties; +import org.apache.tika.metadata.XMPDM; +import org.apache.tika.parser.AutoDetectParser; +import org.apache.tika.parser.ParseContext; +import org.apache.tika.parser.Parser; +import org.apache.tika.sax.BodyContentHandler; +import org.junit.Test; +import org.xml.sax.ContentHandler; + +/** + * Test case for parsing mp3 files. + */ +public class Mp3ParserTest { + + /** + * Checks the duration of an MP3 file. + * @param metadata the metadata object + * @param expected the expected duration, rounded as seconds + */ + private static void checkDuration(Metadata metadata, int expected) { + assertEquals("Wrong duration", expected, + Math.round(Float.valueOf(metadata.get(XMPDM.DURATION)) / 1000)); + } + + /** + * Test that with only ID3v1 tags, we get some information out + */ + @Test + public void testMp3ParsingID3v1() throws Exception { + Parser parser = new AutoDetectParser(); // Should auto-detect! + ContentHandler handler = new BodyContentHandler(); + Metadata metadata = new Metadata(); + + try (InputStream stream = Mp3ParserTest.class.getResourceAsStream( + "/test-documents/testMP3id3v1.mp3")) { + parser.parse(stream, handler, metadata, new ParseContext()); + } + + assertEquals("audio/mpeg", metadata.get(Metadata.CONTENT_TYPE)); + assertEquals("Test Title", metadata.get(TikaCoreProperties.TITLE)); + assertEquals("Test Artist", metadata.get(TikaCoreProperties.CREATOR)); + assertEquals("Test Artist", metadata.get(Metadata.AUTHOR)); + + String content = handler.toString(); + assertContains("Test Title", content); + assertContains("Test Artist", content); + assertContains("Test Album", content); + assertContains("2008", content); + assertContains("Test Comment", content); + assertContains("Rock", content); + + assertEquals("MPEG 3 Layer III Version 1", metadata.get("version")); + assertEquals("44100", metadata.get("samplerate")); + assertEquals("1", metadata.get("channels")); + checkDuration(metadata, 2); + } + + /** + * Test that with only ID3v2 tags, we get the full + * set of information out. + */ + @Test + public void testMp3ParsingID3v2() throws Exception { + Parser parser = new AutoDetectParser(); // Should auto-detect! + ContentHandler handler = new BodyContentHandler(); + Metadata metadata = new Metadata(); + + try (InputStream stream = Mp3ParserTest.class.getResourceAsStream( + "/test-documents/testMP3id3v2.mp3")) { + parser.parse(stream, handler, metadata, new ParseContext()); + } + + // Check core properties + assertEquals("audio/mpeg", metadata.get(Metadata.CONTENT_TYPE)); + assertEquals("Test Title", metadata.get(TikaCoreProperties.TITLE)); + assertEquals("Test Artist", metadata.get(TikaCoreProperties.CREATOR)); + assertEquals("Test Artist", metadata.get(Metadata.AUTHOR)); + + // Check the textual contents + String content = handler.toString(); + assertContains("Test Title", content); + assertContains("Test Artist", content); + assertContains("Test Album", content); + assertContains("2008", content); + assertContains("Test Comment", content); + assertContains("Rock", content); + assertContains(", track 1", content); + assertContains(", disc 1", content); + + // Check un-typed audio properties + assertEquals("MPEG 3 Layer III Version 1", metadata.get("version")); + assertEquals("44100", metadata.get("samplerate")); + assertEquals("1", metadata.get("channels")); + + // Check XMPDM-typed audio properties + assertEquals("Test Album", metadata.get(XMPDM.ALBUM)); + assertEquals("Test Artist", metadata.get(XMPDM.ARTIST)); + assertEquals("Test Album Artist", metadata.get(XMPDM.ALBUM_ARTIST)); + assertEquals(null, metadata.get(XMPDM.COMPOSER)); + assertEquals("2008", metadata.get(XMPDM.RELEASE_DATE)); + assertEquals("Rock", metadata.get(XMPDM.GENRE)); + assertEquals("XXX - ID3v1 Comment\nTest Comment", metadata.get(XMPDM.LOG_COMMENT.getName())); + assertEquals("1", metadata.get(XMPDM.TRACK_NUMBER)); + assertEquals("1/1", metadata.get(XMPDM.DISC_NUMBER)); + assertEquals("1", metadata.get(XMPDM.COMPILATION)); + + assertEquals("44100", metadata.get(XMPDM.AUDIO_SAMPLE_RATE)); + assertEquals("Mono", metadata.get(XMPDM.AUDIO_CHANNEL_TYPE)); + assertEquals("MP3", metadata.get(XMPDM.AUDIO_COMPRESSOR)); + checkDuration(metadata, 2); + } + + /** + * Test that with both id3v2 and id3v1, we prefer the + * details from id3v2 + */ + @Test + public void testMp3ParsingID3v1v2() throws Exception { + Parser parser = new AutoDetectParser(); // Should auto-detect! + ContentHandler handler = new BodyContentHandler(); + Metadata metadata = new Metadata(); + + try (InputStream stream = Mp3ParserTest.class.getResourceAsStream( + "/test-documents/testMP3id3v1_v2.mp3")) { + parser.parse(stream, handler, metadata, new ParseContext()); + } + + assertEquals("audio/mpeg", metadata.get(Metadata.CONTENT_TYPE)); + assertEquals("Test Title", metadata.get(TikaCoreProperties.TITLE)); + assertEquals("Test Artist", metadata.get(TikaCoreProperties.CREATOR)); + assertEquals("Test Artist", metadata.get(Metadata.AUTHOR)); + + String content = handler.toString(); + assertContains("Test Title", content); + assertContains("Test Artist", content); + assertContains("Test Album", content); + assertContains("2008", content); + assertContains("Test Comment", content); + assertContains("Rock", content); + + assertEquals("MPEG 3 Layer III Version 1", metadata.get("version")); + assertEquals("44100", metadata.get("samplerate")); + assertEquals("1", metadata.get("channels")); + checkDuration(metadata, 2); + } + + /** + * Test that with only ID3v2 tags, of version 2.4, we get the full + * set of information out. + */ + @Test + public void testMp3ParsingID3v24() throws Exception { + Parser parser = new AutoDetectParser(); // Should auto-detect! + ContentHandler handler = new BodyContentHandler(); + Metadata metadata = new Metadata(); + + try (InputStream stream = Mp3ParserTest.class.getResourceAsStream( + "/test-documents/testMP3id3v24.mp3")) { + parser.parse(stream, handler, metadata, new ParseContext()); + } + + assertEquals("audio/mpeg", metadata.get(Metadata.CONTENT_TYPE)); + assertEquals("Test Title", metadata.get(TikaCoreProperties.TITLE)); + assertEquals("Test Artist", metadata.get(TikaCoreProperties.CREATOR)); + assertEquals("Test Artist", metadata.get(Metadata.AUTHOR)); + + String content = handler.toString(); + assertContains("Test Title", content); + assertContains("Test Artist", content); + assertContains("Test Album", content); + assertContains("2008", content); + assertContains("Test Comment", content); + assertContains("Rock", content); + assertContains(", disc 1", content); + + assertEquals("MPEG 3 Layer III Version 1", metadata.get("version")); + assertEquals("44100", metadata.get("samplerate")); + assertEquals("1", metadata.get("channels")); + checkDuration(metadata, 2); + + // Check XMPDM-typed audio properties + assertEquals("Test Album", metadata.get(XMPDM.ALBUM)); + assertEquals("Test Artist", metadata.get(XMPDM.ARTIST)); + assertEquals("Test Album Artist", metadata.get(XMPDM.ALBUM_ARTIST)); + assertEquals(null, metadata.get(XMPDM.COMPOSER)); + assertEquals("2008", metadata.get(XMPDM.RELEASE_DATE)); + assertEquals("Rock", metadata.get(XMPDM.GENRE)); + assertEquals("1", metadata.get(XMPDM.COMPILATION)); + + assertEquals(null, metadata.get(XMPDM.TRACK_NUMBER)); + assertEquals("1", metadata.get(XMPDM.DISC_NUMBER)); + } + + /** + * Tests that a file with characters not in the ISO 8859-1 + * range is correctly handled + */ + @Test + public void testMp3ParsingID3i18n() throws Exception { + Parser parser = new AutoDetectParser(); // Should auto-detect! + ContentHandler handler = new BodyContentHandler(); + Metadata metadata = new Metadata(); + + try (InputStream stream = Mp3ParserTest.class.getResourceAsStream( + "/test-documents/testMP3i18n.mp3")) { + parser.parse(stream, handler, metadata, new ParseContext()); + } + + assertEquals("audio/mpeg", metadata.get(Metadata.CONTENT_TYPE)); + assertEquals("Une chason en Fran\u00e7ais", metadata.get(TikaCoreProperties.TITLE)); + assertEquals("Test Artist \u2468\u2460", metadata.get(TikaCoreProperties.CREATOR)); + assertEquals("Test Artist \u2468\u2460", metadata.get(Metadata.AUTHOR)); + assertEquals("Test Artist \u2468\u2460", metadata.get(XMPDM.ARTIST)); + assertEquals("Test Album \u2460\u2468", metadata.get(XMPDM.ALBUM)); + + assertEquals( + "Eng - Comment Desc\nThis is a \u1357\u2468\u2460 Comment", + metadata.get(XMPDM.LOG_COMMENT) + ); + + assertEquals("MPEG 3 Layer III Version 1", metadata.get("version")); + assertEquals("44100", metadata.get("samplerate")); + assertEquals("1", metadata.get("channels")); + checkDuration(metadata, 2); + } + + + /** + * Tests that a file with both lyrics and + * ID3v2 tags gets both extracted correctly + */ + @Test + public void testMp3ParsingLyrics() throws Exception { + Parser parser = new AutoDetectParser(); // Should auto-detect! + ContentHandler handler = new BodyContentHandler(); + Metadata metadata = new Metadata(); + + // Note - our test file has a lyrics tag, but lacks any + // lyrics in the tags, so we can't test that bit + // TODO Find a better sample file + + try (InputStream stream = Mp3ParserTest.class.getResourceAsStream( + "/test-documents/testMP3lyrics.mp3")) { + parser.parse(stream, handler, metadata, new ParseContext()); + } + + assertEquals("audio/mpeg", metadata.get(Metadata.CONTENT_TYPE)); + assertEquals("Test Title", metadata.get(TikaCoreProperties.TITLE)); + assertEquals("Test Artist", metadata.get(TikaCoreProperties.CREATOR)); + assertEquals("Test Artist", metadata.get(Metadata.AUTHOR)); + + String content = handler.toString(); + assertContains("Test Title", content); + assertContains("Test Artist", content); + assertContains("Test Album", content); + assertContains("2008", content); + assertContains("Test Comment", content); + assertContains("Rock", content); + + assertEquals("MPEG 3 Layer III Version 1", metadata.get("version")); + assertEquals("44100", metadata.get("samplerate")); + assertEquals("2", metadata.get("channels")); + checkDuration(metadata, 1); + } + + @Test + public void testID3v2Frame() throws Exception { + byte[] empty = new byte[] { + 0x49, 0x44, 0x33, 3, 1, 0, + 0, 0, 0, 0 + }; + + assertEquals(11, ID3v2Frame.getInt(new byte[] {0,0,0,0x0b})); + assertEquals(257, ID3v2Frame.getInt(new byte[] {0,0,1,1})); + + ID3v2Frame f = (ID3v2Frame) + ID3v2Frame.createFrameIfPresent(new ByteArrayInputStream(empty)); + assertEquals(3, f.getMajorVersion()); + assertEquals(1, f.getMinorVersion()); + assertEquals(0, f.getFlags()); + assertEquals(0, f.getLength()); + assertEquals(0, f.getData().length); + + assertEquals("", ID3v2Frame.getTagString(f.getData(), 0, 0)); + assertEquals("", ID3v2Frame.getTagString(new byte[] {0,0,0,0}, 0, 3)); + assertEquals("A", ID3v2Frame.getTagString(new byte[] {(byte)'A',0,0,0}, 0, 3)); + } + + @Test + public void testTIKA1589_noId3ReturnsDurationCorrectly() throws Exception { + Parser parser = new AutoDetectParser(); // Should auto-detect! + ContentHandler handler = new BodyContentHandler(); + Metadata metadata = new Metadata(); + + try (InputStream stream = Mp3ParserTest.class.getResourceAsStream( + "/test-documents/testMP3noid3.mp3")) { + parser.parse(stream, handler, metadata, new ParseContext()); + } + + assertEquals("2455.510986328125", metadata.get(XMPDM.DURATION)); + } + + /** + * This test will do nothing, unless you've downloaded the + * mp3 file from TIKA-424 - the file cannot be + * distributed with Tika. + * This test will check for the complicated set of ID3v2.4 + * tags. + */ + @Test + public void testTIKA424() throws Exception { + Parser parser = new AutoDetectParser(); // Should auto-detect! + ContentHandler handler = new BodyContentHandler(); + Metadata metadata = new Metadata(); + + try (InputStream stream = Mp3ParserTest.class.getResourceAsStream( + "/test-documents/test2.mp3")) { + if (stream == null) { + // You haven't downloaded the file + // Skip the test + return; + } + parser.parse(stream, handler, metadata, new ParseContext()); + } + + assertEquals("audio/mpeg", metadata.get(Metadata.CONTENT_TYPE)); + assertEquals("Plus loin vers l'ouest", metadata.get(TikaCoreProperties.TITLE)); + assertEquals("Merzhin", metadata.get(TikaCoreProperties.CREATOR)); + assertEquals("Merzhin", metadata.get(Metadata.AUTHOR)); + + String content = handler.toString(); + assertContains("Plus loin vers l'ouest", content); + + assertEquals("MPEG 3 Layer III Version 1", metadata.get("version")); + assertEquals("44100", metadata.get("samplerate")); + assertEquals("2", metadata.get("channels")); + } + + /** + * This tests that we can handle without errors (but perhaps not + * all content) a file with a very very large ID3 frame that + * has been truncated before the end of the ID3 tags. + * In this case, it is a file with JPEG data in the ID3, which + * is trunacted before the end of the JPEG bit of the ID3 frame. + */ + @Test + public void testTIKA474() throws Exception { + Parser parser = new AutoDetectParser(); // Should auto-detect! + ContentHandler handler = new BodyContentHandler(); + Metadata metadata = new Metadata(); + + try (InputStream stream = Mp3ParserTest.class.getResourceAsStream( + "/test-documents/testMP3truncated.mp3")) { + parser.parse(stream, handler, metadata, new ParseContext()); + } + + // Check we could get the headers from the start + assertEquals("audio/mpeg", metadata.get(Metadata.CONTENT_TYPE)); + assertEquals("Girl you have no faith in medicine", metadata.get(TikaCoreProperties.TITLE)); + assertEquals("The White Stripes", metadata.get(TikaCoreProperties.CREATOR)); + assertEquals("The White Stripes", metadata.get(Metadata.AUTHOR)); + + String content = handler.toString(); + assertContains("Girl you have no faith in medicine", content); + assertContains("The White Stripes", content); + assertContains("Elephant", content); + assertContains("2003", content); + + // File lacks any audio frames, so we can't know these + assertEquals(null, metadata.get("version")); + assertEquals(null, metadata.get("samplerate")); + assertEquals(null, metadata.get("channels")); + } + + // TIKA-1024 + @Test + public void testNakedUTF16BOM() throws Exception { + Parser parser = new AutoDetectParser(); // Should auto-detect! + ContentHandler handler = new BodyContentHandler(); + Metadata metadata = new Metadata(); + + try (InputStream stream = Mp3ParserTest.class.getResourceAsStream( + "/test-documents/testNakedUTF16BOM.mp3")) { + parser.parse(stream, handler, metadata, new ParseContext()); + } + assertEquals("audio/mpeg", metadata.get(Metadata.CONTENT_TYPE)); + assertEquals("", metadata.get(XMPDM.GENRE)); + } +} Added: tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/mp3/MpegStreamTest.java URL: http://svn.apache.org/viewvc/tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/mp3/MpegStreamTest.java?rev=1722029&view=auto ============================================================================== --- tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/mp3/MpegStreamTest.java (added) +++ tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/mp3/MpegStreamTest.java Mon Dec 28 23:22:46 2015 @@ -0,0 +1,166 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tika.parser.mp3; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +import org.junit.After; +import org.junit.Test; + +/** + * Test class for {@code MpegStream}. + */ +public class MpegStreamTest +{ + /** The stream to be tested. */ + private MpegStream stream; + + @After + public void tearDown() throws Exception + { + if (stream != null) + { + stream.close(); + } + } + + /** + * Tests whether the default test header can be found in a stream. + * + * @param bos the stream + * @throws IOException if an error occurs + */ + private void checkDefaultHeader(ByteArrayOutputStream bos) + throws IOException + { + ByteArrayInputStream in = new ByteArrayInputStream(bos.toByteArray()); + stream = new MpegStream(in); + AudioFrame header = stream.nextFrame(); + assertNotNull("No header found", header); + assertEquals("Wrong MPEG version", AudioFrame.MPEG_V2, + header.getVersionCode()); + assertEquals("Wrong layer", AudioFrame.LAYER_3, header.getLayer()); + assertEquals("Wrong bit rate", 80000, header.getBitRate()); + assertEquals("Wrong sample rate", 24000, header.getSampleRate()); + } + + /** + * Writes the given byte the given number of times into an output stream. + * + * @param out the output stream + * @param value the value to write + * @param count the number of bytes to write + * @throws IOException if an error occurs + */ + private static void writeBytes(OutputStream out, int value, int count) + throws IOException + { + for (int i = 0; i < count; i++) + { + out.write(value); + } + } + + /** + * Writes a frame header in the given output stream. + * + * @param out the output stream + * @param b2 byte 2 of the header + * @param b3 byte 3 of the header + * @param b4 byte 4 of the header + * @throws IOException if an error occurs + */ + private static void writeFrame(OutputStream out, int b2, int b3, int b4) + throws IOException + { + out.write(0xFF); + out.write(b2); + out.write(b3); + out.write(b4); + } + + /** + * Tests whether an audio frame header can be found somewhere in a stream. + */ + @Test + public void testSearchNextFrame() throws IOException + { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + writeBytes(bos, 0xFF, 32); + writeBytes(bos, 0, 16); + writeBytes(bos, 0xFF, 8); + bos.write(0xF3); + bos.write(0x96); + bos.write(0); + checkDefaultHeader(bos); + } + + /** + * Tests whether invalid frame headers are detected and skipped. + */ + @Test + public void testSearchNextFrameInvalid() throws IOException + { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + writeFrame(bos, 0xEB, 0x96, 0); + writeFrame(bos, 0xF9, 0x96, 0); + writeFrame(bos, 0xF3, 0, 0); + writeFrame(bos, 0xF3, 0xF0, 0); + writeFrame(bos, 0xF3, 0x7C, 0); + writeFrame(bos, 0xF3, 0x96, 0); + checkDefaultHeader(bos); + } + + /** + * Tests a search for another frame which is interrupted because the stream + * ends. + */ + @Test + public void testSeachNextFrameEOS() throws IOException + { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + bos.write(0xFF); + bos.write(0xFF); + bos.write(0xF3); + bos.write(0x96); + ByteArrayInputStream in = new ByteArrayInputStream(bos.toByteArray()); + stream = new MpegStream(in); + assertNull("Got a frame", stream.nextFrame()); + } + + /** + * Tries to skip a frame if no current header is available. + */ + @Test + public void testSkipNoCurrentHeader() throws IOException + { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + bos.write("This is a test".getBytes(UTF_8)); + ByteArrayInputStream in = new ByteArrayInputStream(bos.toByteArray()); + stream = new MpegStream(in); + assertFalse("Wrong result", stream.skipFrame()); + } +} Added: tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/mp4/MP4ParserTest.java URL: http://svn.apache.org/viewvc/tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/mp4/MP4ParserTest.java?rev=1722029&view=auto ============================================================================== --- tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/mp4/MP4ParserTest.java (added) +++ tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/mp4/MP4ParserTest.java Mon Dec 28 23:22:46 2015 @@ -0,0 +1,108 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tika.parser.mp4; + +import static org.apache.tika.TikaTest.assertContains; +import static org.junit.Assert.assertEquals; + +import java.io.InputStream; + +import org.apache.tika.io.TikaInputStream; +import org.apache.tika.metadata.Metadata; +import org.apache.tika.metadata.TikaCoreProperties; +import org.apache.tika.metadata.XMP; +import org.apache.tika.metadata.XMPDM; +import org.apache.tika.parser.AutoDetectParser; +import org.apache.tika.parser.ParseContext; +import org.apache.tika.parser.Parser; +import org.apache.tika.sax.BodyContentHandler; +import org.junit.Test; +import org.xml.sax.ContentHandler; + +/** + * Test case for parsing mp4 files. + */ +public class MP4ParserTest { + /** + * Test that we can extract information from + * a M4A MP4 Audio file + */ + @Test + public void testMP4ParsingAudio() throws Exception { + Parser parser = new AutoDetectParser(); // Should auto-detect! + ContentHandler handler = new BodyContentHandler(); + Metadata metadata = new Metadata(); + + try (InputStream stream = MP4ParserTest.class.getResourceAsStream( + "/test-documents/testMP4.m4a")) { + parser.parse(stream, handler, metadata, new ParseContext()); + } + + // Check core properties + assertEquals("audio/mp4", metadata.get(Metadata.CONTENT_TYPE)); + assertEquals("Test Title", metadata.get(TikaCoreProperties.TITLE)); + assertEquals("Test Artist", metadata.get(TikaCoreProperties.CREATOR)); + assertEquals("Test Artist", metadata.get(Metadata.AUTHOR)); + assertEquals("2012-01-28T18:39:18Z", metadata.get(TikaCoreProperties.CREATED)); + assertEquals("2012-01-28T18:39:18Z", metadata.get(Metadata.CREATION_DATE)); + assertEquals("2012-01-28T18:40:25Z", metadata.get(TikaCoreProperties.MODIFIED)); + assertEquals("2012-01-28T18:40:25Z", metadata.get(Metadata.DATE)); + + // Check the textual contents + String content = handler.toString(); + assertContains("Test Title", content); + assertContains("Test Artist", content); + assertContains("Test Album", content); + assertContains("2008", content); + assertContains("Test Comment", content); + assertContains("Test Genre", content); + + // Check XMPDM-typed audio properties + assertEquals("Test Album", metadata.get(XMPDM.ALBUM)); + assertEquals("Test Artist", metadata.get(XMPDM.ARTIST)); + assertEquals("Test Composer", metadata.get(XMPDM.COMPOSER)); + assertEquals("2008", metadata.get(XMPDM.RELEASE_DATE)); + assertEquals("Test Genre", metadata.get(XMPDM.GENRE)); + assertEquals("Test Comments", metadata.get(XMPDM.LOG_COMMENT.getName())); + assertEquals("1", metadata.get(XMPDM.TRACK_NUMBER)); + assertEquals("Test Album Artist", metadata.get(XMPDM.ALBUM_ARTIST)); + assertEquals("6", metadata.get(XMPDM.DISC_NUMBER)); + assertEquals("0", metadata.get(XMPDM.COMPILATION)); + + + assertEquals("44100", metadata.get(XMPDM.AUDIO_SAMPLE_RATE)); + assertEquals("Stereo", metadata.get(XMPDM.AUDIO_CHANNEL_TYPE)); + assertEquals("M4A", metadata.get(XMPDM.AUDIO_COMPRESSOR)); + assertEquals("0.07", metadata.get(XMPDM.DURATION)); + + assertEquals("iTunes 10.5.3.3", metadata.get(XMP.CREATOR_TOOL)); + + + // Check again by file, rather than stream + TikaInputStream tstream = TikaInputStream.get( + MP4ParserTest.class.getResourceAsStream("/test-documents/testMP4.m4a")); + tstream.getFile(); + try { + parser.parse(tstream, handler, metadata, new ParseContext()); + } finally { + tstream.close(); + } + } + + // TODO Test a MP4 Video file + // TODO Test an old QuickTime Video File +} Added: tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/video/FLVParserTest.java URL: http://svn.apache.org/viewvc/tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/video/FLVParserTest.java?rev=1722029&view=auto ============================================================================== --- tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/video/FLVParserTest.java (added) +++ tika/branches/2.x/tika-parser-modules/tika-multimedia-module/src/test/java/org/apache/tika/parser/video/FLVParserTest.java Mon Dec 28 23:22:46 2015 @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tika.parser.video; + +import static org.junit.Assert.assertEquals; + +import org.apache.tika.Tika; +import org.apache.tika.metadata.Metadata; +import org.junit.Test; + +public class FLVParserTest { + + @Test + public void testFLV() throws Exception { + String path = "/test-documents/testFLV.flv"; + Metadata metadata = new Metadata(); + + String content = new Tika().parseToString( + FLVParserTest.class.getResourceAsStream(path), metadata); + + assertEquals("", content); + assertEquals("video/x-flv", metadata.get(Metadata.CONTENT_TYPE)); + assertEquals("true", metadata.get("hasVideo")); + assertEquals("false", metadata.get("stereo")); + assertEquals("true", metadata.get("hasAudio")); + assertEquals("120.0", metadata.get("height")); + assertEquals("16.0", metadata.get("audiosamplesize")); + } + +}
