You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by mr...@apache.org on 2009/09/24 18:18:18 UTC

svn commit: r818532 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/query/lucene/ test/java/org/apache/jackrabbit/core/query/

Author: mreutegg
Date: Thu Sep 24 16:18:18 2009
New Revision: 818532

URL: http://svn.apache.org/viewvc?rev=818532&view=rev
Log:
JCR-2325: rep:similar in xpath does not work

Added:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/SimilarQueryTest.java   (with props)
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/TestAll.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java?rev=818532&r1=818531&r2=818532&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java Thu Sep 24 16:18:18 2009
@@ -609,8 +609,17 @@
             return data;
         }
         LocationStepQueryNode[] steps = relPath.getPathSteps();
-        Name propertyName = steps[steps.length - 1].getNameTest();
-        
+        Name propertyName;
+        if (node.getOperation() == QueryConstants.OPERATION_SIMILAR) {
+            // this is a bit ugly:
+            // use the name of a dummy property because relPath actually
+            // references a property. whereas the relPath of the similar
+            // operation references a node
+            propertyName = NameConstants.JCR_PRIMARYTYPE;
+        } else {
+            propertyName = steps[steps.length - 1].getNameTest();
+        }
+
         Query query;
         String[] stringValues = new String[1];
         switch (node.getValueType()) {
@@ -658,13 +667,6 @@
             }
         }, null);
 
-        if (node.getOperation() == QueryConstants.OPERATION_SIMILAR) {
-            // this is a bit ugly:
-            // use the name of a dummy property because relPath actually
-            // references a property. whereas the relPath of the similar
-            // operation references a node
-            propertyName = NameConstants.JCR_PRIMARYTYPE;
-        }
         String field = "";
         try {
             field = resolver.getJCRName(propertyName);

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/SimilarQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/SimilarQueryTest.java?rev=818532&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/SimilarQueryTest.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/SimilarQueryTest.java Thu Sep 24 16:18:18 2009
@@ -0,0 +1,30 @@
+/*
+ * 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.core.query;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * <code>SimilarQueryTest</code> checks rep:similar function.
+ */
+public class SimilarQueryTest extends AbstractQueryTest {
+
+    public void testSimilar() throws RepositoryException {
+        executeQuery("//*[rep:similar(., '" + testRootNode.getPath() + "')]");
+        executeQuery("//*[rep:similar(node, '" + testRootNode.getPath() + "')]");
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/SimilarQueryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/TestAll.java?rev=818532&r1=818531&r2=818532&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/TestAll.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/TestAll.java Thu Sep 24 16:18:18 2009
@@ -61,6 +61,7 @@
         suite.addTestSuite(IndexingRuleTest.class);
         suite.addTestSuite(ShareableNodeTest.class);
         suite.addTestSuite(ParentNodeTest.class);
+        suite.addTestSuite(SimilarQueryTest.class);
 
         return suite;
     }