jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [22/50] jena git commit: Add tests of duplicated quads in construct quad
Date Mon, 24 Aug 2015 08:13:31 GMT
Add tests of duplicated quads in construct quad

Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/54e48f3e
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/54e48f3e
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/54e48f3e

Branch: refs/heads/master
Commit: 54e48f3e8e3734d495bc399a2133eb9e25f24491
Parents: 03a321f
Author: confidencesun <confidence.sun@gmail.com>
Authored: Fri Aug 14 18:53:01 2015 +0800
Committer: confidencesun <confidence.sun@gmail.com>
Committed: Fri Aug 14 18:53:01 2015 +0800

----------------------------------------------------------------------
 .../org/apache/jena/sparql/api/TestAPI.java     | 36 +++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/54e48f3e/jena-arq/src/test/java/org/apache/jena/sparql/api/TestAPI.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/api/TestAPI.java b/jena-arq/src/test/java/org/apache/jena/sparql/api/TestAPI.java
index 5393cda..ecc576a 100644
--- a/jena-arq/src/test/java/org/apache/jena/sparql/api/TestAPI.java
+++ b/jena-arq/src/test/java/org/apache/jena/sparql/api/TestAPI.java
@@ -369,7 +369,7 @@ public class TestAPI extends BaseTest
         DatasetGraph expected = DatasetGraphFactory.createMem();
         expected.add(g1.asNode(), s.asNode(), p.asNode(), o.asNode());
         
-        assertEquals(1, count); // 3 duplicated quads
+        assertEquals(1, count); 
         assertTrue(IsoMatcher.isomorphic( expected, result) );
         
     }
@@ -414,6 +414,40 @@ public class TestAPI extends BaseTest
         assertTrue(dft.isIsomorphicWith(result));
     }
     
+    
+    // Allow duplicated quads in execConstructQuads()
+    @Test public void testARQConstructQuad_Duplicate_1() {
+        String queryString = "CONSTRUCT { GRAPH ?g1 {?s ?p ?o} } WHERE { ?s ?p ?o. GRAPH
?g1 {?s1 ?p1 ?o1} }";
+        Query q = QueryFactory.create(queryString, Syntax.syntaxARQ);
+        
+        QueryExecution qExec = QueryExecutionFactory.create(q, d);
+        
+        Iterator<Quad> ts = qExec.execConstructQuads();
+        long count = 0;
+        Quad expected = Quad.create( g1.asNode(), s.asNode(), p.asNode(), o.asNode());
+        while (ts.hasNext()) {
+            count++;
+            Quad qd = ts.next();
+            assertEquals(expected, qd);
+        }
+        assertEquals(3, count); // 3 duplicated quads
+    }
+    
+    // No duplicated quads in execConstructDataset()
+    @Test public void testARQConstructQuad_Duplicate_2() {
+        String queryString = "CONSTRUCT { GRAPH ?g1 {?s ?p ?o} } WHERE { ?s ?p ?o. GRAPH
?g1 {?s1 ?p1 ?o1} }";
+        Query q = QueryFactory.create(queryString, Syntax.syntaxARQ);
+        
+        QueryExecution qExec = QueryExecutionFactory.create(q, d);
+        
+        Dataset result = qExec.execConstructDataset();
+
+        DatasetGraph expected = DatasetGraphFactory.createMem();
+        expected.add(g1.asNode(), s.asNode(), p.asNode(), o.asNode());
+        assertEquals(1, result.asDatasetGraph().size());
+        assertTrue(IsoMatcher.isomorphic( expected, result.asDatasetGraph()) );
+    }
+    
     private QueryExecution makeQExec(String queryString)
     {
         Query q = QueryFactory.create(queryString) ;


Mime
View raw message