jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r760876 - in /jackrabbit/trunk/jackrabbit-spi-commons/src: main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java test/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormatTest.java
Date Wed, 01 Apr 2009 13:00:28 GMT
Author: mreutegg
Date: Wed Apr  1 13:00:19 2009
New Revision: 760876

URL: http://svn.apache.org/viewvc?rev=760876&view=rev
Log:
JCR-2052: XPath QueryFormat may produce malformed XPath statement

Added:
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormatTest.java
  (with props)
Modified:
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java?rev=760876&r1=760875&r2=760876&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java
Wed Apr  1 13:00:19 2009
@@ -113,9 +113,6 @@
     public Object visit(QueryRootNode node, Object data) throws RepositoryException {
         StringBuffer sb = (StringBuffer) data;
         node.getLocationNode().accept(this, data);
-        if (node.getOrderNode() != null) {
-            node.getOrderNode().accept(this, data);
-        }
         Name[] selectProps = node.getSelectProperties();
         if (selectProps.length > 0) {
             sb.append('/');
@@ -138,6 +135,9 @@
                 sb.append(')');
             }
         }
+        if (node.getOrderNode() != null) {
+            node.getOrderNode().accept(this, data);
+        }
         return data;
     }
 

Added: jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormatTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormatTest.java?rev=760876&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormatTest.java
(added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormatTest.java
Wed Apr  1 13:00:19 2009
@@ -0,0 +1,49 @@
+/*
+ * 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.jackrabbit.spi.commons.query.xpath;
+
+import java.util.Collections;
+
+import javax.jcr.query.Query;
+import javax.jcr.query.InvalidQueryException;
+
+import org.apache.jackrabbit.spi.commons.conversion.NameResolver;
+import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
+import org.apache.jackrabbit.spi.commons.conversion.DummyNamespaceResolver;
+import org.apache.jackrabbit.spi.commons.query.QueryNodeFactory;
+import org.apache.jackrabbit.spi.commons.query.DefaultQueryNodeFactory;
+import org.apache.jackrabbit.spi.commons.query.QueryRootNode;
+import org.apache.jackrabbit.spi.commons.query.QueryParser;
+
+import junit.framework.TestCase;
+
+/**
+ * <code>QueryFormatTest</code> performs tests on {@link QueryFormat}.
+ */
+public class QueryFormatTest extends TestCase {
+
+    private static final NameResolver RESOLVER = new DefaultNamePathResolver(
+            new DummyNamespaceResolver());
+
+    private static final QueryNodeFactory FACTORY = new DefaultQueryNodeFactory(Collections.EMPTY_LIST);
+
+    public void testSelectWithOrderBy() throws InvalidQueryException {
+        String stmt = "//element(*, foo)/(@a|@b) order by @bar";
+        QueryRootNode root = QueryParser.parse(stmt, Query.XPATH, RESOLVER, FACTORY);
+        assertEquals(stmt, QueryFormat.toString(root, RESOLVER));
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormatTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message