jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1467745 - in /jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/algebra/optimize: TestOptimizer.java TestVarRename.java
Date Sun, 14 Apr 2013 08:29:10 GMT
Author: andy
Date: Sun Apr 14 08:29:10 2013
New Revision: 1467745

URL: http://svn.apache.org/r1467745
Log:
Put all rename tests in the same place.

Modified:
    jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/algebra/optimize/TestOptimizer.java
    jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/algebra/optimize/TestVarRename.java

Modified: jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/algebra/optimize/TestOptimizer.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/algebra/optimize/TestOptimizer.java?rev=1467745&r1=1467744&r2=1467745&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/algebra/optimize/TestOptimizer.java
(original)
+++ jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/algebra/optimize/TestOptimizer.java
Sun Apr 14 08:29:10 2013
@@ -33,112 +33,6 @@ public class TestOptimizer extends BaseT
 {
     // A lot of the optimizer is tested by using the scripted queries.
     
-    @Test public void query_rename_01()
-    {
-        String queryString =  
-            "SELECT ?x { ?s ?p ?o . { SELECT ?v { ?x ?y ?v {SELECT ?w { ?a ?y ?w }}} LIMIT
50 } }" ;
-        String opExpectedString =
-            "(project (?x)\n" + 
-            "  (join\n" + 
-            "    (bgp (triple ?s ?p ?o))\n" + 
-            "    (slice _ 50\n" + 
-            "      (project (?v)\n" + 
-            "        (join\n" + 
-            "          (bgp (triple ?/x ?/y ?v))\n" + 
-            "          (project (?/w)\n" + 
-            "            (bgp (triple ?//a ?//y ?/w))))))))";
-        checkRename(queryString, opExpectedString) ;
-    }
-
-    @Test public void query_rename_02()
-    {
-        String queryString = 
-            "SELECT ?x { ?s ?p ?o . { SELECT ?v { ?x ?y ?v {SELECT * { ?a ?y ?w }}} LIMIT
50 } }"  ;  
-        String opExpectedString = 
-            "(project (?x)\n" + 
-            "  (join\n" + 
-            "    (bgp (triple ?s ?p ?o))\n" + 
-            "    (slice _ 50\n" + 
-            "      (project (?v)\n" + 
-            "        (join (bgp (triple ?/x ?/y ?v)) (bgp (triple ?/a ?/y ?/w))))" +
-            ")))" ; 
-        checkRename(queryString, opExpectedString) ;
-    }
-
-    @Test public void query_rename_03()
-    {
-        String queryString = "SELECT ?x { ?s ?p ?o . { SELECT * { ?x ?y ?v {SELECT ?w { ?a
?y ?w }}} LIMIT 50 } }" ;  
-        String opExpectedString = 
-            "(project (?x)\n" + 
-            "  (join\n" + 
-            "    (bgp (triple ?s ?p ?o))\n" + 
-            "    (slice _ 50\n" + 
-            "      (join\n" + 
-            "        (bgp (triple ?x ?y ?v))\n" + 
-            "        (project (?w)\n" + 
-            "          (bgp (triple ?/a ?/y ?w)))))))" ;
-        checkRename(queryString, opExpectedString) ;
-    }
-
-    @Test public void query_rename_04()
-    {
-        String queryString = "SELECT * { ?s ?p ?o . { SELECT ?v { ?x ?y ?v {SELECT ?w { ?a
?y ?w }}} LIMIT 50 } }" ;  
-        String opExpectedString = 
-            "(join\n" + 
-            "  (bgp (triple ?s ?p ?o))\n" + 
-            "  (slice _ 50\n" + 
-            "    (project (?v)\n" + 
-            "      (join\n" + 
-            "        (bgp (triple ?/x ?/y ?v))\n" + 
-            "        (project (?/w)\n" + 
-            "          (bgp (triple ?//a ?//y ?/w)))))))" ;
-        checkRename(queryString, opExpectedString) ;
-    }
-
-    @Test public void query_rename_05()
-    {
-        String queryString = "SELECT ?v { ?s ?p ?o . { SELECT ?v { ?x ?y ?v {SELECT ?w {
?a ?y ?w }}} LIMIT 50 } }"    ;  
-        String opExpectedString = 
-            "(project (?v)\n" + 
-            "  (join\n" + 
-            "    (bgp (triple ?s ?p ?o))\n" + 
-            "    (slice _ 50\n" + 
-            "      (project (?v)\n" + 
-            "        (join\n" + 
-            "          (bgp (triple ?/x ?/y ?v))\n" + 
-            "          (project (?/w)\n" + 
-            "            (bgp (triple ?//a ?//y ?/w))))))))" ;
-        checkRename(queryString, opExpectedString) ;
-    }
-
-    @Test public void query_rename_06()
-    {
-        String queryString = "SELECT ?w { ?s ?p ?o . { SELECT ?w { ?x ?y ?v {SELECT ?w {
?a ?y ?w }}} } } LIMIT 50" ;  
-        String opExpectedString = 
-            "(slice _ 50\n" + 
-            "  (project (?w)\n" + 
-            "    (join\n" + 
-            "      (bgp (triple ?s ?p ?o))\n" + 
-            "      (project (?w)\n" + 
-            "        (join\n" + 
-            "          (bgp (triple ?/x ?/y ?/v))\n" + 
-            "          (project (?w)\n" + 
-            "            (bgp (triple ?//a ?//y ?w))))))))\n" + 
-            "" ;
-        checkRename(queryString, opExpectedString) ;
-    }
-
-    @Test public void query_rename_07()
-    {
-        String queryString = "SELECT * { ?s ?p ?o . { SELECT ?w { ?x ?y ?v }}}"  ;  
-        String opExpectedString = 
-            "(join\n" + 
-            "  (bgp (triple ?s ?p ?o))\n" + 
-            "  (project (?w)\n" + 
-            "    (bgp (triple ?/x ?/y ?/v))))" ;
-        checkRename(queryString, opExpectedString) ;
-    }
-    
     @Test public void slice_order_to_topn_01()
     {
         assertTrue(ARQ.isTrueOrUndef(ARQ.optTopNSorting)) ;
@@ -322,17 +216,6 @@ public class TestOptimizer extends BaseT
         check(queryString, opExpectedString) ; 
     }
 
