Author: jukka
Date: Mon Nov 16 15:07:22 2009
New Revision: 880782

URL: http://svn.apache.org/viewvc?rev=880782&view=rev
Log:
TIKA-309: Mime type application/rdf+xml not correctly detected

Use local copies of the test documents to avoid test cases that depend on 
external network resources.

Added:
    
lucene/tika/trunk/tika-core/src/test/resources/org/apache/tika/mime/test-difficult-rdf1.xml
   (with props)
    
lucene/tika/trunk/tika-core/src/test/resources/org/apache/tika/mime/test-difficult-rdf2.xml
   (with props)
Modified:
    
lucene/tika/trunk/tika-core/src/test/java/org/apache/tika/mime/MimeDetectionTest.java

Modified: 
lucene/tika/trunk/tika-core/src/test/java/org/apache/tika/mime/MimeDetectionTest.java
URL: 
http://svn.apache.org/viewvc/lucene/tika/trunk/tika-core/src/test/java/org/apache/tika/mime/MimeDetectionTest.java?rev=880782&r1=880781&r2=880782&view=diff
==============================================================================
--- 
lucene/tika/trunk/tika-core/src/test/java/org/apache/tika/mime/MimeDetectionTest.java
 (original)
+++ 
lucene/tika/trunk/tika-core/src/test/java/org/apache/tika/mime/MimeDetectionTest.java
 Mon Nov 16 15:07:22 2009
@@ -18,7 +18,6 @@
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.URL;
 
 import junit.framework.TestCase;
 
@@ -48,8 +47,14 @@
         testFile("application/xml", "test-utf16be.xml");
         testFile("application/xml", "test-long-comment.xml");
         testFile("application/xslt+xml", "stylesheet.xsl");
-        testUrl("application/rdf+xml", new 
URL("http://www.ai.sri.com/daml/services/owl-s/1.2/Process.owl";));
-        testUrl("application/rdf+xml", new 
URL("http://www.w3.org/2002/07/owl#";));
+        testUrl(
+                "application/rdf+xml",
+                "http://www.ai.sri.com/daml/services/owl-s/1.2/Process.owl";,
+                "test-difficult-rdf1.xml");
+        testUrl(
+                "application/rdf+xml",
+                "http://www.w3.org/2002/07/owl#";,
+                "test-difficult-rdf2.xml");
     }
     
     public void testAutosetSupertype() throws MimeTypeException {
@@ -60,10 +65,10 @@
        type = types.forName("text/something");
        assertEquals("text/plain", type.getSuperType().getName());
     }
