/*
 * 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
 *
 *     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.gagravarr.tika;

import java.io.IOException;
import java.io.InputStream;

import junit.framework.TestCase;

import org.apache.tika.io.TikaInputStream;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.metadata.XMPDM;
import org.apache.tika.parser.ParseContext;
import org.apache.tika.sax.BodyContentHandler;
import org.xml.sax.ContentHandler;

public class TestVorbisParser extends TestCase {
	private InputStream getTestFile() throws IOException {
		return this.getClass().getResourceAsStream("/testVORBIS.ogg");
	}
	
	public void testParser() throws Exception {
	   VorbisParser parser = new VorbisParser();
	   
      ContentHandler handler = new BodyContentHandler();
      ParseContext context = new ParseContext();
	   Metadata metadata = new Metadata();
	   
	   parser.parse(
	         TikaInputStream.get(getTestFile()), handler,
	         metadata, context
	   );
	   
	   // Check metadata
	   assertEquals("Test Artist", metadata.get(Metadata.AUTHOR));
      assertEquals("Test Title", metadata.get(Metadata.TITLE));
      
      assertEquals("Test Album", metadata.get(XMPDM.ALBUM));
      assertEquals("Test Artist", metadata.get(XMPDM.ARTIST));
      assertEquals("Stereo", metadata.get(XMPDM.AUDIO_CHANNEL_TYPE));
      assertEquals("44100", metadata.get(XMPDM.AUDIO_SAMPLE_RATE));
      assertEquals("Test Genre", metadata.get(XMPDM.GENRE));
      assertEquals("Test Comment", metadata.get(XMPDM.LOG_COMMENT));
      assertEquals("2010-01-26", metadata.get(XMPDM.RELEASE_DATE));
      assertEquals("1", metadata.get(XMPDM.TRACK_NUMBER));
      
      assertEquals("Xiph.Org libVorbis I 20070622", metadata.get("vendor"));
      assertEquals("Vorbis 0", metadata.get("version"));
      
      // Check text
      String content = handler.toString();
      assertTrue(content.contains("Test Title"));
      assertTrue(content.contains("Test Artist"));
      assertTrue(content.contains("Test Album"));
      assertTrue(content.contains("2010"));
      assertTrue(content.contains("Test Comment"));
      assertTrue(content.contains("Test Genre"));
	}
}

@@ -760,16 +760,108 @@
 tadata;%0A
+import org.apache.tika.metadata.Office;%0Aimport org.apache.tika.metadata.TikaCoreProperties;%0A
 import o
@@ -891,16 +891,16 @@
 .XMPDM;%0A
-
 import o
@@ -1193,17 +1193,20 @@
 );%0A%09%7D%0A%09%0A
-%09
+    
 public v
@@ -1569,16 +1569,29 @@
 / Check 
+legacy style 
 metadata
@@ -1651,24 +1651,24 @@
 a.AUTHOR));%0A
-
       assert
@@ -1718,32 +1718,288 @@
 TITLE));%0A      %0A
+      // Check new-style metadata%0A      assertEquals(%22Test Artist%22, metadata.get(Office.AUTHOR));%0A      assertEquals(%22Test Artist%22, metadata.get(TikaCoreProperties.CREATOR));%0A      assertEquals(%22Test Title%22, metadata.get(TikaCoreProperties.TITLE));%0A      %0A
       assertEqua

Update the Vorbis Tika test to explicitly check both old and new style metadata keys