You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2012/11/18 12:08:01 UTC

svn commit: r1410869 - in /jena/trunk/jena-arq/src/test/java/org/apache/jena/riot: ./ adapters/ langsuite/ stream/

Author: andy
Date: Sun Nov 18 11:07:59 2012
New Revision: 1410869

URL: http://svn.apache.org/viewvc?rev=1410869&view=rev
Log:
Test code for RIOT reader

Added:
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TC_Riot.java
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TS_LangSuite.java
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TS_ReaderRIOT.java
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TestJenaReaderRIOT.java
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TestLangRIOT.java
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TestReadDataset.java
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/adapters/
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/adapters/TS_RIOTAdapters.java
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/adapters/TestFileManager.java
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/FactoryTestRiot.java
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/LangTestCase.java
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/UnitTestBadEval.java
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/UnitTestBadSyntax.java
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/UnitTestEval.java
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/UnitTestSurpressed.java
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/UnitTestSyntax.java
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/VocabLangRDF.java
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/stream/
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/stream/TS_IO2.java
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/stream/TestLocationMapper.java
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/stream/TestLocators.java
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/stream/TestStreamManager.java

Added: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TC_Riot.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TC_Riot.java?rev=1410869&view=auto
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TC_Riot.java (added)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TC_Riot.java Sun Nov 18 11:07:59 2012
@@ -0,0 +1,37 @@
+/*
+ * 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.jena.riot;
+
+import org.apache.jena.riot.adapters.TS_RIOTAdapters ;
+import org.apache.jena.riot.stream.TS_IO2 ;
+import org.junit.runner.RunWith ;
+import org.junit.runners.Suite ;
+import org.openjena.riot.TS_Riot ;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses( {
+      TS_Riot.class
+      , TS_LangSuite.class
+      , TS_ReaderRIOT.class
+      , TS_IO2.class
+      , TS_RIOTAdapters.class
+})
+
+public class TC_Riot
+{}

Added: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TS_LangSuite.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TS_LangSuite.java?rev=1410869&view=auto
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TS_LangSuite.java (added)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TS_LangSuite.java Sun Nov 18 11:07:59 2012
@@ -0,0 +1,39 @@
+/**
+ * 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.jena.riot;
+
+import junit.framework.TestSuite ;
+import org.apache.jena.riot.langsuite.FactoryTestRiot ;
+import org.junit.runner.RunWith ;
+import org.junit.runners.AllTests ;
+
+/** The test suites - these are driven by a manifest file and use external files for tests */
+
+@RunWith(AllTests.class)
+public class TS_LangSuite extends TestSuite
+{
+    private static final String manifest1 = "testing/RIOT/Lang/manifest-all.ttl" ;
+
+    static public TestSuite suite()
+    {
+        TestSuite ts = new TestSuite("RIOT Lang") ;
+        ts.addTest(FactoryTestRiot.make(manifest1, null, null)) ;
+        return ts ;
+    }
+}

