Author: rvesse
Date: Mon Apr 29 17:29:07 2013
New Revision: 1477219

URL: http://svn.apache.org/r1477219
Log:
New test case that demonstrates that some uses of sub-queries will result in 
algebra that cannot round trip back to the original query (JENA-445)

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

Modified: 
jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/algebra/TestOpAsQuery.java
URL: 
http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/algebra/TestOpAsQuery.java?rev=1477219&r1=1477218&r2=1477219&view=diff
==============================================================================
--- 
jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/algebra/TestOpAsQuery.java
 (original)
+++ 
jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/algebra/TestOpAsQuery.java
 Mon Apr 29 17:29:07 2013
@@ -210,6 +210,14 @@ public class TestOpAsQuery {
     }
     
     @Test
+    public void testSubQuery3() {
+        String query = "SELECT * WHERE { { SELECT ?s ?p WHERE { ?s ?p ?o } } { 
SELECT ?x WHERE { ?x ?p ?o } } }";
+        //In this case there is insufficient information to correctly reverse 
translate the algebra so this query
+        //will not round trip
+        checkQueryNonRecoverable(query);
+    }
+    
+    @Test
     public void testAggregatesInSubQuery1() {
         //Simplified form of a test case provided via the mailing list
         String query = "SELECT ?key ?agg WHERE { { SELECT ?key (COUNT(*) AS 
?agg) { ?key ?p ?o } GROUP BY ?key } }";
@@ -279,6 +287,24 @@ public class TestOpAsQuery {
         return r;
     }
     
+    public Query[] checkQueryNonRecoverable(String query) {
+        Query[] r = checkQuery(query);
+        
+        // Strip namespaces and Base URI from each so comparison is not 
affected by those
+        stripNamespacesAndBase(r[0]);
+        stripNamespacesAndBase(r[1]);
+        
+        // If this method is being called then we expect the strings to be 
non-equal and also
+        // the algebras to be non-equivalent because there will be 
insufficient information
+        // in the algebra to allow it to be translated back into a 
semantically equivalent query
+        Assert.assertNotEquals(r[0], r[1]);
+        Op a1 = Algebra.compile(r[0]);
+        Op a2 = Algebra.compile(r[1]);
+        Assert.assertNotEquals(a1, a2);
+        
+        return r;
+    }
+    
     protected void stripNamespacesAndBase(Query q) {
         Map<String, String> prefixes = q.getPrefixMapping().getNsPrefixMap();
         for (String prefix : prefixes.keySet()) {


Reply via email to