jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From casta...@apache.org
Subject svn commit: r1179770 - in /incubator/jena/Jena2/ARQ/trunk: src/main/java/org/openjena/riot/ src/main/java/org/openjena/riot/out/ src/test/java/org/openjena/riot/ src/test/java/org/openjena/riot/lang/ testing/RIOT/RDF-JSON/
Date Thu, 06 Oct 2011 19:00:41 GMT
Author: castagna
Date: Thu Oct  6 19:00:40 2011
New Revision: 1179770

URL: http://svn.apache.org/viewvc?rev=1179770&view=rev
Log:
JENA-127 - Manifest-controlled tests, patch from Andy. (Thanks, why not to commit directly
to SVN? So long we put the JIRA issue on the comment, people working on an issue will not
miss it). Also, a first skeleton of an RDF/JSON writer.

Added:
    incubator/jena/Jena2/ARQ/trunk/src/main/java/org/openjena/riot/out/RDFJSONWriter.java
  (with props)
    incubator/jena/Jena2/ARQ/trunk/src/main/java/org/openjena/riot/out/SinkEntityOutput.java
  (with props)
    incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/FactoryTestRDFJSONFactory.java
  (with props)
    incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/TestSuiteRDFJSON.java
  (with props)
    incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/UnitTestRDFJSON.java
  (with props)
    incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/UnitTestRDFJSONBadSyntax.java
  (with props)
    incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/UnitTestRDFJSONSyntax.java
  (with props)
    incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/
    incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-00.nt
    incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-00.rj
    incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-90.nt
    incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-90.rj
    incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-91.rdf
    incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-91.rj
    incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-bad-01.rj
    incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-bad-02.rj
Modified:
    incubator/jena/Jena2/ARQ/trunk/src/main/java/org/openjena/riot/RiotWriter.java
    incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/TS_Riot.java

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/org/openjena/riot/RiotWriter.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/org/openjena/riot/RiotWriter.java?rev=1179770&r1=1179769&r2=1179770&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/org/openjena/riot/RiotWriter.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/org/openjena/riot/RiotWriter.java Thu Oct
 6 19:00:40 2011
@@ -22,6 +22,7 @@ import java.io.OutputStream ;
 
 import org.openjena.riot.out.NQuadsWriter ;
 import org.openjena.riot.out.NTriplesWriter ;
+import org.openjena.riot.out.RDFJSONWriter ;
 
 import com.hp.hpl.jena.graph.Graph ;
 import com.hp.hpl.jena.sparql.core.DatasetGraph ;
@@ -41,5 +42,10 @@ public class RiotWriter
     {
         NTriplesWriter.write(out, graph) ;
     }
-
+
+    public static void writeRDFJSON(OutputStream out, Graph graph)
+    {
+    	RDFJSONWriter.write(out, graph) ;
+    }
+
 }