Added: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TS_ReaderRIOT.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TS_ReaderRIOT.java?rev=1410869&view=auto
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TS_ReaderRIOT.java (added)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TS_ReaderRIOT.java Sun Nov 18 11:07:59 2012
@@ -0,0 +1,39 @@
+/**
+ * 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.jena.riot;
+
+import org.apache.jena.riot.stream.TestStreamManager ;
+import org.junit.runner.RunWith ;
+import org.junit.runners.Suite ;
+import org.junit.runners.Suite.SuiteClasses ;
+
+@RunWith(Suite.class)
+@SuiteClasses(
+{ 
+    TestLangRIOT.class
+    , TestStreamManager.class 
+    , TestJenaReaderRIOT.class
+    , TestReadDataset.class
+})
+
+public class TS_ReaderRIOT
+{
+
+}
+

Added: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TestJenaReaderRIOT.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TestJenaReaderRIOT.java?rev=1410869&view=auto
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TestJenaReaderRIOT.java (added)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TestJenaReaderRIOT.java Sun Nov 18 11:07:59 2012
@@ -0,0 +1,221 @@
+/**
+ * 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.jena.riot;
+
+import java.io.FileInputStream ;
+import java.io.IOException ;
+import java.io.StringReader ;
+
+import org.apache.jena.riot.Langs ;
+import org.apache.jena.riot.RDFReaderFactoryRIOT ;
+import org.apache.jena.riot.TypedInputStream2 ;
+import org.apache.jena.riot.WebReader2 ;
+import org.junit.AfterClass ;
+import org.junit.BeforeClass ;
+import org.junit.Test ;
+import org.openjena.atlas.junit.BaseTest ;
+import org.openjena.atlas.lib.StrUtils ;
+
+import com.hp.hpl.jena.rdf.model.Model ;
+import com.hp.hpl.jena.rdf.model.ModelFactory ;
+import com.hp.hpl.jena.rdf.model.Resource ;
+import com.hp.hpl.jena.sparql.util.Context ;
+import com.hp.hpl.jena.util.FileUtils ;
+
+public class TestJenaReaderRIOT extends BaseTest
+{
+    private static final String directory = "testing/RIOT/Reader" ;
+
+    private static Context context = new Context() ;
+    
+    @BeforeClass static public void beforeClass()
+    { 
+        WebReader2.wireIntoJena() ;
+    }
+    
+    @AfterClass static public void afterClass()
+    { 
+        // Unwire?
+    }
+
+    @Test public void read_01() { jenaread("D.nt") ; }
+    @Test public void read_02() { jenaread("D.ttl") ; }
+    @Test public void read_03() { jenaread("D.rdf") ; }
+    @Test public void read_04() { jenaread("D.rdf") ; }
+    @Test public void read_05() { jenaread("D.json") ; }
+
+    @Test public void read_11() { jenaread("D.nt", "N-TRIPLES") ; }
+    @Test public void read_12() { jenaread("D.ttl", "TTL") ; }
+    @Test public void read_13() { jenaread("D.rdf", "RDF/XML") ; }
+    @Test public void read_14() { jenaread("D.rdf", "RDF/XML-ABBREV") ; }
+    @Test public void read_15() { jenaread("D.json", "RDF/JSON") ; }
+
+    @Test public void read_21a() { jenaread("D-nt",  "N-TRIPLES") ; }
+    @Test public void read_21b() { jenaread("D-nt",  "NTRIPLES") ; }
+    @Test public void read_21c() { jenaread("D-nt",  "NT") ; }
+
+    @Test public void read_22a() { jenaread("D-ttl", "TURTLE") ; }
+    @Test public void read_22b() { jenaread("D-ttl", "TTL") ; }
+    
+    @Test public void read_23a()  { jenaread("D-rdf", "RDF/XML") ; }
+    @Test public void read_23b()  { jenaread("D-rdf", "RDFXML") ; }
+    @Test public void read_24()   { jenaread("D-json", "RDF/JSON") ; }
+    
+    @Test public void read_30()
+    {
+        {
+            TypedInputStream2 in = WebReader2.open(filename("D-not-TTL.ttl") );
+            Model m0 = ModelFactory.createDefaultModel() ;
+            WebReader2.read(m0, in.getInput(), Langs.langRDFXML) ;
+        }
+
+        TypedInputStream2 in1 = WebReader2.open(filename("D-not-TTL.ttl") );
+        Model m1 = ModelFactory.createDefaultModel() ;
+        // Fails until integration with jena-core as hintlang gets lost.
+        m1.read(in1.getInput(), null, "RDF/XML") ;
+    }
+    
+    // test read from StringReader..
+    @Test public void read_31()
+    {
+        String x = "<s> <p> <p> ." ;
+        
+        {
+            StringReader s = new StringReader(x) ;
+            Model m = ModelFactory.createDefaultModel() ;
+            WebReader2.read(m, s, null, Langs.langNTriples) ;
+        }
+        
+        StringReader s1 = new StringReader("<s> <p> <p> .") ;
+        Model m1 = ModelFactory.createDefaultModel() ;
+        m1.read(s1, null, "N-TRIPLES") ;
+    }
+    
+    @Test public void read_32()
+    {
+        String x = StrUtils.strjoinNL(
+            "<rdf:RDF", 
+            "   xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"",
+            "   xmlns:j.0=\"http://example/\">" ,
+            "  <rdf:Description rdf:about=\"http://example/s\">" ,
+            "     <j.0:p rdf:resource=\"http://example/o\"/>" ,
+            "   </rdf:Description>" ,
+            "</rdf:RDF>") ;
+        {
+            StringReader s = new StringReader(x) ;
+            Model m = ModelFactory.createDefaultModel() ;
+            WebReader2.read(m, s, null, Langs.langRDFXML) ;
+        }
+        StringReader s1 = new StringReader(x) ;
+        Model m = ModelFactory.createDefaultModel() ;
+        m.read(s1, null, "RDF/XML") ;
+    }
+
+    // Stream opening is hardwired into jena!
+    @Test public void read_base_1() { jenaread("D-no-base.ttl", "http://baseuri/", "TTL") ; }
+    
+    @Test public void read_input_1() throws IOException
+    { jenaread_stream("D.ttl", "TTL") ; }
+        
+    @Test public void read_input_2() throws IOException
+    { jenaread_stream("D.rdf", "RDF/XML") ; }
+    
+    private static String filename(String filename) { return directory+"/"+filename ; }
+    
+    private static void jenaread_stream(String filename, String lang) throws IOException
+    {
+        filename = filename(filename) ;
+        
+        // Read with a base
+        FileInputStream in0 = new FileInputStream(filename) ;
+        Model m0 = ModelFactory.createDefaultModel() ;
+        WebReader2.read(m0, in0, "http://example/base2", Langs.nameToLang(lang)) ;
+        in0.close() ;
+
+        // Read again, but without base
+        FileInputStream in1 = new FileInputStream(filename) ;
+        Model m1 = ModelFactory.createDefaultModel() ;
+        WebReader2.read(m1, in1, Langs.nameToLang(lang)) ;
+        in1.close() ;
+        
+        // Fail because Jena core does a look up of lang with ModelCom builtin in RDFReaderF, then calls RIOReader().
+        // 1/ Fix Jena - remove RDFReaderF
+        // 2/ Change RDFReaderF to pass in the language name. 
+        
+        // Read via Jena API.
+        Model m2 = ModelFactory.createDefaultModel() ;
+        FileInputStream in2 = new FileInputStream(filename) ;
+        m2.read(in2, "http://example/base3", lang) ;
+        in2.close() ;
+        
+        String x = FileUtils.readWholeFileAsUTF8(filename) ;
+        Model m3 = ModelFactory.createDefaultModel() ;
+        m2.read(new StringReader(x), "http://example/base4", lang) ;
+    }
+
+    // Web.
+    // TriG
+    // NQ
+    
+    private static void jenaread(String dataurl)
+    {
+        dataurl = filename(dataurl) ; 
+        Model m = ModelFactory.createDefaultModel() ;
+        m.read(dataurl) ;
+        assertTrue(m.size() != 0 ) ;
+    }
+    
+    // Wire in.
+    // +1 one with a base.
+    private static void jenaread(String dataurl, String lang)
+    {
+        // read via WebReader to make sure the test setup is right.
+        dataurl = filename(dataurl) ;
+        
+        Model m0 = ModelFactory.createDefaultModel() ;
+        WebReader2.read(m0, dataurl, Langs.nameToLang(lang)) ;
+        assertTrue(m0.size() != 0 ) ;
+        
+        Model m1 = ModelFactory.createDefaultModel() ;
+        new RDFReaderFactoryRIOT().getReader(lang).read(m1, dataurl) ;
+        assertTrue(m1.size() != 0 ) ;
+        
+//        // Read via Jena model API.
+//        Model m2 = ModelFactory.createDefaultModel() ;
+//        m2.read(dataurl, lang) ;
+//        assertTrue(m2.size() != 0 ) ;
+    }
+
+    private static void jenaread(String dataurl, String lang, String base)
+    {
+        dataurl = filename(dataurl) ;
+        Model m = ModelFactory.createDefaultModel() ;
+        
+        // This 
+        WebReader2.read(m, dataurl, base, Langs.nameToLang(lang)) ;
+        // should be implementation of:
+        m.read("file:"+dataurl, lang, base) ;
+        assertTrue(m.size() != 0 ) ;
+        
+        Resource s = m.listStatements().next().getSubject() ;
+        assertTrue(s.getURI().startsWith("http://")) ;
+        assertTrue(s.getURI().equals("http://baseuri/s")) ;
+    }
+}
+

Added: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TestLangRIOT.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TestLangRIOT.java?rev=1410869&view=auto
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TestLangRIOT.java (added)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TestLangRIOT.java Sun Nov 18 11:07:59 2012
@@ -0,0 +1,78 @@
+/**
+ * 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.jena.riot;
+
+import org.apache.jena.riot.Lang2 ;
+import org.apache.jena.riot.Langs ;
+import org.junit.Test ;
+import org.openjena.atlas.junit.BaseTest ;
+
+public class TestLangRIOT extends BaseTest
+{
+    @Test public void lang_01() { test(Langs.langNTriples, "NT") ; }
+    @Test public void lang_02() { test(Langs.langNTriples, "N-Triples") ; }
+    @Test public void lang_03() { test(Langs.langNTriples, "N-TRIPLES") ; }
+    @Test public void lang_04() { test(Langs.langNTriples, "NTRIPLE") ; }
+    @Test public void lang_05() { test(Langs.langNTriples, "NTRIPLES") ; }
+    
+    @Test public void lang_11() { test(Langs.langTurtle, "TTL") ; }
+    @Test public void lang_12() { test(Langs.langTurtle, "TUrtLE") ; }
+
+    @Test public void lang_21() { test(Langs.langRDFXML, "RDF/XML") ; }
+    @Test public void lang_22() { test(Langs.langRDFXML, "RDFXML") ; }
+    @Test public void lang_23() { test(Langs.langRDFXML, "RDF/XML-ABBREV") ; }
+    
+    @Test public void lang_30() { test(Langs.langRDFJSON, "RDFJSON") ; }
+    @Test public void lang_31() { test(Langs.langRDFJSON, "RDF/json") ; }
+
+    @Test public void lang_40() { test(Langs.langNQuads,  "N-QUADS") ; }
+    @Test public void lang_41() { test(Langs.langNQuads, "NQuads") ; }
+    
+    @Test public void lang_50() { test(Langs.langTriG,  "TriG") ; }
+    @Test public void lang_51() { test(Langs.langTriG, "trig") ; }
+    @Test public void lang_52() { test(Langs.langTriG, "TRIG") ; }
+    
+    @Test public void guess_01() { guess("D.nt", Langs.langNTriples) ; }
+    @Test public void guess_02() { guess("D.ttl.nt", Langs.langNTriples) ; }
+
+    @Test public void guess_03() { guess("D.ttl", Langs.langTurtle) ; }
+
+    @Test public void guess_04() { guess("D.rdf", Langs.langRDFXML) ; }
+    @Test public void guess_05() { guess("D.owl", Langs.langRDFXML) ; }
+    
+    @Test public void guess_06() { guess("D.rj", Langs.langRDFJSON) ; }
+    @Test public void guess_07() { guess("D.json", Langs.langRDFJSON) ; }
+
+    @Test public void guess_08() { guess("D.nq", Langs.langNQuads) ; }
+    @Test public void guess_09() { guess("D.trig", Langs.langTriG) ; }
+    
+    private void test(Lang2 expected, String string)
+    {
+        Lang2 lang = Langs.nameToLang(string) ;
+        assertEquals(expected, lang) ;
+    }
+
+    private void guess(String string, Lang2 expected)
+    {
+        Lang2 lang = Langs.guess(string) ;
+        assertEquals(expected, lang) ;
+    }
+
+}
+

Added: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TestReadDataset.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TestReadDataset.java?rev=1410869&view=auto
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TestReadDataset.java (added)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TestReadDataset.java Sun Nov 18 11:07:59 2012
@@ -0,0 +1,116 @@
+/**
+ * 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.jena.riot;
+
+import java.io.FileInputStream ;
+import java.io.IOException ;
+
+import org.apache.jena.riot.Lang2 ;
+import org.apache.jena.riot.Langs ;
+import org.apache.jena.riot.WebReader2 ;
+import org.junit.AfterClass ;
+import org.junit.BeforeClass ;
+import org.junit.Test ;
+import org.openjena.atlas.junit.BaseTest ;
+
+import com.hp.hpl.jena.query.Dataset ;
+import com.hp.hpl.jena.query.DatasetFactory ;
+import com.hp.hpl.jena.sparql.util.Context ;
+
+public class TestReadDataset extends BaseTest
+{
+    private static final String directory = "testing/RIOT/Reader" ;
+
+    private static Context context = new Context() ;
+    
+    @BeforeClass static public void beforeClass()
+    { 
+        WebReader2.wireIntoJena() ;
+    }
+    
+    @AfterClass static public void afterClass()
+    { 
+        // Unwire?
+    }
+
+    @Test public void read_01() { read("D.nq") ; }
+    @Test public void read_02() { read("D.trig") ; }
+    @Test public void read_03() { read("D.nq",   Langs.langNQuads) ; }
+    @Test public void read_04() { read("D.trig", Langs.langTriG) ; }
+    
+    @Test public void read_11() { read("D.nq", "N-Quads") ; }
+
+    @Test public void read_12() { read("D.nq", "NQuads") ; }
+    @Test public void read_13() { read("D.nq", "NQ") ; }
+    @Test public void read_14() { read("D.trig", "TriG") ; }
+    @Test public void read_15() { read("D.trig", "trig") ; } 
+
+    @Test public void read_21() { read("D-nq",  Langs.langNQuads) ; }
+    @Test public void read_22() { read("D-trig", Langs.langTriG) ; }
+    @Test public void read_23() { read("D-nq",  "NQuads") ; }
+    @Test public void read_24() { read("D-trig", "TRIG") ; }
+
+    @Test public void read_input_1() throws IOException
+    { read_stream("D.nq", "NQ") ; }
+        
+    @Test public void read_input_2() throws IOException
+    { read_stream("D.trig", "trig") ; }
+    
+    private static String filename(String filename) { return directory+"/"+filename ; }
+
+    // Base.
+    
+    private static void read(String dataurl) { read(dataurl, (Lang2)null) ; }
+    
+    private static void read(String dataurl, String lang)
+    {
+        read(dataurl, Langs.nameToLang(lang)) ;
+    }
+    
+    private static void read(String dataurl, Lang2 lang)
+    {
+        dataurl = filename(dataurl) ;
+        Dataset ds = DatasetFactory.createMem() ;
+        WebReader2.read(ds, dataurl, lang) ;
+    }
+
+    private static void read_stream(String filename, String lang) throws IOException
+    {
+        read_stream(filename, Langs.nameToLang(lang)) ;
+    }
+    
+    private static void read_stream(String filename, Lang2 lang) throws IOException
+    {
+        filename = filename(filename) ;
+        
+        // Read with a base
+        Dataset ds0 = DatasetFactory.createMem() ;
+        FileInputStream in0 = new FileInputStream(filename) ;
+        WebReader2.read(ds0, in0, "http://example/base2", lang) ;
+        in0.close() ;
+
+        // Read again, but without base
+        Dataset ds1 = DatasetFactory.createMem() ;
+        FileInputStream in1 = new FileInputStream(filename) ;
+        WebReader2.read(ds1, in1, null, lang) ;
+        in1.close() ;
+    }
+
+}
+

Added: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/adapters/TS_RIOTAdapters.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/adapters/TS_RIOTAdapters.java?rev=1410869&view=auto
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/adapters/TS_RIOTAdapters.java (added)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/adapters/TS_RIOTAdapters.java Sun Nov 18 11:07:59 2012
@@ -0,0 +1,34 @@
+/**
+ * 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.jena.riot.adapters;
+
+import org.junit.runner.RunWith ;
+import org.junit.runners.Suite ;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses( {
+      TestFileManager.class
+})
+
+
+public class TS_RIOTAdapters
+{
+
+}
+

Added: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/adapters/TestFileManager.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/adapters/TestFileManager.java?rev=1410869&view=auto
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/adapters/TestFileManager.java (added)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/adapters/TestFileManager.java Sun Nov 18 11:07:59 2012
@@ -0,0 +1,241 @@
+/*
+ * 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.jena.riot.adapters;
+
+import java.io.InputStream ;
+
+import junit.framework.TestCase ;
+import junit.framework.TestSuite ;
+import org.apache.jena.riot.stream.TestLocationMapper ;
+import org.slf4j.Logger ;
+import org.slf4j.LoggerFactory ;
+
+import com.hp.hpl.jena.rdf.model.Model ;
+import com.hp.hpl.jena.shared.NotFoundException ;
+import com.hp.hpl.jena.util.FileManager ;
+import com.hp.hpl.jena.util.LocationMapper ;
+
+public class TestFileManager extends TestCase
+{
+    static Logger log = LoggerFactory.getLogger(TestFileManager.class) ;
+    public static final String testingDir = "testing/RIOT/FileManager" ;
+    static final String filename = "fmgr-test-file" ; 
+    static final String filenameNonExistent = "fmgr-test-file-1421" ;
+    static final String fileModel = "foo.ttl" ;
+    static final String zipname = testingDir+"/fmgr-test.zip" ;
+    
+    public TestFileManager( String name )
+    {
+        super(name);
+    }
+    
+    public static TestSuite suite()
+    {
+        return new TestSuite( TestFileManager.class );
+    }
+
+    public void testFileManagerFileLocator()
+    {
+        FileManager fileManager = new FileManager() ;
+        fileManager.addLocatorFile() ;
+        InputStream in = fileManager.open(testingDir+"/"+filename) ;
+        assertNotNull(in) ;
+        closeInputStream(in) ;
+    }
+
+    public void testFileManagerFileLocatorWithDir()
+    {
+        FileManager fileManager = new FileManager() ;
+        fileManager.addLocatorFile(testingDir) ;
+        InputStream in = fileManager.open(filename) ;
+        assertNotNull(in) ;
+        closeInputStream(in) ;
+    }
+
+
+    public void testFileManagerNoFile()
+    {
+        FileManager fileManager = new FileManager() ;
+        fileManager.addLocatorFile() ;
+        try {
+            // Tests either way round - exception or a null return.
+            InputStream in = fileManager.open(filenameNonExistent) ;
+            closeInputStream(in) ;
+            assertNull("Found non-existant file: "+filenameNonExistent, in) ;
+        } catch (NotFoundException ex) {}
+    }
+    
+    public void testFileManagerLocatorClassLoader()
+    {
+        FileManager fileManager = new FileManager() ;
+        fileManager.addLocatorClassLoader(fileManager.getClass().getClassLoader()) ;
+        InputStream in = fileManager.open("java/lang/String.class") ;
+        assertNotNull(in) ;
+        closeInputStream(in) ;
+    }
+
+    public void testFileManagerLocatorClassLoaderNotFound()
+    {
+        FileManager fileManager = new FileManager() ;
+        fileManager.addLocatorClassLoader(fileManager.getClass().getClassLoader()) ;
+        try {
+            InputStream in = fileManager.open("not/java/lang/String.class") ;
+            closeInputStream(in) ;
+            assertNull("Found non-existant class", in) ;
+        } catch (NotFoundException ex) {}
+    }
+
+    public void testFileManagerLocatorZip()
+    {
+        FileManager fileManager = new FileManager() ;
+        try {
+            fileManager.addLocatorZip(zipname) ;
+        } catch (Exception ex)
+        {
+           fail("Failed to create a filemanager and add a zip locator") ;
+        }
+        InputStream in = fileManager.open(filename) ;
+        assertNotNull(in) ;
+        closeInputStream(in) ;
+    }
+
+    public void testFileManagerLocatorZipNonFound()
+    {
+        FileManager fileManager = new FileManager() ;
+        try {
+            fileManager.addLocatorZip(zipname) ;
+        } catch (Exception ex)
+        { fail("Failed to create a filemanager and add a zip locator") ; }
+        try {
+            InputStream in = fileManager.open(filenameNonExistent) ;
+            closeInputStream(in) ;
+            assertNull("Found non-existant zip file member", in) ;
+        } catch (NotFoundException ex) {}
+    }
+    
+    public void testFileManagerClone()
+    {
+        FileManager fileManager1 = new FileManager() ;
+        FileManager fileManager2 = new FileManager(fileManager1) ;
+        
+        // Should not affect fileManager2
+        fileManager1.addLocatorFile() ;
+        {
+            InputStream in = fileManager1.open(testingDir+"/"+filename) ;
+            assertNotNull(in) ;
+            closeInputStream(in) ;
+        }
+        // Should not work.
+        try {
+            InputStream in = fileManager2.open(testingDir+"/"+filename) ;
+            closeInputStream(in) ;
+            assertNull("Found file via wrong FileManager", in) ;
+        } catch (NotFoundException ex) {}
+    }
+    
+    
+    public void testLocationMappingURLtoFileOpen()
+    {
+        LocationMapper locMap = new LocationMapper(TestLocationMapper.mapping) ;
+        FileManager fileManager = new FileManager(locMap) ;
+        fileManager.addLocatorFile() ;
+        InputStream in = fileManager.open("http://example.org/file") ;
+        assertNotNull(in) ;
+        closeInputStream(in) ;
+    }
+
+    public void testLocationMappingURLtoFileOpenNotFound()
+    {
+        LocationMapper locMap = new LocationMapper(TestLocationMapper.mapping) ;
+        FileManager fileManager = new FileManager(locMap) ;
+        fileManager.addLocatorClassLoader(fileManager.getClass().getClassLoader()) ;
+        try {
+            InputStream in = fileManager.open("http://example.org/file") ;
+            closeInputStream(in) ;
+            assertNull("Found nont-existant URL", null) ;
+        } catch (NotFoundException ex) {}
+    }
+
+    public void testCache1()
+    {
+        FileManager fileManager = new FileManager() ;
+        fileManager.addLocatorFile(testingDir) ;
+        Model m1 = fileManager.loadModel(fileModel) ;
+        Model m2 = fileManager.loadModel(fileModel) ;
+        assertNotSame(m1, m2) ;
+    }
+    
+    public void testCache2()
+    {
+        FileManager fileManager = FileManager.get() ;
+        fileManager.addLocatorFile(testingDir) ;
+        fileManager.setModelCaching(true) ;
+        Model m1 = fileManager.loadModel(fileModel) ;
+        Model m2 = fileManager.loadModel(fileModel) ;
+        assertSame(m1, m2) ;
+    }
+    
+    public void testCache3()
+    {
+        FileManager fileManager = FileManager.get() ;
+        fileManager.addLocatorFile(testingDir) ;
+        fileManager.setModelCaching(true) ;
+        Model m1 = fileManager.loadModel(fileModel) ;
+        Model m2 = fileManager.loadModel(fileModel) ;
+        assertSame(m1, m2) ;
+        
+        fileManager.removeCacheModel(fileModel) ;
+        Model m3 = fileManager.loadModel(fileModel) ;
+        assertNotSame(m1, m3) ;
+        
+        fileManager.resetCache() ;
+        Model m4 = fileManager.loadModel(fileModel) ;
+        Model m5 = fileManager.loadModel(fileModel) ;
+
+        assertSame(m4, m5) ;
+        assertNotSame(m1, m4) ;
+        assertNotSame(m3, m4) ;
+    }
+    
+//    public void testFileManagerLocatorURL()
+//    {
+//        FileManager fileManager = new FileManager() ;
+//        fileManager.addLocatorURL() ;
+//        InputStream in = fileManager.open("http:///www.bbc.co.uk/") ;
+//        //assertNotNull(in) ;
+//        // Proxies matter.
+//        if ( in == null )
+//            log.warn("Failed to contact http:///www.bbc.co.uk/: maybe due to proxy issues") ;
+//        
+//        try { if ( in != null ) in.close() ; }
+//        catch (Exception ex) {}
+//    }
+
+    
+    // -------- Helpers
+    
+    private void closeInputStream(InputStream in)
+    {
+      try {
+          if ( in != null )
+              in.close() ;
+      }
+      catch (Exception ex) {}
+    }
+}

Added: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/FactoryTestRiot.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/FactoryTestRiot.java?rev=1410869&view=auto
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/FactoryTestRiot.java (added)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/FactoryTestRiot.java Sun Nov 18 11:07:59 2012
@@ -0,0 +1,126 @@
+/*
+ * 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.jena.riot.langsuite ;
+
+import junit.framework.Test ;
+import junit.framework.TestSuite ;
+import org.apache.jena.riot.Lang2 ;
+import org.openjena.riot.RiotException ;
+import org.openjena.riot.TestVocabRIOT ;
+
+import com.hp.hpl.jena.rdf.model.Resource ;
+import com.hp.hpl.jena.util.junit.TestFactoryManifest ;
+import com.hp.hpl.jena.util.junit.TestUtils ;
+import com.hp.hpl.jena.vocabulary.RDF ;
+
+public class FactoryTestRiot extends TestFactoryManifest
+{
+
+    public static TestSuite make(String manifest, Resource dftTestType, String labelPrefix)
+    {
+        return new FactoryTestRiot(dftTestType, labelPrefix).process(manifest) ;
+    }
+
+    private Resource dftTestType ;
+    private String labelPrefix ;
+
+    public FactoryTestRiot(Resource dftTestType, String labelPrefix)
+    {
+        // FileManager? 
+        
+        this.dftTestType = dftTestType ;
+        this.labelPrefix = labelPrefix ;
+    }
+    
+    @Override
+    public Test makeTest(Resource manifest, Resource item, String testName, Resource action, Resource result)
+    {
+        try
+        {
+            Resource r = TestUtils.getResource(item, RDF.type) ;
+            if ( r == null )
+                r = dftTestType ;
+            if ( r == null )
+                throw new RiotException("Can't determine the test type") ;
+            
+            if ( labelPrefix != null )
+                testName = labelPrefix+testName ;
+            
+            // In Turtle tests, the action directly names the file to process.
+            Resource input = action ;
+            Resource output = result ; 
+            
+            String baseIRI = TestVocabRIOT.assumedBaseURI ;
+            String x = input.getLocalName() ;
+            // Yuk, yuk, yuk.
+            baseIRI = baseIRI+x ;
+
+            if ( r.equals(VocabLangRDF.TestPositiveSyntaxTTL) )
+                return new UnitTestSyntax(testName, input.getURI(), Lang2.TURTLE) ;
+            
+            if ( r.equals(VocabLangRDF.TestNegativeSyntaxTTL) )
+                return new UnitTestBadSyntax(testName, input.getURI(), Lang2.TURTLE) ;
+
+            if ( r.equals(VocabLangRDF.TestPositiveSyntaxNT) )
+                return new UnitTestSyntax(testName, input.getURI(), Lang2.NTRIPLES) ;
+            
+            if ( r.equals(VocabLangRDF.TestNegativeSyntaxNT) )
+                return new UnitTestBadSyntax(testName, input.getURI(), Lang2.NTRIPLES) ;
+
+            if ( r.equals(VocabLangRDF.TestPositiveSyntaxRJ) )
+                return new UnitTestSyntax(testName, input.getURI(), Lang2.RDFJSON) ;
+            
+            if ( r.equals(VocabLangRDF.TestNegativeSyntaxRJ) )
+                return new UnitTestBadSyntax(testName, input.getURI(), Lang2.RDFJSON) ;
+            
+            if ( r.equals(VocabLangRDF.TestSurpressed ))
+                return new UnitTestSurpressed(testName) ;
+
+            // Eval.
+            
+            if ( r.equals(VocabLangRDF.TestEvalTTL) )
+                return new UnitTestEval(testName, input.getURI(), result.getURI(), baseIRI, Lang2.TURTLE) ;
+
+            if ( r.equals(VocabLangRDF.TestNegativeEvalTTL) )
+                return new UnitTestBadEval(testName, input.getURI(), Lang2.TURTLE) ;
+            
+            if ( r.equals(VocabLangRDF.TestEvalNT) )
+                return new UnitTestEval(testName, input.getURI(), result.getURI(), baseIRI, Lang2.NTRIPLES) ;
+
+            if ( r.equals(VocabLangRDF.TestNegativeEvalNT) )
+                return new UnitTestBadEval(testName, input.getURI(), Lang2.NTRIPLES) ;
+            
+            if ( r.equals(VocabLangRDF.TestEvalRJ) )
+                return new UnitTestEval(testName, input.getURI(), result.getURI(), baseIRI, Lang2.RDFJSON) ;
+
+            if ( r.equals(VocabLangRDF.TestNegativeEvalRJ) )
+                return new UnitTestBadEval(testName, input.getURI(), Lang2.RDFJSON) ;
+
+            System.err.println("Unrecognized turtle test : " + testName) ;
+            return null ;
+
+        } catch (Exception ex)
+        {
+            ex.printStackTrace(System.err) ;
+            System.err.println("Failed to grok test : " + testName) ;
+            return null ;
+        }
+    }
+
+}

Added: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/LangTestCase.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/LangTestCase.java?rev=1410869&view=auto
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/LangTestCase.java (added)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/LangTestCase.java Sun Nov 18 11:07:59 2012
@@ -0,0 +1,58 @@
+/**
+ * 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.jena.riot.langsuite;
+
+import junit.framework.TestCase ;
+import org.openjena.atlas.junit.BaseTest ;
+import org.openjena.riot.ErrorHandlerFactory ;
+import org.openjena.riot.SysRIOT ;
+
+public abstract class LangTestCase extends TestCase
+{
+    protected LangTestCase(String name) { super(name) ; }
+    
+    protected abstract void _setUp() ; 
+    protected abstract void _tearDown() ; 
+    
+    protected boolean sysRIOT_strictMode ;
+    protected boolean sysRIOT_strictXSDLexicialForms ;
+    
+    @Override
+    final public void setUp()
+    {        
+        BaseTest.setTestLogging(ErrorHandlerFactory.errorHandlerStrictNoLogging) ;
+        sysRIOT_strictMode = SysRIOT.strictMode ;
+        sysRIOT_strictXSDLexicialForms = SysRIOT.StrictXSDLexicialForms ;
+        
+        SysRIOT.strictMode = true ;
+        SysRIOT.StrictXSDLexicialForms = true ;
+        _setUp() ;
+    }
+    
+    @Override
+    final public void tearDown()
+    {
+        _tearDown() ;
+        SysRIOT.strictMode = sysRIOT_strictMode ;
+        SysRIOT.StrictXSDLexicialForms = sysRIOT_strictXSDLexicialForms ;
+        BaseTest.unsetTestLogging() ; 
+    }
+
+}
+

Added: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/UnitTestBadEval.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/UnitTestBadEval.java?rev=1410869&view=auto
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/UnitTestBadEval.java (added)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/UnitTestBadEval.java Sun Nov 18 11:07:59 2012
@@ -0,0 +1,84 @@
+/*
+ * 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.jena.riot.langsuite;
+
+
+import junit.framework.TestCase ;
+import org.apache.jena.riot.Lang2 ;
+import org.junit.After ;
+import org.junit.Before ;
+import org.openjena.riot.* ;
+import org.openjena.riot.system.JenaReaderTurtle2 ;
+
+import com.hp.hpl.jena.rdf.model.Model ;
+import com.hp.hpl.jena.rdf.model.ModelFactory ;
+import com.hp.hpl.jena.rdf.model.RDFReader ;
+import com.hp.hpl.jena.shared.JenaException ;
+
+public class UnitTestBadEval extends TestCase
+{
+    private final String input ;
+    private final Lang2 lang ;
+
+    protected UnitTestBadEval(String name, String uri, Lang2 lang)
+    {
+        super(name) ;
+        this.input = uri ;
+        this.lang = lang ;
+    }
+    
+    ErrorHandler installed ;
+    
+    @Override
+    @Before
+    public void setUp()
+    {
+        installed = ErrorHandlerFactory.getDefaultErrorHandler() ;
+        ErrorHandlerFactory.setDefaultErrorHandler(ErrorHandlerFactory.errorHandlerStrictSilent()) ;
+    }
+    
+    @Override
+    @After
+    public void tearDown()
+    {
+        ErrorHandlerFactory.setDefaultErrorHandler(installed) ;
+    }
+    
+
+    @Override
+    public void runTest()
+    {
+        // Install picky error handler.
+        
+        
+        
+        Model model = ModelFactory.createDefaultModel() ;
+        RDFReader rdfreader = new JenaReaderTurtle2() ;
+        try {
+            rdfreader.read(model, input) ;
+            fail("Managed to read a bad evaluation test without error") ;
+        } 
+        catch (RiotException ex) {}
+        catch (JenaException ex) {}
+        catch (RuntimeException ex) 
+        { 
+            ex.printStackTrace(System.err) ;
+            throw ex ; }
+    }
+}

Added: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/UnitTestBadSyntax.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/UnitTestBadSyntax.java?rev=1410869&view=auto
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/UnitTestBadSyntax.java (added)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/UnitTestBadSyntax.java Sun Nov 18 11:07:59 2012
@@ -0,0 +1,87 @@
+/*
+ * 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.jena.riot.langsuite;
+
+import static org.openjena.riot.SysRIOT.fmtMessage ;
+import org.apache.jena.riot.Lang2 ;
+import org.apache.jena.riot.WebReader2 ;
+import org.openjena.atlas.junit.BaseTest ;
+import org.openjena.riot.ErrorHandler ;
+import org.openjena.riot.ErrorHandlerFactory ;
+import org.openjena.riot.RiotException ;
+
+import com.hp.hpl.jena.rdf.model.Model ;
+import com.hp.hpl.jena.rdf.model.ModelFactory ;
+
+public class UnitTestBadSyntax extends LangTestCase
+{
+    private final String uri ;
+    private final Lang2 lang ;
+
+    protected UnitTestBadSyntax(String name, String uri, Lang2 lang)
+    {
+        super(name) ;
+        this.uri = uri ;
+        this.lang = lang ;
+    }
+    
+    /** An error handler that throw exceptions on warnings and errors */ 
+    private static ErrorHandler errorHandlerTestStrict = new ErrorHandler()
+    {
+        /** report a warning  - do not carry on */
+        @Override
+        public void warning(String message, long line, long col)
+        { 
+            throw new RiotException(fmtMessage(message, line, col)) ;
+        }
+        
+        /** report an error - do not carry on */
+        @Override
+        public void error(String message, long line, long col)
+        { 
+            throw new RiotException(fmtMessage(message, line, col)) ;
+        }
+
+        @Override
+        public void fatal(String message, long line, long col)
+        {
+            throw new RiotException(fmtMessage(message, line, col)) ;
+        }
+    } ;
+
+    @Override
+    protected void _setUp()         { BaseTest.setTestLogging(ErrorHandlerFactory.errorHandlerStrictNoLogging) ; }
+
+    @Override
+    protected void _tearDown()      { BaseTest.unsetTestLogging() ; }
+
+    @Override
+    public void runTest()
+    {
+        Model model = ModelFactory.createDefaultModel() ;
+        try {
+            WebReader2.read(model, uri, uri, lang) ;
+        } catch (RiotException ex) { return ; }
+        catch (RuntimeException ex) {
+            ex.printStackTrace(System.err) ;
+            fail("Unexpected exception") ;
+        }
+        fail("Bad syntax test succeed in parsing the file") ;
+    }
+}

