jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r784760 - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbi...
Date Mon, 15 Jun 2009 12:51:42 GMT
Author: mreutegg
Date: Mon Jun 15 12:51:41 2009
New Revision: 784760

URL: http://svn.apache.org/viewvc?rev=784760&view=rev
Log:
JCR-2085: test case (TCK) maintenance for JCR 2.0
- move ValueFactory field to AbstractJCRTest
- more QOM tests
- use RepositoryException instead of IOException in constraints

Added:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/FullTextSearchScoreOperand.java   (with props)
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/AndConstraintTest.java   (with props)
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/FullTextSearchScoreTest.java   (with props)
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/NotConstraintTest.java   (with props)
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/OrConstraintTest.java   (with props)
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/PropertyValueTest.java   (with props)
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/FilterMultiColumnQuery.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Ordering.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ScoreNode.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ComparisonConstraint.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ConstraintBuilder.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/DynamicOperand.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/LengthOperand.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/LowerCaseOperand.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/NodeLocalNameOperand.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/NodeNameOperand.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/PropertyValueOperand.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/QueryConstraint.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/UpperCaseOperand.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyCalendarTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractOrderByTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/BindVariableValueTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/LengthTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/NodeNameTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/PropertyExistenceTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/TestAll.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/UpperLowerCaseTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/FilterMultiColumnQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/FilterMultiColumnQuery.java?rev=784760&r1=784759&r2=784760&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/FilterMultiColumnQuery.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/FilterMultiColumnQuery.java Mon Jun 15 12:51:41 2009
@@ -94,9 +94,7 @@
                 }
             }
         };
