jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r292664 - in /incubator/jackrabbit/trunk/src: java/org/apache/jackrabbit/core/query/lucene/ test/org/apache/jackrabbit/test/api/query/
Date Fri, 30 Sep 2005 07:49:53 GMT
Author: mreutegg
Date: Fri Sep 30 00:49:45 2005
New Revision: 292664

URL: http://svn.apache.org/viewcvs?rev=292664&view=rev
Log:
JCR-156: Review test cases and cross check with 1.0 specification
- QueryResult must return jcr:score

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/query/GetPropertyNamesTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/query/SQLJcrPathTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/query/XPathJcrPathTest.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java?rev=292664&r1=292663&r2=292664&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/query/lucene/QueryImpl.java
Fri Sep 30 00:49:45 2005
@@ -22,19 +22,15 @@
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeImpl;
 import org.apache.jackrabbit.core.nodetype.PropertyDefinitionImpl;
-import org.apache.jackrabbit.core.query.AndQueryNode;
 import org.apache.jackrabbit.core.query.DefaultQueryNodeVisitor;
 import org.apache.jackrabbit.core.query.ExecutableQuery;
 import org.apache.jackrabbit.core.query.LocationStepQueryNode;
 import org.apache.jackrabbit.core.query.NodeTypeQueryNode;
-import org.apache.jackrabbit.core.query.NotQueryNode;
-import org.apache.jackrabbit.core.query.OrQueryNode;
 import org.apache.jackrabbit.core.query.OrderQueryNode;
 import org.apache.jackrabbit.core.query.PathQueryNode;
 import org.apache.jackrabbit.core.query.PropertyTypeRegistry;
 import org.apache.jackrabbit.core.query.QueryParser;
 import org.apache.jackrabbit.core.query.QueryRootNode;
-import org.apache.jackrabbit.core.query.TextsearchQueryNode;
 import org.apache.jackrabbit.core.security.AccessManager;
 import org.apache.jackrabbit.name.QName;
 import org.apache.log4j.Logger;
@@ -227,11 +223,11 @@
             }
         }
 
-        // add jcr:path
-        selectProps.add(Constants.JCR_PATH);
-
-        // add jcr:score if necessary
-        if (hasTextsearchNode(root.getLocationNode())) {
+        // add jcr:path and jcr:score if not selected already
+        if (!selectProps.contains(Constants.JCR_PATH)) {
+            selectProps.add(Constants.JCR_PATH);
+        }
+        if (!selectProps.contains(Constants.JCR_SCORE)) {
             selectProps.add(Constants.JCR_SCORE);
         }
 
@@ -269,42 +265,5 @@
      */
     public void setRespectDocumentOrder(boolean documentOrder) {
         this.documentOrder = documentOrder;
-    }
-
-    //-----------------------------< internal >---------------------------------
-
-    /**
-     * Returns <code>true</code> if <code>node</code> has a
-     * {@link org.apache.jackrabbit.core.query.TextsearchQueryNode} somewhere
-     * down the query tree; <code>false</code> otherwise.
-     * @param node the path node.
-     * @return <code>true</code> if the query tree contains a textsearch
-     *  node, <code>false</code> otherwise.
-     */
-    private static boolean hasTextsearchNode(PathQueryNode node) {
-        final boolean[] textsearch = new boolean[1];
-        node.acceptOperands(new DefaultQueryNodeVisitor() {
-            public Object visit(OrQueryNode node, Object data) {
-                return node.acceptOperands(this, data);
-            }
-
-            public Object visit(AndQueryNode node, Object data) {
-                return node.acceptOperands(this, data);
-            }
-
-            public Object visit(NotQueryNode node, Object data) {
-                return node.acceptOperands(this, data);
-            }
-
-            public Object visit(TextsearchQueryNode node, Object data) {
-                textsearch[0] = true;
-                return data;
-            }
-
-            public Object visit(LocationStepQueryNode node, Object data) {
-                return node.acceptOperands(this, data);
-            }
-        }, null);
-        return textsearch[0];
     }
 }

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/query/GetPropertyNamesTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/query/GetPropertyNamesTest.java?rev=292664&r1=292663&r2=292664&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/query/GetPropertyNamesTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/query/GetPropertyNamesTest.java
Fri Sep 30 00:49:45 2005
@@ -82,6 +82,7 @@
         }
         // add jcr:path
         singleValPropNames.add(jcrPath);
+        singleValPropNames.add(jcrScore);
 
         String[] foundPropertyNames = result.getColumnNames();
         Object[] realPropertyNames = singleValPropNames.toArray();

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/query/SQLJcrPathTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/query/SQLJcrPathTest.java?rev=292664&r1=292663&r2=292664&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/query/SQLJcrPathTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/query/SQLJcrPathTest.java
Fri Sep 30 00:49:45 2005
@@ -22,10 +22,10 @@
 import javax.jcr.Session;
 import javax.jcr.query.Query;
 import javax.jcr.query.QueryResult;
+import java.util.Arrays;
 
 /**
- * Tests if the jcr:path property is returned at the correct position in the
- * query result.
+ * Tests if the jcr:path property is returned in the query result.
  *
  * @test
  * @sources SQLJcrPathTest.java
@@ -58,8 +58,7 @@
     }
     
     /**
-     * Verify that the jcr:path is the last property from the found property
-     * names when the query statement does not use a contains function.
+     * Verify that the jcr:path is present in the query result.
      */
     public void testJcrPath() throws RepositoryException, NotExecutableException {
         String nodeTypeName = session.getRootNode().getPrimaryNodeType().getName();
@@ -69,10 +68,7 @@
         Query query = session.getWorkspace().getQueryManager().createQuery(queryStatement,
Query.SQL);
         QueryResult result = query.execute();
 
-        String[] propNames = result.getColumnNames();
-        if (propNames.length > 0) {
-            // jcr:path should be the last column
-            assertEquals(jcrPath + " should be the last property", jcrPath, propNames[propNames.length
- 1]);
-        }
+        assertTrue("jcr:path must be present in query result row",
+                Arrays.asList(result.getColumnNames()).contains(jcrPath));
     }
 }

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/query/XPathJcrPathTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/query/XPathJcrPathTest.java?rev=292664&r1=292663&r2=292664&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/query/XPathJcrPathTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/query/XPathJcrPathTest.java
Fri Sep 30 00:49:45 2005
@@ -22,10 +22,10 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.query.Query;
 import javax.jcr.query.QueryResult;
+import java.util.Arrays;
 
 /**
- * Tests if the jcr:path property is returned at the correct position in the
- * query result.
+ * Tests if the jcr:path property is returned in the query result.
  *
  * @test
  * @sources XPathJcrPathTest.java
@@ -58,8 +58,7 @@
     }
 
     /**
-     * Verify that the jcr:path is the last property from the found property
-     * names when the query statement does not use a contains function.
+     * Verify that the jcr:path is present in the query result.
      */
     public void testJcrPath() throws RepositoryException, NotExecutableException {
         String nodeTypeName = session.getRootNode().getPrimaryNodeType().getName();
@@ -69,10 +68,7 @@
         Query query = session.getWorkspace().getQueryManager().createQuery(queryStatement,
Query.XPATH);
         QueryResult result = query.execute();
 
-        String[] propNames = result.getColumnNames();
-        if (propNames.length > 0) {
-            // jcr:path should be the last column
-            assertEquals(jcrPath + " should be the last property", jcrPath, propNames[propNames.length
- 1]);
-        }
+        assertTrue("jcr:path must be present in query result row",
+                Arrays.asList(result.getColumnNames()).contains(jcrPath));
     }
 }



Mime
View raw message