Added: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/UnitTestEval.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/UnitTestEval.java?rev=1410869&view=auto
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/UnitTestEval.java (added)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/UnitTestEval.java Sun Nov 18 11:07:59 2012
@@ -0,0 +1,94 @@
+/*
+ * 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.jena.riot.langsuite;
+
+import org.apache.jena.riot.Lang2 ;
+import org.apache.jena.riot.RDFReaderRIOT ;
+import org.apache.jena.riot.WebReader2 ;
+import org.openjena.riot.RiotException ;
+import org.openjena.riot.system.JenaReaderNTriples2 ;
+
+import com.hp.hpl.jena.rdf.model.Model ;
+import com.hp.hpl.jena.rdf.model.ModelFactory ;
+import com.hp.hpl.jena.rdf.model.RDFReader ;
+import com.hp.hpl.jena.util.FileUtils ;
+
+public class UnitTestEval extends LangTestCase
+{
+    String input ;
+    String output ;
+    String baseIRI ;
+    Lang2 lang ;
+    
+    public UnitTestEval(String name, String input, String output, String baseIRI, Lang2 lang)
+    {
+        super(name) ;
+        this.input = input ;
+        this.output = output ;
+        this.baseIRI = baseIRI ;
+        this.lang = lang ;
+    }
+    
+    @Override
+    protected void _setUp()
+    {}
+
+    @Override
+    protected void _tearDown()
+    {}
+
+    @Override
+    public void runTest()
+    {
+        Model model = ModelFactory.createDefaultModel() ;
+        RDFReader rdfreader = new RDFReaderRIOT() ;
+        try {
+            if ( baseIRI != null )
+                WebReader2.read(model, input, baseIRI, lang) ;
+            else
+                WebReader2.read(model, input, lang) ;
+            
+            String syntax = FileUtils.guessLang(output, FileUtils.langNTriple) ;
+            Model results = ModelFactory.createDefaultModel() ;
+            // Directly get an N-triples reader
+            new JenaReaderNTriples2().read(results, output) ;
+
+            boolean b = model.isIsomorphicWith(results) ;
+            if ( !b )
+            {
+                //model.isIsomorphicWith(results) ;
+                System.out.println("---- Parsed");
+                model.write(System.out, "TTL") ;
+                System.out.println("---- Expected");
+                results.write(System.out, "TTL") ;
+                System.out.println("--------");
+            }
+            
+            assertTrue("Models not isomorphic", b) ;
+        } catch (RiotException ex)
+        {
+            // Catch and rethrow - debugging.
+            throw ex ;    
+        }
+        catch (RuntimeException ex) 
+        { 
+            ex.printStackTrace(System.err) ;
+            throw ex ; }
+    }
+}

Added: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/UnitTestSurpressed.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/UnitTestSurpressed.java?rev=1410869&view=auto
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/UnitTestSurpressed.java (added)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/UnitTestSurpressed.java Sun Nov 18 11:07:59 2012
@@ -0,0 +1,40 @@
+/**
+ * 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.jena.riot.langsuite;
+
+public class UnitTestSurpressed extends LangTestCase
+{
+    public UnitTestSurpressed(String name)
+    {
+        super(name) ;
+    }
+    
+    @Override
+    public void runTest()
+    { }
+
+    @Override
+    protected void _setUp()
+    {}
+
+    @Override
+    protected void _tearDown()
+    {}
+}
+

Added: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/UnitTestSyntax.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/UnitTestSyntax.java?rev=1410869&view=auto
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/UnitTestSyntax.java (added)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/UnitTestSyntax.java Sun Nov 18 11:07:59 2012
@@ -0,0 +1,48 @@
+/*
+ * 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.jena.riot.langsuite;
+
+import org.apache.jena.riot.Lang2 ;
+import org.apache.jena.riot.WebReader2 ;
+
+import com.hp.hpl.jena.rdf.model.Model ;
+import com.hp.hpl.jena.rdf.model.ModelFactory ;
+
+public class UnitTestSyntax extends LangTestCase
+{
+    private final String uri ;
+    private final Lang2 lang ;
+    public UnitTestSyntax(String name, String uri, Lang2 lang) { super(name) ; this.uri = uri ; this.lang = lang ; }
+    
+    @Override
+    public void runTest()
+    {
+        Model model = ModelFactory.createDefaultModel() ;
+        WebReader2.read(model, uri, uri, lang) ;
+    }
+
+    @Override
+    protected void _setUp()
+    {}
+
+    @Override
+    protected void _tearDown()
+    {}
+
+}

Added: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/VocabLangRDF.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/VocabLangRDF.java?rev=1410869&view=auto
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/VocabLangRDF.java (added)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/langsuite/VocabLangRDF.java Sun Nov 18 11:07:59 2012
@@ -0,0 +1,84 @@
+/**
+ * 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.jena.riot.langsuite;
+
+import com.hp.hpl.jena.rdf.model.Model ;
+import com.hp.hpl.jena.rdf.model.ModelFactory ;
+import com.hp.hpl.jena.rdf.model.Resource ;
+
+public class VocabLangRDF
+{
+    public static String assumedBaseURI = "http://example/base/" ;
+
+    /** <p>The RDF model that holds the vocabulary terms</p> */
+    private static Model m_model = ModelFactory.createDefaultModel();
+
+    /** <p>The namespace of the vocabulary as a string</p> */
+    public static final String NS = "http://www.w3.org/ns/rdftest#" ;
+
+    /** <p>The namespace of the vocabulary as a string</p>
+     *  @see #NS */
+    public static String getURI() {return NS;}
+
+    /** <p>The namespace of the vocabulary as a resource</p> */
+    public static final Resource NAMESPACE = m_model.createResource( NS );
+
+    public static final Resource TestPositiveSyntaxTTL      = m_model.createResource( NS+"TestTurtlePositiveSyntax" );
+
+    public static final Resource TestNegativeSyntaxTTL      = m_model.createResource( NS+"TestTurtleNegativeSyntax" );
+
+    public static final Resource TestEvalTTL                = m_model.createResource( NS+"TestTurtleEval" );
+
+    public static final Resource TestNegativeEvalTTL        = m_model.createResource( NS+"TestTurtleNegativeEval" );
+
+    public static final Resource TestPositiveSyntaxNT       = m_model.createResource( NS+"TestNTriplesPositiveSyntax" );
+
+    public static final Resource TestNegativeSyntaxNT       = m_model.createResource( NS+"TestNTriplesNegativeSyntax" );
+
+    public static final Resource TestEvalNT                 = m_model.createResource( NS+"TestNTriplesEval" );
+
+    public static final Resource TestNegativeEvalNT         = m_model.createResource( NS+"TestNTriplesNegativeEval" );
+
+    public static final Resource TestPositiveSyntaxRJ       = m_model.createResource( NS+"TestRDFJSONPositiveSyntax" );
+
+    public static final Resource TestNegativeSyntaxRJ       = m_model.createResource( NS+"TestRDFJSONNegativeSyntax" );
+
+    public static final Resource TestEvalRJ                 = m_model.createResource( NS+"TestRDFJSONEval" );
+
+    public static final Resource TestNegativeEvalRJ         = m_model.createResource( NS+"TestRDFJSONNegativeEval" );
+
+    public static final Resource TestPositiveSyntaxNQ       = m_model.createResource( NS+"TestNQuadsPositiveSyntax" );
+
+    public static final Resource TestNegativeSyntaxNQ       = m_model.createResource( NS+"TestNQuadsNegativeSyntax" );
+
+    public static final Resource TestEvalNQ                 = m_model.createResource( NS+"TestNQuadsEval" );
+
+    public static final Resource TestNegativeEvalNQ         = m_model.createResource( NS+"TestNQuadsNegativeEval" );
+
+    public static final Resource TestPositiveSyntaxTriG     = m_model.createResource( NS+"TestTrigPositiveSyntax" );
+
+    public static final Resource TestNegativeSyntaxTriG     = m_model.createResource( NS+"TestTrigNegativeSyntax" );
+
+    public static final Resource TestEvalTriG               = m_model.createResource( NS+"TestTrigEval" );
+
+    public static final Resource TestNegativeEvalTriG       = m_model.createResource( NS+"TestTrigNegativeEval" );
+
+    public static final Resource TestSurpressed             = m_model.createResource( NS+"Test" );
+}
+

