jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [1/2] jena git commit: JENA-1112: Build the new update correctly.
Date Fri, 08 Jan 2016 17:46:13 GMT
Repository: jena
Updated Branches:
  refs/heads/master 7a8548350 -> b1fd4f0b7


JENA-1112: Build the new update correctly.

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

Branch: refs/heads/master
Commit: b1fd4f0b78c6442787e05206069c934c8f05ee46
Parents: 7b31488
Author: Andy Seaborne <andy@apache.org>
Authored: Fri Jan 8 17:45:31 2016 +0000
Committer: Andy Seaborne <andy@apache.org>
Committed: Fri Jan 8 17:45:59 2016 +0000

----------------------------------------------------------------------
 .../syntaxtransform/UpdateTransformOps.java     |   1 +
 .../apache/jena/sparql/syntax/TS_Syntax.java    |   7 +-
 .../syntaxtransform/TestSubstitution.java       |  93 ------------
 .../syntaxtransform/TestSyntaxTransform.java    | 141 +++++++++++++++++++
 4 files changed, 145 insertions(+), 97 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/b1fd4f0b/jena-arq/src/main/java/org/apache/jena/sparql/syntax/syntaxtransform/UpdateTransformOps.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/syntax/syntaxtransform/UpdateTransformOps.java
b/jena-arq/src/main/java/org/apache/jena/sparql/syntax/syntaxtransform/UpdateTransformOps.java
index b3c7ddb..348e947 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/syntax/syntaxtransform/UpdateTransformOps.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/syntax/syntaxtransform/UpdateTransformOps.java
@@ -152,6 +152,7 @@ public class UpdateTransformOps {
 
             addAll(mod.getDeleteAcc(), del1) ;
             addAll(mod.getInsertAcc(), ins1) ;
+            mod.setElement(el2); 
             result = mod ;
         }
 

http://git-wip-us.apache.org/repos/asf/jena/blob/b1fd4f0b/jena-arq/src/test/java/org/apache/jena/sparql/syntax/TS_Syntax.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/syntax/TS_Syntax.java b/jena-arq/src/test/java/org/apache/jena/sparql/syntax/TS_Syntax.java
index c192e7e..b01904c 100644
--- a/jena-arq/src/test/java/org/apache/jena/sparql/syntax/TS_Syntax.java
+++ b/jena-arq/src/test/java/org/apache/jena/sparql/syntax/TS_Syntax.java
@@ -20,7 +20,7 @@ package org.apache.jena.sparql.syntax;
 
 import org.apache.jena.sparql.syntax.syntaxtransform.TestFlattenSyntax ;
 import org.apache.jena.sparql.syntax.syntaxtransform.TestQueryOps ;
-import org.apache.jena.sparql.syntax.syntaxtransform.TestSubstitution ;
+import org.apache.jena.sparql.syntax.syntaxtransform.TestSyntaxTransform ;
 import org.junit.runner.RunWith ;
 import org.junit.runners.Suite ;
 import org.junit.runners.Suite.SuiteClasses ;
@@ -29,9 +29,8 @@ import org.junit.runners.Suite.SuiteClasses ;
 @SuiteClasses( {
     TestSerialization.class
     , TestQueryOps.class
-    , TestSubstitution.class
+    , TestSyntaxTransform.class
     , TestFlattenSyntax.class
 })
-public class TS_Syntax {
 
-}
+public class TS_Syntax {}