-    
-    private void testUrl(String expected, URL url) throws IOException{
-        InputStream in = url.openStream();
-        testStream(expected, url.toString(), in);        
+
+    private void testUrl(String expected, String url, String file) throws 
IOException{
+        InputStream in = getClass().getResourceAsStream(file);
+        testStream(expected, url, in);
     }
 
     private void testFile(String expected, String filename) throws IOException 
{

Added: 
lucene/tika/trunk/tika-core/src/test/resources/org/apache/tika/mime/test-difficult-rdf1.xml
URL: 
http://svn.apache.org/viewvc/lucene/tika/trunk/tika-core/src/test/resources/org/apache/tika/mime/test-difficult-rdf1.xml?rev=880782&view=auto
==============================================================================
--- 
lucene/tika/trunk/tika-core/src/test/resources/org/apache/tika/mime/test-difficult-rdf1.xml
 (added)
+++ 
lucene/tika/trunk/tika-core/src/test/resources/org/apache/tika/mime/test-difficult-rdf1.xml
 Mon Nov 16 15:07:22 2009
@@ -0,0 +1,41 @@
+<?xml version='1.0' encoding='ISO-8859-1'?>
+
+<!--
+  TIKA-309: Mime type application/rdf+xml not correctly detected
+  Simplified test case based on the OWL document at
+  http://www.ai.sri.com/daml/services/owl-s/1.2/Process.owl
+-->
+
+<!DOCTYPE uridef[
+  <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns";>
+  <!ENTITY shadow-rdf 
"http://www.daml.org/services/owl-s/1.2/generic/ObjectList.owl";>
+  <!ENTITY expr 
"http://www.daml.org/services/owl-s/1.2/generic/Expression.owl";>
+  <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema";>
+  <!ENTITY owl "http://www.w3.org/2002/07/owl";>
+  <!ENTITY xsd "http://www.w3.org/2001/XMLSchema";>
+  <!ENTITY time "http://www.isi.edu/~hobbs/damltime/time-entry.owl";>
+  <!ENTITY swrl "http://www.w3.org/2003/11/swrl";>
+  <!ENTITY service "http://www.daml.org/services/owl-s/1.2/Service.owl";>
+  <!ENTITY grounding "http://www.daml.org/services/owl-s/1.2/Grounding.owl";>
+  <!ENTITY process "http://www.daml.org/services/owl-s/1.2/Process.owl";>
+  <!ENTITY DEFAULT "http://www.daml.org/services/owl-s/1.2/Process.owl";>
+]>
+
+
+<rdf:RDF
+  xmlns:rdf=    "&rdf;#"
+  xmlns:shadow-rdf= "&shadow-rdf;#"
+  xmlns:expr= "&expr;#"
+  xmlns:rdfs=   "&rdfs;#"
+  xmlns:owl= "&owl;#"
+  xmlns:swrl= "&swrl;#"
+  xmlns:xsd= "&xsd;#"
+  xmlns:service= "&service;#"
+  xmlns:process= "&process;#"
+  xmlns:grounding= "&grounding;#"
+  xmlns=        "&DEFAULT;#"
+  xml:base="&process;">
+
+  <!-- ... -->
+
+</rdf:RDF>

Propchange: 
lucene/tika/trunk/tika-core/src/test/resources/org/apache/tika/mime/test-difficult-rdf1.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
lucene/tika/trunk/tika-core/src/test/resources/org/apache/tika/mime/test-difficult-rdf2.xml
URL: 
http://svn.apache.org/viewvc/lucene/tika/trunk/tika-core/src/test/resources/org/apache/tika/mime/test-difficult-rdf2.xml?rev=880782&view=auto
==============================================================================
--- 
lucene/tika/trunk/tika-core/src/test/resources/org/apache/tika/mime/test-difficult-rdf2.xml
 (added)
+++ 
lucene/tika/trunk/tika-core/src/test/resources/org/apache/tika/mime/test-difficult-rdf2.xml
 Mon Nov 16 15:07:22 2009
@@ -0,0 +1,47 @@
+<?xml version='1.0' encoding='ISO-8859-1'?>
+
+<!--
+  TIKA-309: Mime type application/rdf+xml not correctly detected
+  Simplified test case based on the OWL 2 Namespace Document at
+  http://www.w3.org/2002/07/owl#
+-->
+
+<!-- This is the OWL 2 Namespace Document, sometimes
+     called the "owl.owl" file.
+
+     For some commentary about its creation, see
+     http://www.w3.org/2007/OWL/wiki/Owl2DotOwlDevel
+
+     This was created from the 16 Oct 2009 version of
+     that page, with the turtle-to-rdf/xml conversion
+     done by cwm, and the conversion to XML entity
+     references done by hand. The GRDDL triple and
+     namespace have also been added by hand
+
+     The real OWL 1 and OWL 2 namespace is:
+          http://www.w3.org/2002/07/owl#
+
+-->
+<!DOCTYPE rdf:RDF [
+
+<!ENTITY location "http://www.w3.org/2002/07/owl"; >
+<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; >
+<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#"; >
+<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#"; >
+<!ENTITY dc "http://purl.org/dc/elements/1.1/"; >
+<!ENTITY grddl "http://www.w3.org/2003/g/data-view#"; >
+<!ENTITY owl "&location;#" >
+
+]>
+<rdf:RDF
+    xml:base ="&location;"
+    xmlns:rdf ="&rdf;"
+    xmlns:rdfs="&rdfs;"
+    xmlns:xsd = "&xsd;"
+    xmlns:owl ="&owl;"
+    xmlns:dc = "&dc;"
+    xmlns:grddl = "&grddl;"
+    >
+
+  <!-- ... -->
+</rdf:RDF>
\ No newline at end of file

Propchange: 
lucene/tika/trunk/tika-core/src/test/resources/org/apache/tika/mime/test-difficult-rdf2.xml
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to