Added: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/stream/TS_IO2.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/stream/TS_IO2.java?rev=1410869&view=auto
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/stream/TS_IO2.java (added)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/stream/TS_IO2.java Sun Nov 18 11:07:59 2012
@@ -0,0 +1,34 @@
+/*
+ * 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.jena.riot.stream;
+
+
+import org.junit.runner.RunWith ;
+import org.junit.runners.Suite ;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses( {
+      TestStreamManager.class
+    , TestLocationMapper.class
+    , TestLocators.class
+})
+public class TS_IO2
+{
+
+}

Added: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/stream/TestLocationMapper.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/stream/TestLocationMapper.java?rev=1410869&view=auto
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/stream/TestLocationMapper.java (added)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/stream/TestLocationMapper.java Sun Nov 18 11:07:59 2012
@@ -0,0 +1,177 @@
+/*
+ * 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.jena.riot.stream;
+
+import java.util.Iterator ;
+
+import junit.framework.TestCase ;
+import junit.framework.TestSuite ;
+import org.apache.jena.riot.adapters.TestFileManager ;
+import org.slf4j.Logger ;
+import org.slf4j.LoggerFactory ;
+
+import com.hp.hpl.jena.rdf.model.Model ;
+import com.hp.hpl.jena.util.FileManager ;
+import com.hp.hpl.jena.util.LocationMapper ;
+
+public class TestLocationMapper extends TestCase
+{
+    static Logger log = LoggerFactory.getLogger(TestLocationMapper.class) ;
+    static final String testingDir = TestFileManager.testingDir ;
+    static final String filename1 = "file:test" ; 
+    static final String notFilename = "zzzz" ;
+    static final String filename2 = "file:"+testingDir+"/location-mapping-test-file" ;
+    public static final String mapping = "location-mapping-test.ttl;"+
+                                  testingDir+"/location-mapping-test.ttl" ;
+
+    
+    public TestLocationMapper( String name )
+    {
+        super(name);
+    }
+    
+    public static TestSuite suite()
+    {
+        return new TestSuite( TestLocationMapper.class );
+    }
+
+    public void testLocationMapper()
+    {
+        LocationMapper locMap = new LocationMapper(mapping) ;
+        String alt = locMap.altMapping(filename1) ;
+        assertNotNull(alt) ;
+        assertEquals(filename2, alt) ;
+    }
+
+    public void testLocationMapperMiss()
+    {
+        LocationMapper locMap = new LocationMapper(mapping) ;
+        String alt = locMap.altMapping(notFilename) ;
+        assertNotNull(alt) ;
+        assertEquals(notFilename, alt) ;
+    }
+
+    public void testLocationMapperURLtoFile()
+    {
+        LocationMapper locMap = new LocationMapper(mapping) ;
+        String alt = locMap.altMapping("http://example.org/file") ;
+        assertNotNull(alt) ;
+        assertEquals("file:"+testingDir+"/location-mapping-test-file", alt) ;
+    }
+    
+    public void testLocationMapperFromModel()
+    {
+        Model model = FileManager.get().loadModel(testingDir+"/location-mapping-test.ttl") ;
+        LocationMapper loc = new LocationMapper(model) ; 
+        
+        // Light test that the two location mappers are "the same"
+        LocationMapper locMap = new LocationMapper(mapping) ;
+        for ( Iterator<String> iter = loc.listAltEntries() ; iter.hasNext() ; )
+        {
+            String e = iter.next() ;
+            String v1 = locMap.getAltEntry(e) ;
+            String v2 = loc.getAltEntry(e) ;
+            assertEquals("Different entries", v1, v2) ;
+        }
+        for ( Iterator<String> iter = loc.listAltPrefixes() ; iter.hasNext() ; )
+        {
+            String e = iter.next() ;
+            String v1 = locMap.getAltPrefix(e) ;
+            String v2 = loc.getAltPrefix(e) ;
+            assertEquals("Different entries", v1, v2) ;
+        }
+    }
+
+    public void testLocationMapperClone1()
+    {
+        LocationMapper locMap1 = new LocationMapper(mapping) ;
+        // See testLocationMapperURLtoFile
+//        String alt = locMap.altMapping("http://example.org/file") ;
+//        assertNotNull(alt) ;
+//        assertEquals(alt, "file:"+testingDir+"/location-mapping-test-file") ;
+        
+        LocationMapper locMap2 = new LocationMapper(locMap1) ;
+        // Remove from original
+        locMap1.removeAltEntry("http://example.org/file") ;
+        String alt = locMap2.altMapping("http://example.org/file") ;
+        assertNotNull(alt) ;
+        assertEquals("file:"+testingDir+"/location-mapping-test-file", alt) ;
+    }
+    
+    public void testLocationMapperClone2()
+    {
+        LocationMapper locMap1 = new LocationMapper(mapping) ;
+        // See testLocationMapperURLtoFile
+//        String alt = locMap.altMapping("http://example.org/file") ;
+//        assertNotNull(alt) ;
+//        assertEquals(alt, "file:"+testingDir+"/location-mapping-test-file") ;
+        
+        LocationMapper locMap2 = new LocationMapper(locMap1) ;
+
+        // Change this one
+        locMap2.addAltPrefix("http://example.org/OTHER", "file:OTHER") ;
+        {
+            String alt = locMap2.altMapping("http://example.org/OTHER/f") ;
+            assertNotNull(alt) ;
+            assertEquals("file:OTHER/f", alt) ;
+        }
+        // Not the other
+        {
+            String alt = locMap1.altMapping("http://example.org/OTHER/f") ;
+            assertNotNull(alt) ;
+            // Did not change
+            assertEquals("http://example.org/OTHER/f", alt) ;
+        }
+    }
+
+    public void testLocationMapperEquals1()
+    {
+        LocationMapper locMap1 = new LocationMapper(mapping) ;
+        LocationMapper locMap2 = new LocationMapper(mapping) ;
+        assertEquals(locMap1, locMap2) ;
+        assertEquals(locMap1.hashCode(), locMap2.hashCode()) ;
+    }
+
+    public void testLocationMapperEquals2()
+    {
+        LocationMapper locMap1 = new LocationMapper(mapping) ;
+        LocationMapper locMap2 = new LocationMapper(mapping) ;
+        locMap2.addAltEntry("file:nowhere", "file:somewhere") ;
+        assertFalse(locMap1.equals(locMap2)) ;
+        assertFalse(locMap2.equals(locMap1)) ;
+    }
+
+    public void testLocationMapperToModel1()
+    {
+        LocationMapper locMap1 = new LocationMapper(mapping) ;
+        LocationMapper locMap2 = new LocationMapper(locMap1.toModel()) ;
+        assertEquals(locMap1, locMap2) ;
+        assertEquals(locMap1.hashCode(), locMap2.hashCode()) ;
+    }
+
+    public void testLocationMapperToModel2()
+    {
+        LocationMapper locMap1 = new LocationMapper(mapping) ;
+        LocationMapper locMap2 = new LocationMapper(mapping) ;
+        locMap1 = new LocationMapper(locMap1.toModel()) ;
+        locMap2.addAltEntry("file:nowhere", "file:somewhere") ;
+        assertFalse(locMap1.equals(locMap2)) ;
+        assertFalse(locMap2.equals(locMap1)) ;
+    }
+}

Added: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/stream/TestLocators.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/stream/TestLocators.java?rev=1410869&view=auto
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/stream/TestLocators.java (added)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/stream/TestLocators.java Sun Nov 18 11:07:59 2012
@@ -0,0 +1,84 @@
+/*
+ * 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.jena.riot.stream;
+
+import java.io.File ;
+
+import org.apache.jena.riot.TypedInputStream2 ;
+import org.apache.jena.riot.stream.LocatorFile2 ;
+import org.junit.Test ;
+import org.openjena.atlas.junit.BaseTest ;
+import org.openjena.riot.WebContent ;
+
+public class TestLocators extends BaseTest 
+{
+    public static final String testingDir = "testing/RIOT/Files/" ;
+    
+    @Test public void locatorFile_01()
+    {
+        LocatorFile2 loc = new LocatorFile2() ;
+        assertTrue(loc.exists("pom.xml")) ;
+        assertTrue(loc.exists(testingDir+"data.ttl")) ;
+        assertFalse(loc.exists("IDoNotExist")) ;
+    }
+    
+    @Test public void locatorFile_02()
+    {
+        LocatorFile2 loc = new LocatorFile2(".") ;
+        assertTrue(loc.exists("pom.xml")) ;
+        assertTrue(loc.exists(testingDir+"data.ttl")) ;
+        assertFalse(loc.exists("IDoNotExist")) ;
+    }
+
+    @Test public void locatorFile_03()
+    {
+        String dir = new File(".").getAbsolutePath() ;
+        LocatorFile2 loc = new LocatorFile2(dir) ;
+        assertTrue(loc.exists("pom.xml")) ;
+        assertFalse(loc.exists("IDoNotExist")) ;
+    }
+    
+    @Test public void locatorFile_04()
+    {
+        String dir = new File("src").getAbsolutePath() ;
+        LocatorFile2 loc = new LocatorFile2(dir) ;
+        
+        assertFalse(loc.exists("pom.xml")) ;
+        assertTrue(loc.exists("main")) ;
+        assertFalse(loc.exists(testingDir+"data.ttl")) ;
+        assertTrue(loc.exists("../pom.xml")) ;
+        assertFalse(loc.exists("/../"+testingDir+"data.ttl")) ;
+    }
+    
+    @Test public void locatorFile_05()
+    {
+        LocatorFile2 loc = new LocatorFile2() ;
+        TypedInputStream2 ts = loc.open(testingDir+"data.ttl") ;
+        assertTrue("Not equal: "+WebContent.contentTypeTurtle+" != "+ts.getMediaType(), 
+                   WebContent.contentTypeTurtle.equalsIgnoreCase(ts.getContentType())) ;
+    }
+
+    // TypedStream
+    
+    @Test public void locatorURL_01() {}
+
+    @Test public void locatorZip_01() {}
+
+    @Test public void locatorClassloader_01() {}
+}

Added: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/stream/TestStreamManager.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/stream/TestStreamManager.java?rev=1410869&view=auto
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/stream/TestStreamManager.java (added)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/stream/TestStreamManager.java Sun Nov 18 11:07:59 2012
@@ -0,0 +1,115 @@
+/**
+ * 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.jena.riot.stream;
+
+import java.io.File ;
+
+import org.apache.jena.riot.TypedInputStream2 ;
+import org.apache.jena.riot.WebReader2 ;
+import org.apache.jena.riot.stream.LocatorFile2 ;
+import org.apache.jena.riot.stream.LocatorURL2 ;
+import org.apache.jena.riot.stream.StreamManager ;
+import org.junit.AfterClass ;
+import org.junit.BeforeClass ;
+import org.junit.Test ;
+import org.openjena.atlas.junit.BaseTest ;
+import org.openjena.riot.RiotNotFoundException ;
+
+import com.hp.hpl.jena.rdf.model.Model ;
+import com.hp.hpl.jena.rdf.model.ModelFactory ;
+import com.hp.hpl.jena.sparql.util.Context ;
+
+public class TestStreamManager extends BaseTest
+{
+    private static final String directory = "testing/RIOT/StreamManager" ;
+    private static final String absDirectory = new File(directory).getAbsolutePath() ;
+
+    private static Context context = new Context() ;
+    
+    private static StreamManager streamMgr ;
+    private static StreamManager streamMgrStd ;
+    private static Object streamManagerContextValue ;
+    
+    @BeforeClass static public void beforeClass()
+    { 
+        streamMgrStd = StreamManager.get() ;
+        streamMgr = new StreamManager() ;
+        streamMgr.addLocator(new LocatorFile2()) ;
+        streamMgr.addLocator(new LocatorFile2(directory)) ;
+        streamMgr.addLocator(new LocatorURL2()) ;
+        
+        streamManagerContextValue = context.get(WebReader2.streamManagerSymbol) ;
+        context.put(WebReader2.streamManagerSymbol, streamMgr) ;
+    }
+    
+    @AfterClass static public void afterClass()
+    { 
+        StreamManager.setGlobal(streamMgrStd) ;
+        if ( streamManagerContextValue == null )
+            context.remove(WebReader2.streamManagerSymbol) ;
+        else
+            context.put(WebReader2.streamManagerSymbol, streamManagerContextValue) ;
+    }
+    
+    @Test public void fm_open_01() { open(directory+"/D.ttl", context) ; }
+    @Test public void fm_open_02() { open("D.ttl", context) ; }
+
+    @Test public void fm_open_03() { open("file:"+directory+"/D.ttl", context) ; }
+    @Test public void fm_open_04() { open("file:D.ttl", context) ; }
+    
+    @Test public void fm_open_05() { open(absDirectory+"/D.ttl", context) ; }
+    @Test public void fm_open_06() { open("file://"+absDirectory+"/D.ttl", context) ; }
+    
+    @Test (expected=RiotNotFoundException.class)
+    public void fm_open_10() { open("nosuchfile", null) ; }
+    
+    @Test public void fm_read_01() { read("D.nt") ; }
+    @Test public void fm_read_02() { read("D.ttl") ; }
+    @Test public void fm_read_03() { read("D.rdf") ; }
+    @Test public void fm_read_04() { read("D.json") ; }
+
+    @Test public void fm_read_11() { read("file:D.nt") ; }
+    @Test public void fm_read_12() { read("file:D.ttl") ; }
+    @Test public void fm_read_13() { read("file:D.rdf") ; }
+    @Test public void fm_read_14() { read("file:D.json") ; }
+    
+    // TriG
+    // NQuads
+    
+    private static void open(String dataName, Context context)
+    {
+        TypedInputStream2 in ;
+        if ( context != null )
+            in = WebReader2.open(dataName, context) ;
+        else
+            in = WebReader2.open(dataName) ;
+        assertNotNull(in) ;
+        in.close() ;
+    }
+    
+    private static void read(String dataName)
+    {
+        StreamManager.setGlobal(streamMgr) ;
+        Model m = ModelFactory.createDefaultModel() ;
+        WebReader2.read(m, dataName) ;
+        assertTrue(m.size() != 0 ) ;
+        StreamManager.setGlobal(streamMgrStd) ;
+    }
+}
+