Added: incubator/jena/Jena2/ARQ/trunk/src/main/java/org/openjena/riot/out/RDFJSONWriter.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/org/openjena/riot/out/RDFJSONWriter.java?rev=1179770&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/org/openjena/riot/out/RDFJSONWriter.java
(added)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/org/openjena/riot/out/RDFJSONWriter.java
Thu Oct  6 19:00:40 2011
@@ -0,0 +1,75 @@
+/**
+ * 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.openjena.riot.out;
+
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.openjena.atlas.lib.Pair;
+import org.openjena.atlas.lib.Sink;
+import org.openjena.riot.system.Prologue;
+import org.openjena.riot.system.SyntaxLabels;
+
+import com.hp.hpl.jena.graph.Graph;
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.graph.Triple;
+import com.hp.hpl.jena.graph.query.QueryHandler;
+import com.hp.hpl.jena.util.iterator.ExtendedIterator;
+
+public class RDFJSONWriter {
+
+	public static void write (OutputStream out, Graph graph) {
+        Prologue prologue = Prologue.create(null, null) ; // (null, graph.getPrefixMapping())
;
+		Sink<Pair<Node, Map<Node, Set<Node>>>> sink = new SinkEntityOutput(out,
prologue, SyntaxLabels.createNodeToLabel()) ;
+
+		QueryHandler queryHandler = graph.queryHandler() ;
+		ExtendedIterator<Node> subjects = queryHandler.subjectsFor(Node.ANY, Node.ANY) ;
+		try {
+			Map<Node, Set<Node>> predicates = new HashMap<Node, Set<Node>>()
;
+			while ( subjects.hasNext() ) {
+				Node subject = subjects.next() ;
+				ExtendedIterator<Triple> triples = graph.find(subject, Node.ANY, Node.ANY) ;
+				try {
+					while ( triples.hasNext() ) {
+						Triple triple = triples.next() ;
+						Node p = triple.getPredicate() ;
+						if ( predicates.containsKey(p) ) {
+							predicates.get(p).add(triple.getObject()) ; 
+						} else {
+							Set<Node> objects = new HashSet<Node>() ;
+							objects.add(triple.getObject()) ;
+							predicates.put(p, objects) ;
+						}
+					}				
+				} finally {
+					if ( triples != null ) triples.close() ;
+				}
+				sink.send(new Pair<Node, Map<Node, Set<Node>>>(subject, predicates))
;
+				predicates.clear() ;
+			}			
+		} finally {
+			if ( subjects != null ) subjects.close() ;
+			sink.close() ;
+		}		
+	}
+
+}

Propchange: incubator/jena/Jena2/ARQ/trunk/src/main/java/org/openjena/riot/out/RDFJSONWriter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/jena/Jena2/ARQ/trunk/src/main/java/org/openjena/riot/out/SinkEntityOutput.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/org/openjena/riot/out/SinkEntityOutput.java?rev=1179770&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/org/openjena/riot/out/SinkEntityOutput.java
(added)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/org/openjena/riot/out/SinkEntityOutput.java
Thu Oct  6 19:00:40 2011
@@ -0,0 +1,90 @@
+/**
+ * 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.openjena.riot.out;
+
+import java.io.OutputStream;
+import java.util.Map;
+import java.util.Set;
+
+import org.openjena.atlas.json.io.JSWriter;
+import org.openjena.atlas.lib.Pair;
+import org.openjena.atlas.lib.Sink;
+import org.openjena.riot.system.Prologue;
+import org.openjena.riot.system.SyntaxLabels;
+
+import com.hp.hpl.jena.graph.Node;
+
+public class SinkEntityOutput implements Sink<Pair<Node, Map<Node, Set<Node>>>>
{
+
+    private Prologue prologue = null ;
+    private JSWriter out ;
+    private NodeToLabel labelPolicy = null ;
+	
+    public SinkEntityOutput(OutputStream outs)
+    {
+        this(outs, null, SyntaxLabels.createNodeToLabel()) ;
+    }
+    
+    public SinkEntityOutput(OutputStream outs, Prologue prologue, NodeToLabel labels)
+    {
+    	out = new JSWriter(outs) ;
+    	setPrologue(prologue) ;
+    	setLabelPolicy(labels) ;
+    	out.startOutput() ;
+    	out.startArray() ;
+    }
+
+    public void setPrologue(Prologue prologue)
+    {
+    	this.prologue = prologue ;
+    }
+
+    public void setLabelPolicy(NodeToLabel labels)
+    {
+    	this.labelPolicy = labels ;
+    }
+
+    //@Override
+	public void send(Pair<Node, Map<Node, Set<Node>>> item) {
+		Node s = item.getLeft() ;
+		// out.pair(key, value) ;
+		Map<Node, Set<Node>> predicates = item.getRight() ;
+		for (Node p : predicates.keySet() ) {
+			Set<Node> objects = predicates.get(p) ;
+			out.startArray() ;
+			for ( Node o : objects ) {
+				// out.arrayElement(o) ;
+				// TODO
+			}
+			out.finishArray() ;
+		}
+	}
+
+    //@Override
+	public void flush() {
+		out.finishArray() ;
+		out.finishOutput();
+	}
+	
+    //@Override
+	public void close() {
+		flush() ;
+	}
+
+}

Propchange: incubator/jena/Jena2/ARQ/trunk/src/main/java/org/openjena/riot/out/SinkEntityOutput.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/TS_Riot.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/TS_Riot.java?rev=1179770&r1=1179769&r2=1179770&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/TS_Riot.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/TS_Riot.java Thu Oct  6
19:00:40 2011
@@ -22,18 +22,7 @@ import org.junit.AfterClass ;
 import org.junit.BeforeClass ;
 import org.junit.runner.RunWith ;
 import org.junit.runners.Suite ;
-import org.openjena.riot.lang.TestIRI ;
-import org.openjena.riot.lang.TestLang ;
-import org.openjena.riot.lang.TestLangNQuads ;
-import org.openjena.riot.lang.TestLangNTriples ;
-import org.openjena.riot.lang.TestLangRdfJson ;
-import org.openjena.riot.lang.TestLangTrig ;
-import org.openjena.riot.lang.TestLangTurtle ;
-import org.openjena.riot.lang.TestNodeAllocator ;
-import org.openjena.riot.lang.TestParserFactory ;
-import org.openjena.riot.lang.TestSuiteTrig ;
-import org.openjena.riot.lang.TestSuiteTurtle ;
-import org.openjena.riot.lang.TestTurtleTerms ;
+import org.openjena.riot.lang.* ;
 import org.openjena.riot.out.TestNodeFmt ;
 import org.openjena.riot.out.TestNodeFmtLib ;
 import org.openjena.riot.out.TestOutput ;
@@ -64,6 +53,7 @@ import org.openjena.riot.tokens.TestToke
     , TestSuiteTrig.class
 
     , TestLangRdfJson.class
+    , TestSuiteRDFJSON.class
     
     , TestParserFactory.class
 

Added: incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/FactoryTestRDFJSONFactory.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/FactoryTestRDFJSONFactory.java?rev=1179770&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/FactoryTestRDFJSONFactory.java
(added)
+++ incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/FactoryTestRDFJSONFactory.java
Thu Oct  6 19:00:40 2011
@@ -0,0 +1,102 @@
+/**
+ * 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.openjena.riot.lang ;
+
+import junit.framework.Test ;
+import junit.framework.TestSuite ;
+import org.openjena.riot.TestVocabRIOT ;
+
+import com.hp.hpl.jena.rdf.model.Resource ;
+import com.hp.hpl.jena.sparql.vocabulary.VocabTestQuery ;
+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 FactoryTestRDFJSONFactory extends TestFactoryManifest
+{
+
+    public static TestSuite make(String manifest, Resource dftTestType, String labelPrefix)
+    {
+        return new FactoryTestRDFJSONFactory(dftTestType, labelPrefix).process(manifest)
;
+    }
+
+    private Resource dftTestType ;
+    private String labelPrefix ;
+
+    public FactoryTestRDFJSONFactory(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 ( labelPrefix != null )
+                testName = labelPrefix+testName ;
+            
+            Resource input = TestUtils.getResource(action, VocabTestQuery.data) ;
+            Resource output = result ; 
+//            // Convert baseIRI.
+//            Resource inputIRIr = TestUtils.getResource(action, TestVocabRIOT.inputIRI)
;
+//            String baseIRI = (inputIRIr == null) ? null : inputIRIr.getURI() ;
+            // !!
+            
+            String baseIRI = TestVocabRIOT.assumedBaseURI ;
+            String x = input.getLocalName() ;
+            // Yuk, yuk, yuk.
+            baseIRI = baseIRI+x ;
+
+            if (r.equals(TestVocabRIOT.TestInOut))
+            {
+                return new UnitTestRDFJSON(testName, input.getURI(), output.getURI(), baseIRI)
;
+            }
+
+            if (r.equals(TestVocabRIOT.TestSyntax))
+            {
+                return new UnitTestRDFJSONSyntax(testName, input.getURI()) ;
+            }
+
+            if (r.equals(TestVocabRIOT.TestBadSyntax))
+            {
+                return new UnitTestRDFJSONBadSyntax(testName, input.getURI()) ;
+            }
+
+            // if ( r.equals(TestVocabRIOT.TestSurpeessed ))
+            // return new TestSupressed(testName, null) ;
+
+            System.err.println("Unrecognized RDF/JSON test : " + testName) ;
+            return null ;
+
+        } catch (Exception ex)
+        {
+            ex.printStackTrace(System.err) ;
+            System.err.println("Failed to grok test : " + testName) ;
+            return null ;
+        }
+    }
+
+}

Propchange: incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/FactoryTestRDFJSONFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/TestSuiteRDFJSON.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/TestSuiteRDFJSON.java?rev=1179770&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/TestSuiteRDFJSON.java
(added)
+++ incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/TestSuiteRDFJSON.java
Thu Oct  6 19:00:40 2011
@@ -0,0 +1,42 @@
+/**
+ * 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.openjena.riot.lang;
+
+
+import junit.framework.TestSuite ;
+import org.junit.runner.RunWith ;
+import org.junit.runners.AllTests ;
+import org.openjena.riot.TestVocabRIOT ;
+
+@RunWith(AllTests.class)
+public class TestSuiteRDFJSON extends TestSuite
+{
+    private static final String manifest1 = "testing/RIOT/RDF-JSON/manifest.ttl" ;
+    private static final String manifest2 = "testing/RIOT/RDF-JSON/manifest-bad.ttl" ;
+    
+    static public TestSuite suite()
+    {
+        TestSuite ts = new TestSuite("RDFJSON") ;
+        // The good ..
+        ts.addTest(FactoryTestRDFJSONFactory.make(manifest1, TestVocabRIOT.TestInOut, "RDF/JSON-"))
;
+        // .. the bad ...
+        ts.addTest(FactoryTestRDFJSONFactory.make(manifest2, TestVocabRIOT.TestBadSyntax,
"RDF/JSON-")) ;
+        return ts ;
+    }
+}

Propchange: incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/TestSuiteRDFJSON.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/UnitTestRDFJSON.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/UnitTestRDFJSON.java?rev=1179770&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/UnitTestRDFJSON.java
(added)
+++ incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/UnitTestRDFJSON.java
Thu Oct  6 19:00:40 2011
@@ -0,0 +1,90 @@
+/**
+ * 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.openjena.riot.lang;
+
+
+import java.io.InputStream ;
+import java.io.Reader ;
+
+import junit.framework.TestCase ;
+import org.openjena.atlas.io.PeekReader ;
+import org.openjena.riot.RiotParseException ;
+import org.openjena.riot.SysRIOT ;
+import org.openjena.riot.system.JenaReaderRdfJson ;
+
+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.FileManager ;
+
+public class UnitTestRDFJSON extends TestCase
+{
+    static { SysRIOT.wireIntoJena() ; }
+    String input ;
+    String output ;
+    String baseIRI ;
+    
+    public UnitTestRDFJSON(String name, String input, String output, String baseIRI)
+    {
+        super(name) ;
+        this.input = input ;
+        this.output = output ;
+        this.baseIRI = baseIRI ;
+    }
+    
+    @Override
+    public void runTest()
+    {
+        Model model = ModelFactory.createDefaultModel() ;
+        RDFReader t = new JenaReaderRdfJson() ;
+        try {
+            if ( baseIRI != null )
+            {
+                InputStream in =  FileManager.get().open(input) ;
+                Reader r = PeekReader.makeUTF8(in) ;
+                t.read(model, r, baseIRI) ;
+            }
+            else
+                t.read(model, input) ;  
+
+            Model results = FileManager.get().loadModel(output) ;
+
+            boolean b = model.isIsomorphicWith(results) ;
+            if ( !b )
+            {
+                model.isIsomorphicWith(results) ;
+//                System.out.println("---- Parsed");
+//                model.write(System.out, "RDF/JSON") ;
+//                System.out.println("---- Expected");
+//                results.write(System.out, "RDF/JSON") ;
+//                System.out.println("--------");
+            }
+            
+            assertTrue("Models not isomorphic", b) ;
+        } catch (RiotParseException ex)
+        {
+            // Catch and retrhow - debugging.
+            throw ex ;    
+        }
+        catch (RuntimeException ex) 
+        { 
+            ex.printStackTrace(System.err) ;
+            throw ex ; }
+    }
+}

Propchange: incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/UnitTestRDFJSON.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/UnitTestRDFJSONBadSyntax.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/UnitTestRDFJSONBadSyntax.java?rev=1179770&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/UnitTestRDFJSONBadSyntax.java
(added)
+++ incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/UnitTestRDFJSONBadSyntax.java
Thu Oct  6 19:00:40 2011
@@ -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.openjena.riot.lang;
+
+import java.io.InputStream ;
+
+import junit.framework.TestCase ;
+import org.openjena.atlas.io.IO ;
+import org.openjena.atlas.lib.SinkNull ;
+import org.openjena.riot.RiotException ;
+import org.openjena.riot.RiotReader ;
+
+import com.hp.hpl.jena.graph.Triple ;
+
+
+public class UnitTestRDFJSONBadSyntax extends TestCase
+{
+    String uri ;
+    public UnitTestRDFJSONBadSyntax(String name, String uri) { super(name) ; this.uri = uri
; }
+    
+    @Override
+    public void runTest()
+    {
+        InputStream in = IO.openFile(uri) ;
+        assertNotNull(in) ;
+        LangRIOT parser = RiotReader.createParserRdfJson(in, new SinkNull<Triple>())
;
+        try {
+            parser.parse() ;
+        } catch (RiotException ex) { return ; }
+        fail("Bad syntax RDF/JSON test succeed in parsing the file") ;
+    }
+}

Propchange: incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/UnitTestRDFJSONBadSyntax.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/UnitTestRDFJSONSyntax.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/UnitTestRDFJSONSyntax.java?rev=1179770&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/UnitTestRDFJSONSyntax.java
(added)
+++ incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/UnitTestRDFJSONSyntax.java
Thu Oct  6 19:00:40 2011
@@ -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.openjena.riot.lang;
+
+import junit.framework.TestCase ;
+import org.openjena.riot.RiotParseException ;
+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 ;
+
+
+public class UnitTestRDFJSONSyntax extends TestCase
+{
+    String uri ;
+    public UnitTestRDFJSONSyntax(String name, String uri) { super(name) ; this.uri = uri
; }
+    
+    @Override
+    public void runTest()
+    {
+        Model model = ModelFactory.createDefaultModel() ;
+        RDFReader t = new JenaReaderTurtle2() ;
+        try {
+            t.read(model, uri) ;
+        } catch (RiotParseException ex)
+        {
+            throw ex ;    
+        }
+    }
+
+}

Propchange: incubator/jena/Jena2/ARQ/trunk/src/test/java/org/openjena/riot/lang/UnitTestRDFJSONSyntax.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-00.nt
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-00.nt?rev=1179770&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-00.nt (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-00.nt Thu Oct  6 19:00:40
2011
@@ -0,0 +1 @@
+#Empty

Added: incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-00.rj
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-00.rj?rev=1179770&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-00.rj (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-00.rj Thu Oct  6 19:00:40
2011
@@ -0,0 +1,3 @@
+#Empty
+{
+}

Added: incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-90.nt
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-90.nt?rev=1179770&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-90.nt (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-90.nt Thu Oct  6 19:00:40
2011
@@ -0,0 +1 @@
+<http://example.org/about> <http://purl.org/dc/elements/1.1/title> "Anna's Homepage"
.

Added: incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-90.rj
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-90.rj?rev=1179770&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-90.rj (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-90.rj Thu Oct  6 19:00:40
2011
@@ -0,0 +1,6 @@
+{
+  "http://example.org/about" : 
+    {
+       "http://purl.org/dc/elements/1.1/title": [ { "type" : "literal" , "value" : "Anna's
Homepage" } ]
+    }
+}

Added: incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-91.rdf
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-91.rdf?rev=1179770&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-91.rdf (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-91.rdf Thu Oct  6 19:00:40
2011
@@ -0,0 +1,20 @@
+<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+	 xmlns:foaf="http://xmlns.com/foaf/0.1/"
+	 xmlns:dc="http://purl.org/dc/elements/1.1/">
+  <rdf:Description rdf:about="http://example.org/about">
+    <dc:creator>Anna Wilder</dc:creator>
+    <dc:title xml:lang="en">Anna's Homepage</dc:title>
+    <foaf:maker rdf:nodeID="person" />
+  </rdf:Description>
+  <rdf:Description rdf:nodeID="person">
+    <foaf:homepage rdf:resource="http://example.org/about" />
+    <foaf:made rdf:resource="http://example.org/about" />
+    <foaf:name>Anna Wilder</foaf:name>
+    <foaf:firstName>Anna</foaf:firstName>
+    <foaf:surname>Wilder</foaf:surname>
+    <foaf:depiction rdf:resource="http://example.org/pic.jpg" />
+    <foaf:nick>wildling</foaf:nick>
+    <foaf:nick>wilda</foaf:nick>
+    <foaf:mbox_sha1sum>69e31bbcf58d432950127593e292a55975bc66fd</foaf:mbox_sha1sum>
+  </rdf:Description>
+</rdf:RDF>
\ No newline at end of file

Added: incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-91.rj
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-91.rj?rev=1179770&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-91.rj (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-91.rj Thu Oct  6 19:00:40
2011
@@ -0,0 +1,21 @@
+{
+    "http://example.org/about" : {
+        "http://purl.org/dc/elements/1.1/creator" : [ { "value" : "Anna Wilder", "type" :
"literal" } ],
+        "http://purl.org/dc/elements/1.1/title"   : [ { "value" : "Anna's Homepage", "type"
: "literal", "lang" : "en" } ] ,
+        "http://xmlns.com/foaf/0.1/maker"         : [ { "value" : "_:person", "type" : "bnode"
} ]
+    } ,
+ 
+    "_:person" : {
+        "http://xmlns.com/foaf/0.1/homepage"      : [ { "value" : "http://example.org/about",
"type" : "uri" } ] ,
+        "http://xmlns.com/foaf/0.1/made"          : [ { "value" : "http://example.org/about",
"type" : "uri" } ] ,
+        "http://xmlns.com/foaf/0.1/name"          : [ { "value" : "Anna Wilder", "type" :
"literal" } ] ,
+        "http://xmlns.com/foaf/0.1/firstName"     : [ { "value" : "Anna", "type" : "literal"
} ] ,
+        "http://xmlns.com/foaf/0.1/surname"       : [ { "value" : "Wilder", "type" : "literal"
} ] , 
+        "http://xmlns.com/foaf/0.1/depiction"     : [ { "value" : "http://example.org/pic.jpg",
"type" : "uri" } ] ,
+        "http://xmlns.com/foaf/0.1/nick"          : [ 
+                                                      { "type" : "literal", "value" : "wildling"}
, 
+                                                      { "type" : "literal", "value" : "wilda"
} 
+                                                    ] ,
+        "http://xmlns.com/foaf/0.1/mbox_sha1sum"  : [ {  "value" : "69e31bbcf58d432950127593e292a55975bc66fd",
"type" : "literal" } ] 
+    }
+}

Added: incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-bad-01.rj
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-bad-01.rj?rev=1179770&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-bad-01.rj (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-bad-01.rj Thu Oct  6 19:00:40
2011
@@ -0,0 +1,4 @@
+{
+  "http://example.org/about" : "foo"
+}
+

Added: incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-bad-02.rj
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-bad-02.rj?rev=1179770&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-bad-02.rj (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/RIOT/RDF-JSON/rdf-json-bad-02.rj Thu Oct  6 19:00:40
2011
@@ -0,0 +1,7 @@
+{
+  "http://example.org/about" : 
+  {
+      "http://example.org/predicate" : 1234 
+  }
+}
+



Mime
View raw message