-        if (orderings.length > 0 && hits.getSelectorNames().length > 1) {
-            // subsequent ordering is only needed
-            // when there is more than one column
+        if (orderings.length > 0) {
             hits = new SortedMultiColumnQueryHits(hits, orderings, searcher.getIndexReader());
         }
         return hits;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Ordering.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Ordering.java?rev=784760&r1=784759&r2=784760&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Ordering.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Ordering.java Mon Jun 15 12:51:41 2009
@@ -120,7 +120,7 @@
                     throws Exception {
                 selectorName[0] = node.getSelectorQName();
                 return new SortField(null, SortField.SCORE,
-                        ordering.isAscending());
+                        !ordering.isAscending());
             }
 
             public Object visit(NodeLocalNameImpl node, Object data) throws Exception {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ScoreNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ScoreNode.java?rev=784760&r1=784759&r2=784760&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ScoreNode.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ScoreNode.java Mon Jun 15 12:51:41 2009
@@ -37,7 +37,7 @@
     /**
      * The score of the node.
      */
-    private final float score;
+    private float score;
 
     /**
      * The lucene document number for this score node. Set to <code>-1</code> if
@@ -83,6 +83,15 @@
     }
 
     /**
+     * Sets a new score value.
+     *
+     * @param score the score value.
+     */
+    public void setScore(float score) {
+        this.score = score;
+    }
+
+    /**
      * Returns the document number for this score node.
      *
      * @param reader the current index reader to look up the document if

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ComparisonConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ComparisonConstraint.java?rev=784760&r1=784759&r2=784760&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ComparisonConstraint.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ComparisonConstraint.java Mon Jun 15 12:51:41 2009
@@ -76,10 +76,10 @@
         if (sn == null) {
             return false;
         }
-        Value[] values = operand1.getValues(sn, context);
         try {
-            for (int i = 0; i < values.length; i++) {
-                if (evaluate(values[i])) {
+            Value[] values = operand1.getValues(sn, context);
+            for (Value value : values) {
+                if (evaluate(value)) {
                     return true;
                 }
             }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ConstraintBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ConstraintBuilder.java?rev=784760&r1=784759&r2=784760&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ConstraintBuilder.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ConstraintBuilder.java Mon Jun 15 12:51:41 2009
@@ -31,17 +31,12 @@
 import org.apache.jackrabbit.spi.commons.query.qom.AndImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.BindVariableValueImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.ChildNodeImpl;
-import org.apache.jackrabbit.spi.commons.query.qom.ChildNodeJoinConditionImpl;
-import org.apache.jackrabbit.spi.commons.query.qom.ColumnImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.ComparisonImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.ConstraintImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.DescendantNodeImpl;
-import org.apache.jackrabbit.spi.commons.query.qom.DescendantNodeJoinConditionImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.DynamicOperandImpl;
-import org.apache.jackrabbit.spi.commons.query.qom.EquiJoinConditionImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.FullTextSearchImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.FullTextSearchScoreImpl;
-import org.apache.jackrabbit.spi.commons.query.qom.JoinImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.LengthImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.LiteralImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.LowerCaseImpl;
@@ -50,16 +45,13 @@
 import org.apache.jackrabbit.spi.commons.query.qom.NotImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.Operator;
 import org.apache.jackrabbit.spi.commons.query.qom.OrImpl;
-import org.apache.jackrabbit.spi.commons.query.qom.OrderingImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.PropertyExistenceImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.PropertyValueImpl;
-import org.apache.jackrabbit.spi.commons.query.qom.QOMTreeVisitor;
-import org.apache.jackrabbit.spi.commons.query.qom.QueryObjectModelTree;
 import org.apache.jackrabbit.spi.commons.query.qom.SameNodeImpl;
-import org.apache.jackrabbit.spi.commons.query.qom.SameNodeJoinConditionImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.SelectorImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.StaticOperandImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.UpperCaseImpl;
+import org.apache.jackrabbit.spi.commons.query.qom.DefaultQOMTreeVisitor;
 
 /**
  * <code>ConstraintBuilder</code> builds a {@link Constraint} from a tree of
@@ -99,7 +91,7 @@
     /**
      * A QOM tree visitor that translates the contraints.
      */
-    private static final class Visitor implements QOMTreeVisitor {
+    private static final class Visitor extends DefaultQOMTreeVisitor {
 
         /**
          * The bind variables and their values.
@@ -156,17 +148,6 @@
                     getSelector(node.getSelectorQName()));
         }
 
-        public Object visit(ChildNodeJoinConditionImpl node, Object data)
-                throws Exception {
-            // not used
-            return null;
-        }
-
-        public Object visit(ColumnImpl node, Object data) throws Exception {
-            // not used
-            return null;
-        }
-
         public Object visit(ComparisonImpl node, Object data) throws Exception {
             DynamicOperandImpl op1 = (DynamicOperandImpl) node.getOperand1();
             Operator operator = node.getOperatorInstance();
@@ -189,18 +170,6 @@
                     getSelector(node.getSelectorQName()));
         }
 
-        public Object visit(DescendantNodeJoinConditionImpl node, Object data)
-                throws Exception {
-            // not used
-            return null;
-        }
-
-        public Object visit(EquiJoinConditionImpl node, Object data)
-                throws Exception {
-            // not used
-            return null;
-        }
-
         public Object visit(FullTextSearchImpl node, Object data)
                 throws Exception {
             return new FullTextConstraint(node,
@@ -209,13 +178,7 @@
 
         public Object visit(FullTextSearchScoreImpl node, Object data)
                 throws Exception {
-            // TODO
-            return null;
-        }
-
-        public Object visit(JoinImpl node, Object data) throws Exception {
-            // not used
-            return null;
+            return new FullTextSearchScoreOperand();
         }
 
         public Object visit(LengthImpl node, Object data) throws Exception {
@@ -288,11 +251,6 @@
             return new NotConstraint((Constraint) c.accept(this, null));
         }
 
-        public Object visit(OrderingImpl node, Object data) throws Exception {
-            // not used
-            return null;
-        }
-
         public Object visit(OrImpl node, Object data) throws Exception {
             ConstraintImpl left = (ConstraintImpl) node.getConstraint1();
             ConstraintImpl right = (ConstraintImpl) node.getConstraint2();
@@ -310,38 +268,17 @@
             return new PropertyValueOperand(node);
         }
 
-        public Object visit(QueryObjectModelTree node, Object data)
-                throws Exception {
-            // not used
-            return null;
-        }
-
         public Object visit(SameNodeImpl node, Object data) throws Exception {
             return new SameNodeConstraint(node,
                     getSelector(node.getSelectorQName()));
         }
 
-        public Object visit(SameNodeJoinConditionImpl node, Object data)
-                throws Exception {
-            // not used
-            return null;
-        }
-
-        public Object visit(SelectorImpl node, Object data) throws Exception {
-            // not used
-            return null;
-        }
-
         public Object visit(UpperCaseImpl node, Object data) throws Exception {
             DynamicOperandImpl operand = (DynamicOperandImpl) node.getOperand();
             return new UpperCaseOperand((DynamicOperand) operand.accept(this, data));
         }
 
         private SelectorImpl getSelector(Name name) {
-            if (name == null) {
-                // assume default selector
-                return selectors[0];
-            }
             for (SelectorImpl selector : selectors) {
                 if (selector.getSelectorQName().equals(name)) {
                     return selector;
@@ -349,6 +286,5 @@
             }
             return null;
         }
-
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/DynamicOperand.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/DynamicOperand.java?rev=784760&r1=784759&r2=784760&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/DynamicOperand.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/DynamicOperand.java Mon Jun 15 12:51:41 2009
@@ -16,9 +16,8 @@
  */
 package org.apache.jackrabbit.core.query.lucene.constraint;
 
-import java.io.IOException;
-
 import javax.jcr.Value;
+import javax.jcr.RepositoryException;
 
 import org.apache.jackrabbit.core.query.lucene.ScoreNode;
 
@@ -40,8 +39,8 @@
      * @param sn      the current score node.
      * @param context the evaluation context.
      * @return the values for the given score node.
-     * @throws IOException if an error occurs while retrieving the value.
+     * @throws RepositoryException if an error occurs while retrieving the value.
      */
     public abstract Value[] getValues(ScoreNode sn, EvaluationContext context)
-            throws IOException;
+            throws RepositoryException;
 }

Added: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/FullTextSearchScoreOperand.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/FullTextSearchScoreOperand.java?rev=784760&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/FullTextSearchScoreOperand.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/FullTextSearchScoreOperand.java Mon Jun 15 12:51:41 2009
@@ -0,0 +1,37 @@
+/*
+ * 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.lucene.constraint;
+
+import javax.jcr.Value;
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.core.query.lucene.ScoreNode;
+
+/**
+ * <code>FullTextSearchScoreOperand</code> implements a full text search score
+ * operand.
+ */
+public class FullTextSearchScoreOperand extends DynamicOperand {
+
+    /**
+     * {@inheritDoc}
+     */
+    public Value[] getValues(ScoreNode sn, EvaluationContext context)
+            throws RepositoryException {
+        return new Value[]{context.getSession().getValueFactory().createValue(sn.getScore())};
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/FullTextSearchScoreOperand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/LengthOperand.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/LengthOperand.java?rev=784760&r1=784759&r2=784760&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/LengthOperand.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/LengthOperand.java Mon Jun 15 12:51:41 2009
@@ -16,8 +16,6 @@
  */
 package org.apache.jackrabbit.core.query.lucene.constraint;
 
-import java.io.IOException;
-
 import javax.jcr.Value;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
@@ -53,7 +51,7 @@
      * {@inheritDoc}
      */
     public Value[] getValues(ScoreNode sn, EvaluationContext context)
-            throws IOException {
+            throws RepositoryException {
         PropertyState ps = property.getPropertyState(sn, context);
         if (ps == null) {
             return EMPTY;
@@ -65,16 +63,12 @@
             for (int i = 0; i < lengths.length; i++) {
                 long len;
                 int type = values[i].getType();
-                try {
-                    if (type == PropertyType.NAME) {
-                        len = vf.createValue(qvf.create(values[i].getName())).getString().length();
-                    } else if (type == PropertyType.PATH) {
-                        len = vf.createValue(qvf.create(values[i].getPath())).getString().length();
-                    } else {
-                        len = Util.getLength(values[i]);
-                    }
-                } catch (RepositoryException e) {
-                    throw Util.createIOException(e);
+                if (type == PropertyType.NAME) {
+                    len = vf.createValue(qvf.create(values[i].getName())).getString().length();
+                } else if (type == PropertyType.PATH) {
+                    len = vf.createValue(qvf.create(values[i].getPath())).getString().length();
+                } else {
+                    len = Util.getLength(values[i]);
                 }
                 lengths[i] = vf.createValue(len);
             }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/LowerCaseOperand.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/LowerCaseOperand.java?rev=784760&r1=784759&r2=784760&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/LowerCaseOperand.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/LowerCaseOperand.java Mon Jun 15 12:51:41 2009
@@ -16,14 +16,11 @@
  */
 package org.apache.jackrabbit.core.query.lucene.constraint;
 
-import java.io.IOException;
-
 import javax.jcr.Value;
 import javax.jcr.ValueFactory;
 import javax.jcr.RepositoryException;
 
 import org.apache.jackrabbit.core.query.lucene.ScoreNode;
-import org.apache.jackrabbit.core.query.lucene.Util;
 
 /**
  * <code>LowerCaseOperand</code> implements a lower case operand.
@@ -49,16 +46,12 @@
      * {@inheritDoc}
      */
     public Value[] getValues(ScoreNode sn, EvaluationContext context)
-            throws IOException {
-        try {
-            ValueFactory vf = context.getSession().getValueFactory();
-            Value[] values = operand.getValues(sn, context);
-            for (int i = 0; i < values.length; i++) {
-                values[i] = vf.createValue(values[i].getString().toLowerCase());
-            }
-            return values;
-        } catch (RepositoryException e) {
-            throw Util.createIOException(e);
+            throws RepositoryException {
+        ValueFactory vf = context.getSession().getValueFactory();
+        Value[] values = operand.getValues(sn, context);
+        for (int i = 0; i < values.length; i++) {
+            values[i] = vf.createValue(values[i].getString().toLowerCase());
         }
+        return values;
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/NodeLocalNameOperand.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/NodeLocalNameOperand.java?rev=784760&r1=784759&r2=784760&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/NodeLocalNameOperand.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/NodeLocalNameOperand.java Mon Jun 15 12:51:41 2009
@@ -16,13 +16,10 @@
  */
 package org.apache.jackrabbit.core.query.lucene.constraint;
 
-import java.io.IOException;
-
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 
 import org.apache.jackrabbit.core.query.lucene.ScoreNode;
-import org.apache.jackrabbit.core.query.lucene.Util;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.util.Text;
 
@@ -38,17 +35,14 @@
      * @param sn      the score node.
      * @param context the evaluation context.
      * @return the local node name.
-     * @throws IOException if an error occurs while reading the local name.
+     * @throws RepositoryException if an error occurs while reading the local
+     *                             name.
      */
     public Value[] getValues(ScoreNode sn, EvaluationContext context)
-            throws IOException {
-        try {
-            SessionImpl session = context.getSession();
-            String name = session.getNodeById(sn.getNodeId()).getName();
-            return new Value[]{session.getValueFactory().createValue(
-                    Text.getLocalName(name))};
-        } catch (RepositoryException e) {
-            throw Util.createIOException(e);
-        }
+            throws RepositoryException {
+        SessionImpl session = context.getSession();
+        String name = session.getNodeById(sn.getNodeId()).getName();
+        return new Value[]{session.getValueFactory().createValue(
+                Text.getLocalName(name))};
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/NodeNameOperand.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/NodeNameOperand.java?rev=784760&r1=784759&r2=784760&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/NodeNameOperand.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/NodeNameOperand.java Mon Jun 15 12:51:41 2009
@@ -16,14 +16,11 @@
  */
 package org.apache.jackrabbit.core.query.lucene.constraint;
 
-import java.io.IOException;
-
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.PropertyType;
 
 import org.apache.jackrabbit.core.query.lucene.ScoreNode;
-import org.apache.jackrabbit.core.query.lucene.Util;
 import org.apache.jackrabbit.core.SessionImpl;
 
 /**
@@ -38,16 +35,12 @@
      * @param sn      the score node.
      * @param context the evaluation context.
      * @return the node name.
-     * @throws IOException if an error occurs while reading the name.
+     * @throws RepositoryException if an error occurs while reading the name.
      */
     public Value[] getValues(ScoreNode sn, EvaluationContext context)
-            throws IOException {
-        try {
-            SessionImpl session = context.getSession();
-            String name = session.getNodeById(sn.getNodeId()).getName();
-            return new Value[]{session.getValueFactory().createValue(name, PropertyType.NAME)};
-        } catch (RepositoryException e) {
-            throw Util.createIOException(e);
-        }
+            throws RepositoryException {
+        SessionImpl session = context.getSession();
+        String name = session.getNodeById(sn.getNodeId()).getName();
+        return new Value[]{session.getValueFactory().createValue(name, PropertyType.NAME)};
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/PropertyValueOperand.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/PropertyValueOperand.java?rev=784760&r1=784759&r2=784760&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/PropertyValueOperand.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/PropertyValueOperand.java Mon Jun 15 12:51:41 2009
@@ -16,8 +16,6 @@
  */
 package org.apache.jackrabbit.core.query.lucene.constraint;
 
-import java.io.IOException;
-
 import javax.jcr.Value;
 import javax.jcr.Property;
 import javax.jcr.Node;
@@ -26,7 +24,6 @@
 
 import org.apache.jackrabbit.spi.commons.query.qom.PropertyValueImpl;
 import org.apache.jackrabbit.core.query.lucene.ScoreNode;
-import org.apache.jackrabbit.core.query.lucene.Util;
 import org.apache.jackrabbit.core.state.ItemStateManager;
 import org.apache.jackrabbit.core.state.PropertyState;
 import org.apache.jackrabbit.core.state.ItemStateException;
@@ -61,11 +58,11 @@
      * @param sn the current score node.
      * @param context the evaluation context.
      * @return the property state or <code>null</code>.
-     * @throws IOException if an error occurs while reading.
+     * @throws RepositoryException if an error occurs while reading.
      */
     public final PropertyState getPropertyState(ScoreNode sn,
-                                          EvaluationContext context)
-            throws IOException {
+                                                EvaluationContext context)
+            throws RepositoryException {
         ItemStateManager ism = context.getItemStateManager();
         PropertyId propId = new PropertyId(sn.getNodeId(), operand.getPropertyQName());
         try {
@@ -73,7 +70,7 @@
         } catch (NoSuchItemStateException e) {
             return null;
         } catch (ItemStateException e) {
-            throw Util.createIOException(e);
+            throw new RepositoryException(e);
         }
     }
 
@@ -84,19 +81,17 @@
      * @param sn the current score node.
      * @param context the evaluation context.
      * @return the property or <code>null</code>.
-     * @throws IOException if an error occurs while reading.
+     * @throws RepositoryException if an error occurs while reading.
      */
     public final Property getProperty(ScoreNode sn,
                                       EvaluationContext context)
-            throws IOException {
+            throws RepositoryException {
         SessionImpl session = context.getSession();
         try {
             Node n = session.getNodeById(sn.getNodeId());
             return n.getProperty(operand.getPropertyName());
         } catch (PathNotFoundException e) {
             return null;
-        } catch (RepositoryException e) {
-            throw Util.createIOException(e);
         }
     }
 
@@ -104,19 +99,15 @@
      * {@inheritDoc}
      */
     public Value[] getValues(ScoreNode sn, EvaluationContext context)
-            throws IOException {
+            throws RepositoryException {
         Property prop = getProperty(sn, context);
         if (prop == null) {
             return EMPTY;
         } else {
-            try {
-                if (prop.getDefinition().isMultiple()) {
-                    return prop.getValues();
-                } else {
-                    return new Value[]{prop.getValue()};
-                }
-            } catch (RepositoryException e) {
-                throw Util.createIOException(e);
+            if (prop.getDefinition().isMultiple()) {
+                return prop.getValues();
+            } else {
+                return new Value[]{prop.getValue()};
             }
         }
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/QueryConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/QueryConstraint.java?rev=784760&r1=784759&r2=784760&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/QueryConstraint.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/QueryConstraint.java Mon Jun 15 12:51:41 2009
@@ -17,7 +17,8 @@
 package org.apache.jackrabbit.core.query.lucene.constraint;
 
 import java.io.IOException;
-import java.util.BitSet;
+import java.util.Map;
+import java.util.HashMap;
 
 import javax.jcr.RepositoryException;
 
@@ -49,9 +50,10 @@
     private final LuceneQueryFactory factory;
 
     /**
-     * The bitset with the matching document numbers.
+     * Map of document numbers with their respective score value that match the
+     * query constraint.
      */
-    private BitSet matches;
+    private Map<Integer, Float> matches;
 
     /**
      * Creates a new query constraint using the given lucene query.
@@ -95,7 +97,11 @@
     private boolean evaluate(ScoreNode sn, EvaluationContext context)
             throws IOException {
         initMatches(context);
-        return matches.get(sn.getDoc(context.getIndexReader()));
+        Float score = matches.get(sn.getDoc(context.getIndexReader()));
+        if (score != null) {
+            sn.setScore(score);
+        }
+        return score != null;
     }
 
     /**
@@ -120,10 +126,10 @@
             IndexReader reader = context.getIndexReader();
             QueryHits hits = context.evaluate(and);
             try {
-                matches = new BitSet();
+                matches = new HashMap<Integer, Float>();
                 ScoreNode sn;
                 while ((sn = hits.nextScoreNode()) != null) {
-                    matches.set(sn.getDoc(reader));
+                    matches.put(sn.getDoc(reader), sn.getScore());
                 }
             } finally {
                 hits.close();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/UpperCaseOperand.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/UpperCaseOperand.java?rev=784760&r1=784759&r2=784760&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/UpperCaseOperand.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/UpperCaseOperand.java Mon Jun 15 12:51:41 2009
@@ -16,14 +16,11 @@
  */
 package org.apache.jackrabbit.core.query.lucene.constraint;
 
-import java.io.IOException;
-
 import javax.jcr.Value;
 import javax.jcr.ValueFactory;
 import javax.jcr.RepositoryException;
 
 import org.apache.jackrabbit.core.query.lucene.ScoreNode;
-import org.apache.jackrabbit.core.query.lucene.Util;
 
 /**
  * <code>UpperCaseOperand</code> implements an upper case operand.
@@ -49,16 +46,12 @@
      * {@inheritDoc}
      */
     public Value[] getValues(ScoreNode sn, EvaluationContext context)
-            throws IOException {
-        try {
-            ValueFactory vf = context.getSession().getValueFactory();
-            Value[] values = operand.getValues(sn, context);
-            for (int i = 0; i < values.length; i++) {
-                values[i] = vf.createValue(values[i].getString().toUpperCase());
-            }
-            return values;
-        } catch (RepositoryException e) {
-            throw Util.createIOException(e);
+            throws RepositoryException {
+        ValueFactory vf = context.getSession().getValueFactory();
+        Value[] values = operand.getValues(sn, context);
+        for (int i = 0; i < values.length; i++) {
+            values[i] = vf.createValue(values[i].getString().toUpperCase());
         }
+        return values;
     }
 }

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java?rev=784760&r1=784759&r2=784760&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java Mon Jun 15 12:51:41 2009
@@ -284,6 +284,11 @@
      */
     protected Node testRootNode;
 
+    /**
+     * The value factory for {@link #superuser}.
+     */
+    protected ValueFactory vf;
+
     protected void setUp() throws Exception {
         super.setUp();
         testRoot = getProperty(RepositoryStub.PROP_TESTROOT);
@@ -375,6 +380,7 @@
                     }
                 }
             }
+            vf = superuser.getValueFactory();
         }
 
         if (isReadOnly) {
@@ -413,6 +419,7 @@
             } finally {
                 superuser.logout();
                 superuser = null;
+                vf = null;
             }
         }
         testRootNode = null;

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyCalendarTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyCalendarTest.java?rev=784760&r1=784759&r2=784760&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyCalendarTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyCalendarTest.java Mon Jun 15 12:51:41 2009
@@ -19,7 +19,6 @@
 import org.apache.jackrabbit.test.AbstractJCRTest;
 
 import javax.jcr.Node;
-import javax.jcr.ValueFactory;
 
 import java.util.Calendar;
 import java.util.GregorianCalendar;
@@ -37,20 +36,16 @@
 
     private Node testNode;
 
-    private ValueFactory vFactory;
-
     private Calendar c1 = new GregorianCalendar(2005, 1, 10, 14, 8, 56);
     private Calendar c2 = new GregorianCalendar(1945, 1, 6, 16, 20, 0);
 
     protected void setUp() throws Exception {
         super.setUp();
         testNode = testRootNode.addNode(nodeName1, testNodeType);
-        vFactory = superuser.getValueFactory();
     }
 
     protected void tearDown() throws Exception {
         testNode = null;
-        vFactory = null;
         super.tearDown();
     }
 
@@ -62,7 +57,7 @@
         testNode.setProperty(propertyName1, c1);
         superuser.save();
         assertEquals("Setting property with Node.setProperty(String, Calendar) and Session.save() not working",
-                vFactory.createValue(c1),
+                vf.createValue(c1),
                 testNode.getProperty(propertyName1).getValue());
     }
 
@@ -76,7 +71,7 @@
         testNode.setProperty(propertyName1, c2);
         superuser.save();
         assertEquals("Modifying property with Node.setProperty(String, Calendar) and Session.save() not working",
-                vFactory.createValue(c2),
+                vf.createValue(c2),
                 testNode.getProperty(propertyName1).getValue());
     }
 
@@ -88,7 +83,7 @@
         testNode.setProperty(propertyName1, c1);
         testRootNode.save();
         assertEquals("Setting property with Node.setProperty(String, Calendar) and parentNode.save() not working",
-                vFactory.createValue(c1),
+                vf.createValue(c1),
                 testNode.getProperty(propertyName1).getValue());
     }
 
@@ -102,7 +97,7 @@
         testNode.setProperty(propertyName1, c2);
         testRootNode.save();
         assertEquals("Modifying property with Node.setProperty(String, Calendar) and parentNode.save() not working",
-                vFactory.createValue(c2),
+                vf.createValue(c2),
                 testNode.getProperty(propertyName1).getValue());
     }
 

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractOrderByTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractOrderByTest.java?rev=784760&r1=784759&r2=784760&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractOrderByTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractOrderByTest.java Mon Jun 15 12:51:41 2009
@@ -20,7 +20,6 @@
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
 import javax.jcr.Repository;
-import javax.jcr.ValueFactory;
 import javax.jcr.query.Query;
 import javax.jcr.query.QueryResult;
 import javax.jcr.query.qom.QueryObjectModel;
@@ -42,15 +41,12 @@
     /** If <code>true</code> this repository supports sql queries */
     protected boolean checkSQL;
 
-    protected ValueFactory vf;
-
     private String[] nodeNames;
 
     protected void setUp() throws Exception {
         super.setUp();
         checkSQL = isSupported(Repository.OPTION_QUERY_SQL_SUPPORTED);
         nodeNames = new String[]{nodeName1, nodeName2, nodeName3, nodeName4};
-        vf = superuser.getValueFactory();
     }
 
     /**

Added: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/AndConstraintTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/AndConstraintTest.java?rev=784760&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/AndConstraintTest.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/AndConstraintTest.java Mon Jun 15 12:51:41 2009
@@ -0,0 +1,50 @@
+/*
+ * 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.test.api.query.qom;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.query.QueryResult;
+
+/**
+ * <code>AndConstraintTest</code> contains tests that check AND constraints.
+ */
+public class AndConstraintTest extends AbstractQOMTest {
+
+    public void testAnd() throws RepositoryException {
+        Node n1 = testRootNode.addNode(nodeName1, testNodeType);
+        n1.setProperty(propertyName1, "foo");
+        n1.setProperty(propertyName2, "bar");
+        Node n2 = testRootNode.addNode(nodeName2, testNodeType);
+        n2.setProperty(propertyName2, "bar");
+        superuser.save();
+
+        QueryResult result = qf.createQuery(
+                qf.selector(testNodeType, "s"),
+                qf.and(
+                        qf.descendantNode("s", testRootNode.getPath()),
+                        qf.and(
+                                qf.propertyExistence("s", propertyName1),
+                                qf.propertyExistence("s", propertyName2)
+                        )
+                ),
+                null,
+                null
+        ).execute();
+        checkResult(result, new Node[]{n1});
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/AndConstraintTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/BindVariableValueTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/BindVariableValueTest.java?rev=784760&r1=784759&r2=784760&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/BindVariableValueTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/BindVariableValueTest.java Mon Jun 15 12:51:41 2009
@@ -22,7 +22,6 @@
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
-import javax.jcr.ValueFactory;
 import javax.jcr.PropertyType;
 import javax.jcr.query.Query;
 import javax.jcr.query.qom.QueryObjectModelConstants;
@@ -48,11 +47,8 @@
 
     private Query query;
 
-    private ValueFactory vf;
-
     protected void setUp() throws Exception {
         super.setUp();
-        vf = superuser.getValueFactory();
         query = qf.createQuery(
                 qf.selector(testNodeType, "s"),
                 qf.and(
@@ -66,7 +62,6 @@
     }
 
     protected void tearDown() throws Exception {
-        vf = null;
         query = null;
         super.tearDown();
     }

Added: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/FullTextSearchScoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/FullTextSearchScoreTest.java?rev=784760&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/FullTextSearchScoreTest.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/FullTextSearchScoreTest.java Mon Jun 15 12:51:41 2009
@@ -0,0 +1,91 @@
+/*
+ * 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.test.api.query.qom;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.query.qom.Ordering;
+import javax.jcr.query.qom.QueryObjectModelFactory;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.RowIterator;
+
+/**
+ * <code>FullTextSearchScoreTest</code> contains fulltext search score tests.
+ */
+public class FullTextSearchScoreTest extends AbstractQOMTest {
+
+    private static final String TEXT = "the quick brown fox jumps over the lazy dog.";
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        Node n1 = testRootNode.addNode(nodeName1, testNodeType);
+        n1.setProperty(propertyName1, TEXT);
+        Node n2 = testRootNode.addNode(nodeName2, testNodeType);
+        n2.setProperty(propertyName1, TEXT);
+        n2.setProperty(propertyName2, TEXT);
+        superuser.save();
+    }
+
+    public void testOrdering() throws RepositoryException {
+        QueryResult result = qf.createQuery(
+                qf.selector(testNodeType, "s"),
+                qf.and(
+                        qf.fullTextSearch("s", null, "fox"),
+                        qf.descendantNode("s", testRootNode.getPath())
+                ),
+                new Ordering[]{qf.ascending(qf.fullTextSearchScore("s"))},
+                null
+        ).execute();
+
+        RowIterator rows = result.getRows();
+        double previousScore = Double.NaN;
+        while (rows.hasNext()) {
+            double score = rows.nextRow().getScore("s");
+            if (!Double.isNaN(previousScore)) {
+                assertTrue("wrong order", previousScore <= score);
+            }
+            previousScore = score;
+        }
+    }
+
+    public void testConstraint() throws RepositoryException {
+        QueryResult result = qf.createQuery(
+                qf.selector(testNodeType, "s"),
+                qf.and(
+                        qf.and(
+                                qf.fullTextSearch("s", null, "fox"),
+                                qf.comparison(
+                                        qf.fullTextSearchScore("s"),
+                                        QueryObjectModelFactory.JCR_OPERATOR_GREATER_THAN,
+                                        qf.literal(vf.createValue(Double.MIN_VALUE))
+                                )
+                        ),
+                        qf.descendantNode("s", testRootNode.getPath())
+                ),
+                new Ordering[]{qf.descending(qf.fullTextSearchScore("s"))},
+                null
+        ).execute();
+
+        RowIterator rows = result.getRows();
+        while (rows.hasNext()) {
+            double score = rows.nextRow().getScore("s");
+            if (!Double.isNaN(score)) {
+                assertTrue("wrong full text search score", Double.MIN_VALUE < score);
+            }
+        }
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/FullTextSearchScoreTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/LengthTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/LengthTest.java?rev=784760&r1=784759&r2=784760&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/LengthTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/LengthTest.java Mon Jun 15 12:51:41 2009
@@ -21,7 +21,6 @@
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
-import javax.jcr.ValueFactory;
 import javax.jcr.PropertyType;
 import javax.jcr.Binary;
 import javax.jcr.query.QueryResult;
@@ -40,18 +39,15 @@
 
     private Node node;
 
-    private ValueFactory vf;
 
     protected void setUp() throws Exception {
         super.setUp();
         node = testRootNode.addNode(nodeName1, testNodeType);
         superuser.save();
-        vf = superuser.getValueFactory();
     }
 
     protected void tearDown() throws Exception {
         node = null;
-        vf = null;
         super.tearDown();
     }
 

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/NodeNameTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/NodeNameTest.java?rev=784760&r1=784759&r2=784760&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/NodeNameTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/NodeNameTest.java Mon Jun 15 12:51:41 2009
@@ -20,7 +20,6 @@
 import javax.jcr.Value;
 import javax.jcr.Node;
 import javax.jcr.PropertyType;
-import javax.jcr.ValueFactory;
 import javax.jcr.query.Query;
 import javax.jcr.query.InvalidQueryException;
 import javax.jcr.query.qom.QueryObjectModelConstants;
@@ -36,13 +35,10 @@
 
     private Node node1;
 
-    private ValueFactory vf;
-
     protected void setUp() throws Exception {
         super.setUp();
         node1 = testRootNode.addNode(nodeName1, testNodeType);
         superuser.save();
-        vf = superuser.getValueFactory();
     }
 
     protected void tearDown() throws Exception {

Added: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/NotConstraintTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/NotConstraintTest.java?rev=784760&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/NotConstraintTest.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/NotConstraintTest.java Mon Jun 15 12:51:41 2009
@@ -0,0 +1,48 @@
+/*
+ * 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.test.api.query.qom;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.query.QueryResult;
+
+/**
+ * <code>NotConstraintTest</code> contains tests that check NOT constraints.
+ */
+public class NotConstraintTest extends AbstractQOMTest {
+
+    public void testNot() throws RepositoryException {
+        Node n1 = testRootNode.addNode(nodeName1, testNodeType);
+        n1.setProperty(propertyName1, "foo");
+        Node n2 = testRootNode.addNode(nodeName2, testNodeType);
+        n2.setProperty(propertyName2, "bar");
+        superuser.save();
+
+        QueryResult result = qf.createQuery(
+                qf.selector(testNodeType, "s"),
+                qf.and(
+                        qf.descendantNode("s", testRootNode.getPath()),
+                        qf.not(
+                                qf.propertyExistence("s", propertyName1)
+                        )
+                ),
+                null,
+                null
+        ).execute();
+        checkResult(result, new Node[]{n2});
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/NotConstraintTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/OrConstraintTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/OrConstraintTest.java?rev=784760&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/OrConstraintTest.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/OrConstraintTest.java Mon Jun 15 12:51:41 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.test.api.query.qom;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.query.QueryResult;
+
+/**
+ * <code>OrConstraintTest</code> contains tests that check OR constraints.
+ */
+public class OrConstraintTest extends AbstractQOMTest {
+
+    public void testOr() throws RepositoryException {
+        Node n1 = testRootNode.addNode(nodeName1, testNodeType);
+        n1.setProperty(propertyName1, "foo");
+        Node n2 = testRootNode.addNode(nodeName2, testNodeType);
+        n2.setProperty(propertyName2, "bar");
+        superuser.save();
+
+        QueryResult result = qf.createQuery(
+                qf.selector(testNodeType, "s"),
+                qf.and(
+                        qf.descendantNode("s", testRootNode.getPath()),
+                        qf.or(
+                                qf.propertyExistence("s", propertyName1),
+                                qf.propertyExistence("s", propertyName2)
+                        )
+                ),
+                null,
+                null
+        ).execute();
+        checkResult(result, new Node[]{n1, n2});
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/OrConstraintTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/PropertyExistenceTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/PropertyExistenceTest.java?rev=784760&r1=784759&r2=784760&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/PropertyExistenceTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/PropertyExistenceTest.java Mon Jun 15 12:51:41 2009
@@ -31,7 +31,7 @@
         n1.setProperty(propertyName1, "abc");
         Node n2 = testRootNode.addNode(nodeName2, testNodeType);
         n2.setProperty(propertyName2, "abc");
-        testRootNode.save();
+        superuser.save();
 
         QueryResult result = qf.createQuery(
                 qf.selector(testNodeType, "s"),

Added: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/PropertyValueTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/PropertyValueTest.java?rev=784760&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/PropertyValueTest.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/PropertyValueTest.java Mon Jun 15 12:51:41 2009
@@ -0,0 +1,63 @@
+/*
+ * 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.test.api.query.qom;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.qom.QueryObjectModelFactory;
+
+/**
+ * <code>PropertyValueTest</code> performs a test with property value
+ * comparision.
+ */
+public class PropertyValueTest extends AbstractQOMTest {
+
+    private static final String TEXT = "abc";
+
+    public void testPropertyExistence() throws RepositoryException {
+        Node n1 = testRootNode.addNode(nodeName1, testNodeType);
+        n1.setProperty(propertyName1, TEXT);
+        Node n2 = testRootNode.addNode(nodeName2, testNodeType);
+        n2.setProperty(propertyName2, TEXT);
+        superuser.save();
+
+        QueryResult result = qf.createQuery(
+                qf.selector(testNodeType, "s"),
+                qf.and(
+                        qf.childNode("s", testRoot),
+                        qf.comparison(
+                                qf.propertyValue("s", propertyName1),
+                                QueryObjectModelFactory.JCR_OPERATOR_EQUAL_TO,
+                                qf.literal(vf.createValue(TEXT))
+                        )
+                ), null, null).execute();
+        checkResult(result, new Node[]{n1});
+
+        result = qf.createQuery(
+                qf.selector(testNodeType, "s"),
+                qf.and(
+                        qf.childNode("s", testRoot),
+                        qf.comparison(
+                                qf.propertyValue("s", propertyName2),
+                                QueryObjectModelFactory.JCR_OPERATOR_EQUAL_TO,
+                                qf.literal(vf.createValue(TEXT))
+                        )
+                ), null, null).execute();
+        checkResult(result, new Node[]{n2});
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/PropertyValueTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/TestAll.java?rev=784760&r1=784759&r2=784760&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/TestAll.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/TestAll.java Mon Jun 15 12:51:41 2009
@@ -29,6 +29,7 @@
     public static Test suite() {
         TestSuite suite = new TestSuite("QOM tests");
 
+        suite.addTestSuite(AndConstraintTest.class);
         suite.addTestSuite(BindVariableValueTest.class);
         suite.addTestSuite(ChildNodeJoinConditionTest.class);
         suite.addTestSuite(ChildNodeTest.class);
@@ -36,11 +37,15 @@
         suite.addTestSuite(DescendantNodeJoinConditionTest.class);
         suite.addTestSuite(DescendantNodeTest.class);
         suite.addTestSuite(EquiJoinConditionTest.class);
+        suite.addTestSuite(FullTextSearchScoreTest.class);
         suite.addTestSuite(LengthTest.class);
         suite.addTestSuite(NodeLocalNameTest.class);
         suite.addTestSuite(NodeNameTest.class);
+        suite.addTestSuite(NotConstraintTest.class);
+        suite.addTestSuite(OrConstraintTest.class);
         suite.addTestSuite(OrderingTest.class);
         suite.addTestSuite(PropertyExistenceTest.class);
+        suite.addTestSuite(PropertyValueTest.class);
         suite.addTestSuite(QueryObjectModelFactoryTest.class);
         suite.addTestSuite(RowTest.class);
         suite.addTestSuite(SameNodeJoinConditionTest.class); 

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/UpperLowerCaseTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/UpperLowerCaseTest.java?rev=784760&r1=784759&r2=784760&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/UpperLowerCaseTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/UpperLowerCaseTest.java Mon Jun 15 12:51:41 2009
@@ -20,7 +20,6 @@
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
-import javax.jcr.ValueFactory;
 import javax.jcr.query.Query;
 import javax.jcr.query.qom.DynamicOperand;
 import javax.jcr.query.qom.QueryObjectModelConstants;
@@ -31,13 +30,10 @@
  */
 public class UpperLowerCaseTest extends AbstractQOMTest {
 
-    private ValueFactory vf;
-
     private Node node;
 
     protected void setUp() throws Exception {
         super.setUp();
-        vf = superuser.getValueFactory();
         node = testRootNode.addNode(nodeName1, testNodeType);
         node.setProperty(propertyName1, "abc");
         node.setProperty(propertyName2, "ABC");
@@ -45,7 +41,6 @@
     }
 
     protected void tearDown() throws Exception {
-        vf = null;
         node = null;
         super.tearDown();
     }



Mime
View raw message