-    public static void checkRename(String queryString, String opExpectedString)
-    {
-        Op opExpected = SSE.parseOp(opExpectedString) ;
-        queryString = "PREFIX : <http://example/>\n"+queryString ;
-        Query query = QueryFactory.create(queryString) ;
-        Op op = Algebra.compile(query) ;
-        Op opRenamed = TransformScopeRename.transform(op) ;
-        assertEquals(opExpected, opRenamed) ;
-    }
-
-    
     public static void check(String queryString, String opExpectedString)
     {
         queryString = "PREFIX : <http://example/>\n"+queryString ;

Modified: jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/algebra/optimize/TestVarRename.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/algebra/optimize/TestVarRename.java?rev=1467745&r1=1467744&r2=1467745&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/algebra/optimize/TestVarRename.java
(original)
+++ jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/algebra/optimize/TestVarRename.java
Sun Apr 14 08:29:10 2013
@@ -25,6 +25,9 @@ import junit.framework.JUnit4TestAdapter
 import org.apache.jena.atlas.junit.BaseTest ;
 import org.junit.Test ;
 
+import com.hp.hpl.jena.query.Query ;
+import com.hp.hpl.jena.query.QueryFactory ;
+import com.hp.hpl.jena.sparql.algebra.Algebra ;
 import com.hp.hpl.jena.sparql.algebra.Op ;
 import com.hp.hpl.jena.sparql.core.Var ;
 import com.hp.hpl.jena.sparql.engine.Rename ;
@@ -115,4 +118,120 @@ public class TestVarRename extends BaseT
             assertEquals(opOrig, opRebuilt) ;
         }
     }
