* 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
InputStream stream = Mp3ParserTest.class.getResourceAsStream(
"/test-documents/testMP3lyrics.mp3");
try {
parser.parse(stream, handler, metadata, new ParseContext());
} finally {
stream.close();
}
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();
assertTrue(content.contains("Test Title"));
assertTrue(content.contains("Test Artist"));
assertTrue(content.contains("Test Album"));
assertTrue(content.contains("2008"));
assertTrue(content.contains("Test Comment"));