jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1519930 - /jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryTest.java
Date Wed, 04 Sep 2013 07:58:19 GMT
Author: thomasm
Date: Wed Sep  4 07:58:19 2013
New Revision: 1519930

URL: http://svn.apache.org/r1519930
Log:
OAK-989 Query parser doesn't decode paths (test case)

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryTest.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryTest.java?rev=1519930&r1=1519929&r2=1519930&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryTest.java
Wed Sep  4 07:58:19 2013
@@ -55,6 +55,40 @@ public class QueryTest extends AbstractR
     public QueryTest(NodeStoreFixture fixture) {
         super(fixture);
     }
+    
+    @SuppressWarnings("deprecation")
+    @Test
+    public void encodedPath() throws RepositoryException {
+        Session session = getAdminSession();
+        session.getRootNode().addNode("hello").addNode("world");
+        session.save();
+        QueryManager qm = session.getWorkspace().getQueryManager();
+        Query q;
+        
+        q = qm.createQuery("/jcr:root/hel_x006c_o/*", Query.XPATH);
+        assertEquals("/hello/world", getPaths(q));
+        
+        q = qm.createQuery("//hel_x006c_o", Query.XPATH);
+        assertEquals("/hello", getPaths(q));
+        
+        q = qm.createQuery("//element(hel_x006c_o, nt:base)", Query.XPATH);
+        assertEquals("/hello", getPaths(q));
+        
+    }
+    
+    private static String getPaths(Query q) throws RepositoryException {
+        QueryResult r = q.execute();
+        RowIterator it = r.getRows();
+        StringBuilder buff = new StringBuilder();
+        if (it.hasNext()) {
+            Row row = it.nextRow();
+            if (buff.length() > 0) {
+                buff.append(", ");
+            }
+            buff.append(row.getPath());
+        }
+        return buff.toString();
+    }
 
     @SuppressWarnings("deprecation")
     @Test



Mime
View raw message