+    
+    @Test public void query_rename_01()
+    {
+        String queryString =  
+            "SELECT ?x { ?s ?p ?o . { SELECT ?v { ?x ?y ?v {SELECT ?w { ?a ?y ?w }}} LIMIT
50 } }" ;
+        String opExpectedString =
+            "(project (?x)\n" + 
+            "  (join\n" + 
+            "    (bgp (triple ?s ?p ?o))\n" + 
+            "    (slice _ 50\n" + 
+            "      (project (?v)\n" + 
+            "        (join\n" + 
+            "          (bgp (triple ?/x ?/y ?v))\n" + 
+            "          (project (?/w)\n" + 
+            "            (bgp (triple ?//a ?//y ?/w))))))))";
+        checkRename(queryString, opExpectedString) ;
+    }
+
+    @Test public void query_rename_02()
+    {
+        String queryString = 
+            "SELECT ?x { ?s ?p ?o . { SELECT ?v { ?x ?y ?v {SELECT * { ?a ?y ?w }}} LIMIT
50 } }"  ;  
+        String opExpectedString = 
+            "(project (?x)\n" + 
+            "  (join\n" + 
+            "    (bgp (triple ?s ?p ?o))\n" + 
+            "    (slice _ 50\n" + 
+            "      (project (?v)\n" + 
+            "        (join (bgp (triple ?/x ?/y ?v)) (bgp (triple ?/a ?/y ?/w))))" +
+            ")))" ; 
+        checkRename(queryString, opExpectedString) ;
+    }
+
+    @Test public void query_rename_03()
+    {
+        String queryString = "SELECT ?x { ?s ?p ?o . { SELECT * { ?x ?y ?v {SELECT ?w { ?a
?y ?w }}} LIMIT 50 } }" ;  
+        String opExpectedString = 
+            "(project (?x)\n" + 
+            "  (join\n" + 
+            "    (bgp (triple ?s ?p ?o))\n" + 
+            "    (slice _ 50\n" + 
+            "      (join\n" + 
+            "        (bgp (triple ?x ?y ?v))\n" + 
+            "        (project (?w)\n" + 
+            "          (bgp (triple ?/a ?/y ?w)))))))" ;
+        checkRename(queryString, opExpectedString) ;
+    }
+
+    @Test public void query_rename_04()
+    {
+        String queryString = "SELECT * { ?s ?p ?o . { SELECT ?v { ?x ?y ?v {SELECT ?w { ?a
?y ?w }}} LIMIT 50 } }" ;  
+        String opExpectedString = 
+            "(join\n" + 
+            "  (bgp (triple ?s ?p ?o))\n" + 
+            "  (slice _ 50\n" + 
+            "    (project (?v)\n" + 
+            "      (join\n" + 
+            "        (bgp (triple ?/x ?/y ?v))\n" + 
+            "        (project (?/w)\n" + 
+            "          (bgp (triple ?//a ?//y ?/w)))))))" ;
+        checkRename(queryString, opExpectedString) ;
+    }
+
+    @Test public void query_rename_05()
+    {
+        String queryString = "SELECT ?v { ?s ?p ?o . { SELECT ?v { ?x ?y ?v {SELECT ?w {
?a ?y ?w }}} LIMIT 50 } }"    ;  
+        String opExpectedString = 
+            "(project (?v)\n" + 
+            "  (join\n" + 
+            "    (bgp (triple ?s ?p ?o))\n" + 
+            "    (slice _ 50\n" + 
+            "      (project (?v)\n" + 
+            "        (join\n" + 
+            "          (bgp (triple ?/x ?/y ?v))\n" + 
+            "          (project (?/w)\n" + 
+            "            (bgp (triple ?//a ?//y ?/w))))))))" ;
+        checkRename(queryString, opExpectedString) ;
+    }
+
+    @Test public void query_rename_06()
+    {
+        String queryString = "SELECT ?w { ?s ?p ?o . { SELECT ?w { ?x ?y ?v {SELECT ?w {
?a ?y ?w }}} } } LIMIT 50" ;  
+        String opExpectedString = 
+            "(slice _ 50\n" + 
+            "  (project (?w)\n" + 
+            "    (join\n" + 
+            "      (bgp (triple ?s ?p ?o))\n" + 
+            "      (project (?w)\n" + 
+            "        (join\n" + 
+            "          (bgp (triple ?/x ?/y ?/v))\n" + 
+            "          (project (?w)\n" + 
+            "            (bgp (triple ?//a ?//y ?w))))))))\n" + 
+            "" ;
+        checkRename(queryString, opExpectedString) ;
+    }
+
+    @Test public void query_rename_07()
+    {
+        String queryString = "SELECT * { ?s ?p ?o . { SELECT ?w { ?x ?y ?v }}}"  ;  
+        String opExpectedString = 
+            "(join\n" + 
+            "  (bgp (triple ?s ?p ?o))\n" + 
+            "  (project (?w)\n" + 
+            "    (bgp (triple ?/x ?/y ?/v))))" ;
+        checkRename(queryString, opExpectedString) ;
+    }
+    
+    static void checkRename(String queryString, String opExpectedString)
+    {
+        Op opExpected = SSE.parseOp(opExpectedString) ;
+        queryString = "PREFIX : <http://example/>\n"+queryString ;
+        Query query = QueryFactory.create(queryString) ;
+        Op op = Algebra.compile(query) ;
+        Op opRenamed = TransformScopeRename.transform(op) ;
+        assertEquals(opExpected, opRenamed) ;
+    }
 }



Mime
View raw message