http://git-wip-us.apache.org/repos/asf/jena/blob/b1fd4f0b/jena-arq/src/test/java/org/apache/jena/sparql/syntax/syntaxtransform/TestSubstitution.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/syntax/syntaxtransform/TestSubstitution.java
b/jena-arq/src/test/java/org/apache/jena/sparql/syntax/syntaxtransform/TestSubstitution.java
deleted file mode 100644
index f50b8f4..0000000
--- a/jena-arq/src/test/java/org/apache/jena/sparql/syntax/syntaxtransform/TestSubstitution.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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.sparql.syntax.syntaxtransform;
-
-import java.util.HashMap ;
-import java.util.Map ;
-
-import org.apache.jena.atlas.junit.BaseTest ;
-import org.junit.Test ;
-import org.apache.jena.graph.Node ;
-import org.apache.jena.query.Query ;
-import org.apache.jena.query.QueryFactory ;
-import org.apache.jena.sparql.core.Var ;
-import org.apache.jena.sparql.sse.SSE ;
-import org.apache.jena.sparql.syntax.syntaxtransform.QueryTransformOps ;
-import org.apache.jena.sparql.syntax.syntaxtransform.UpdateTransformOps ;
-import org.apache.jena.update.UpdateFactory ;
-import org.apache.jena.update.UpdateRequest ;
-
-/** Test of variable replaced by value */
-public class TestSubstitution extends BaseTest
-{
-    @Test public void subst_01() { testQuery("SELECT * { }", "SELECT * {}", "o", "1") ; }
-    
-    @Test public void subst_02() { testQuery("SELECT ?x { }", "SELECT ?x {}", "o", "1") ;
}
-
-    @Test public void subst_03() { testQuery("SELECT ?o { }", "SELECT (1 as ?o) {}", "o",
"1") ; }
-
-    @Test public void subst_04() { testQuery("SELECT (?o AS ?z) { }", "SELECT (1 AS ?z) {}",
"o", "1") ; }
-
-    @Test public void subst_05() { testQuery("SELECT (?o+2 AS ?z) { }", "SELECT (1+2 AS ?z)
{}", "o", "1") ; }
-
-    @Test public void subst_09() { testQuery("SELECT * {?s ?p ?o}", "SELECT * {?s ?p 1}",
"o", "1") ; }  
-    
-    @Test public void subst_10() { testQuery("SELECT * { SELECT ?o {} }", "SELECT * {{SELECT
(1 as ?o) {}}}", "o", "1") ; }
-    
-    @Test public void subst_11() { testQuery("SELECT * { ?s ?p ?o { SELECT ?x { ?x ?p ?o
} } }",
-                                             "SELECT * { ?s ?p 1  { SELECT ?x { ?x ?p 1 }
} }",
-                                             "o", "1") ; }
-
-    @Test public void subst_50() { testUpdate("DELETE { ?s <urn:p> ?x } WHERE {}",
-                                              "DELETE { ?s <urn:p> <urn:x> }
WHERE {}", "x", "<urn:x>") ; }
-
-    //static final String PREFIX = "PREFIX : <http://example/>\n" ;
-    static final String PREFIX = "" ;
-
-    private void testQuery(String input, String output, String varStr, String valStr)
-    {
-        Query q1 = QueryFactory.create(PREFIX+input) ;
-        Query qExpected = QueryFactory.create(PREFIX+output) ;
-        
-        Map<Var, Node> map = new HashMap<Var, Node>() ;
-        map.put(Var.alloc(varStr), SSE.parseNode(valStr)) ;
-        
-        Query qTrans = QueryTransformOps.transform(q1, map) ;
-        assertEquals(qExpected, qTrans) ;
-    }
-
-    private void testUpdate(String input, String output, String varStr, String valStr)
-    {
-        UpdateRequest req1 = UpdateFactory.create(PREFIX+input) ;
-        UpdateRequest reqExpected = UpdateFactory.create(PREFIX+output) ;
-        
-        Map<Var, Node> map = new HashMap<Var, Node>() ;
-        map.put(Var.alloc(varStr), SSE.parseNode(valStr)) ;
-        
-        UpdateRequest reqTrans = UpdateTransformOps.transform(req1, map) ;
-        
-        // Crude.
-        String x1 = reqExpected.toString().replaceAll("[ \n\t]", "") ;
-        String x2 = reqTrans.toString().replaceAll("[ \n\t]", "") ;
-        //assertEquals(reqExpected, reqTrans) ;
-        assertEquals(x1, x2) ;
-    }
-    
-}
-

http://git-wip-us.apache.org/repos/asf/jena/blob/b1fd4f0b/jena-arq/src/test/java/org/apache/jena/sparql/syntax/syntaxtransform/TestSyntaxTransform.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/syntax/syntaxtransform/TestSyntaxTransform.java
b/jena-arq/src/test/java/org/apache/jena/sparql/syntax/syntaxtransform/TestSyntaxTransform.java
new file mode 100644
index 0000000..c09f0fe
--- /dev/null
+++ b/jena-arq/src/test/java/org/apache/jena/sparql/syntax/syntaxtransform/TestSyntaxTransform.java
@@ -0,0 +1,141 @@
+/*
+ * 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.sparql.syntax.syntaxtransform;
+
+import java.util.HashMap ;
+import java.util.Map ;
+
+import org.apache.jena.atlas.junit.BaseTest ;
+import org.junit.Test ;
+import org.apache.jena.graph.Node ;
+import org.apache.jena.query.Query ;
+import org.apache.jena.query.QueryFactory ;
+import org.apache.jena.sparql.core.Var ;
+import org.apache.jena.sparql.sse.SSE ;
+import org.apache.jena.sparql.syntax.syntaxtransform.QueryTransformOps ;
+import org.apache.jena.sparql.syntax.syntaxtransform.UpdateTransformOps ;
+import org.apache.jena.update.UpdateFactory ;
+import org.apache.jena.update.UpdateRequest ;
+
+/** Test of variable replaced by value */
+public class TestSyntaxTransform extends BaseTest
+{
+    @Test public void subst_query_01() {
+        testQuery("SELECT * { }", 
+                  "SELECT * {}", 
+                  "o", "1");
+    }
+
+    @Test public void subst_query_02() { 
+        testQuery("SELECT ?x { }", 
+                  "SELECT ?x {}",
+                  "o", "1") ;
+    }
+
+    @Test public void subst_query_03() {
+        testQuery("SELECT ?o { }", 
+                  "SELECT (1 as ?o) {}", 
+                  "o", "1") ; }
+
+    @Test public void subst_query_04() {
+        testQuery("SELECT (?o AS ?z) { }",
+                  "SELECT (1 AS ?z) {}",
+                  "o", "1") ; }
+
+    @Test public void subst_query_05() {
+        testQuery("SELECT (?o+2 AS ?z) { }", 
+                  "SELECT (1+2 AS ?z) {}",
+                  "o", "1");
+    }
+
+    @Test public void subst_query_09() {
+        testQuery("SELECT * {?s ?p ?o}", 
+                  "SELECT * {?s ?p 1}",
+                  "o", "1");
+    }
+
+    @Test public void subst_query_10() {
+        testQuery("SELECT * { SELECT ?o {} }", 
+                  "SELECT * {{SELECT (1 as ?o) {}}}",
+                  "o", "1");
+    }
+
+    @Test public void subst_query_11() { testQuery
+        ("SELECT * { ?s ?p ?o { SELECT ?x { ?x ?p ?o } } }",
+         "SELECT * { ?s ?p 1  { SELECT ?x { ?x ?p 1 } } }",
+         "o", "1") ; }
+
+    @Test public void subst_update_01() { 
+        testUpdate("DELETE { ?s <urn:p> ?x } WHERE {}", 
+                   "DELETE { ?s <urn:p> <urn:x> } WHERE {}",
+                   "x", "<urn:x>") ;
+    }
+
+    @Test public void subst_update_02() { 
+        testUpdate("DELETE { ?s <urn:p> ?x } WHERE { ?s <urn:p> ?x }", 
+                   "DELETE { ?s <urn:p> <urn:x> } WHERE { ?s <urn:p> <urn:x>
}",
+                   "x", "<urn:x>") ;
+    }
+
+    @Test public void subst_update_03() { 
+        testUpdate("DELETE { ?s <urn:p> ?x } INSERT { ?s <urn:p> ?x } WHERE {
?s <urn:p> ?x }", 
+                   "DELETE { ?s <urn:p> <urn:x> } INSERT { ?s <urn:p> <urn:x>
} WHERE { ?s <urn:p> <urn:x> }",
+                   "x", "<urn:x>") ;
+    }
+    
+    @Test public void subst_update_09() { 
+        testUpdate("DELETE WHERE { ?s <urn:p> ?x }", 
+                   "DELETE WHERE { ?s <urn:p> <urn:x> }",
+                   "x", "<urn:x>") ;
+    }
+
+    //static final String PREFIX = "PREFIX : <http://example/>\n" ;
+    static final String PREFIX = "" ;
+
+    private void testQuery(String input, String output, String varStr, String valStr)
+    {
+        Query q1 = QueryFactory.create(PREFIX+input) ;
+        Query qExpected = QueryFactory.create(PREFIX+output) ;
+        
+        Map<Var, Node> map = new HashMap<Var, Node>() ;
+        map.put(Var.alloc(varStr), SSE.parseNode(valStr)) ;
+        
+        Query qTrans = QueryTransformOps.transform(q1, map) ;
+        assertEquals(qExpected, qTrans) ;
+    }
+
+    private void testUpdate(String input, String output, String varStr, String valStr)
+    {
+        UpdateRequest req1 = UpdateFactory.create(PREFIX+input) ;
+        UpdateRequest reqExpected = UpdateFactory.create(PREFIX+output) ;
+        
+        Map<Var, Node> map = new HashMap<Var, Node>() ;
+        map.put(Var.alloc(varStr), SSE.parseNode(valStr)) ;
+        
+        UpdateRequest reqTrans = UpdateTransformOps.transform(req1, map) ;
+        
+        // Crude.
+        String x1 = reqExpected.toString().replaceAll("[ \n\t]", "") ;
+        String x2 = reqTrans.toString().replaceAll("[ \n\t]", "") ;
+        //assertEquals(reqExpected, reqTrans) ;
+        assertEquals(x1, x2) ;
+    }
+    
+}
+


Mime
View raw message