tika-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1225454 - in /tika/trunk/tika-parsers/src: main/java/org/apache/tika/parser/mp3/ID3v2Frame.java test/java/org/apache/tika/parser/mp3/Mp3ParserTest.java
Date Thu, 29 Dec 2011 07:17:07 GMT
Author: nick
Date: Thu Dec 29 07:17:07 2011
New Revision: 1225454

URL: http://svn.apache.org/viewvc?rev=1225454&view=rev
Log:
TIKA-793 Unit test for i18n MP3 tags (excluding comments)

Modified:
    tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/mp3/ID3v2Frame.java
    tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/mp3/Mp3ParserTest.java

Modified: tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/mp3/ID3v2Frame.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/mp3/ID3v2Frame.java?rev=1225454&r1=1225453&r2=1225454&view=diff
==============================================================================
--- tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/mp3/ID3v2Frame.java (original)
+++ tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/mp3/ID3v2Frame.java Thu Dec
29 07:17:07 2011
@@ -192,7 +192,7 @@ public class ID3v2Frame implements MP3Fr
         // Does it have an encoding flag?
         // Detect by the first byte being sub 0x20
         boolean doubleByte = false;
-        String encoding = "ISO-8859-1";
+        String encoding = "ISO8859_1";
         byte maybeEncodingFlag = data[offset];
         if (maybeEncodingFlag == 0 || maybeEncodingFlag == 1 ||
               maybeEncodingFlag == 2 || maybeEncodingFlag == 3) {

Modified: tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/mp3/Mp3ParserTest.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/mp3/Mp3ParserTest.java?rev=1225454&r1=1225453&r2=1225454&view=diff
==============================================================================
--- tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/mp3/Mp3ParserTest.java (original)
+++ tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/mp3/Mp3ParserTest.java Thu
Dec 29 07:17:07 2011
@@ -186,6 +186,38 @@ public class Mp3ParserTest extends TestC
     }
     
     /**
+     * Tests that a file with characters not in the ISO 8859-1
+     *  range is correctly handled
+     */
+    public void testMp3ParsingID3i18n() throws Exception {
+       Parser parser = new AutoDetectParser(); // Should auto-detect!
+       ContentHandler handler = new BodyContentHandler();
+       Metadata metadata = new Metadata();
+
+       InputStream stream = Mp3ParserTest.class.getResourceAsStream(
+               "/test-documents/testMP3i18n.mp3");
+       try {
+           parser.parse(stream, handler, metadata, new ParseContext());
+       } finally {
+           stream.close();
+       }
+
+       assertEquals("audio/mpeg", metadata.get(Metadata.CONTENT_TYPE));
+       assertEquals("Une chason en Fran\u00e7ais", metadata.get(Metadata.TITLE));
+       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));
+
+       // TODO Fix comments
+//       assertEquals("Comment Desc - This is a comment", metadata.get(XMPDM.LOG_COMMENT));
+       
+       assertEquals("MPEG 3 Layer III Version 1", metadata.get("version"));
+       assertEquals("44100", metadata.get("samplerate"));
+       assertEquals("2", metadata.get("channels"));
+   }
+    
+    
+    /**
      * Tests that a file with both lyrics and
      *  ID3v2 tags gets both extracted correctly
      */



Mime
View raw message