jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r770306 - in /jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query: AbstractQueryTest.java UpperLowerCaseQueryTest.java
Date Thu, 30 Apr 2009 16:07:48 GMT
Author: jukka
Date: Thu Apr 30 16:07:47 2009
New Revision: 770306

URL: http://svn.apache.org/viewvc?rev=770306&view=rev
Log:
JCR-2092: make spi query code compatible with JCR 2.0

Update jackrabbit-core to use JCR 2.0 interfaces instead of the SPI versions

Modified:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/AbstractQueryTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/UpperLowerCaseQueryTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/AbstractQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/AbstractQueryTest.java?rev=770306&r1=770305&r2=770306&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/AbstractQueryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/AbstractQueryTest.java
Thu Apr 30 16:07:47 2009
@@ -16,25 +16,26 @@
  */
 package org.apache.jackrabbit.core.query;
 
-import org.apache.jackrabbit.test.AbstractJCRTest;
-import org.apache.jackrabbit.spi.commons.query.jsr283.qom.QueryObjectModelFactory;
-import org.apache.jackrabbit.commons.iterator.NodeIteratorAdapter;
-
-import javax.jcr.query.QueryResult;
-import javax.jcr.query.RowIterator;
-import javax.jcr.query.Query;
-import javax.jcr.query.QueryManager;
-import javax.jcr.query.Row;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.Node;
-import javax.jcr.Value;
-import java.util.List;
 import java.util.ArrayList;
-import java.util.Set;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
 import java.util.NoSuchElementException;
+import java.util.Set;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.Row;
+import javax.jcr.query.RowIterator;
+import javax.jcr.query.qom.QueryObjectModelFactory;
+
+import org.apache.jackrabbit.commons.iterator.NodeIteratorAdapter;
+import org.apache.jackrabbit.test.AbstractJCRTest;
 
 /**
  * Abstract base class for query test cases.

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/UpperLowerCaseQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/UpperLowerCaseQueryTest.java?rev=770306&r1=770305&r2=770306&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/UpperLowerCaseQueryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/UpperLowerCaseQueryTest.java
Thu Apr 30 16:07:47 2009
@@ -16,18 +16,18 @@
  */
 package org.apache.jackrabbit.core.query;
 
-import org.apache.jackrabbit.spi.commons.query.jsr283.qom.QueryObjectModelConstants;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
 
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
 import javax.jcr.RepositoryException;
 import javax.jcr.query.InvalidQueryException;
 import javax.jcr.query.QueryResult;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.Random;
-import java.util.Map;
-import java.util.HashMap;
+import javax.jcr.query.qom.QueryObjectModelConstants;
 
 /**
  * <code>UpperLowerCaseQueryTest</code> tests the functions fn:lower-case() and
@@ -39,16 +39,17 @@
     /**
      * Maps operator strings to QueryObjectModelConstants.
      */
-    private static final Map OPERATORS = new HashMap();
+    private static final Map<String, String> OPERATORS =
+        new HashMap<String, String>();
 
     static {
-        OPERATORS.put("=", new Integer(OPERATOR_EQUAL_TO));
-        OPERATORS.put(">", new Integer(OPERATOR_GREATER_THAN));
-        OPERATORS.put(">=", new Integer(OPERATOR_GREATER_THAN_OR_EQUAL_TO));
-        OPERATORS.put("<", new Integer(OPERATOR_LESS_THAN));
-        OPERATORS.put("<=", new Integer(OPERATOR_LESS_THAN_OR_EQUAL_TO));
-        OPERATORS.put("like", new Integer(OPERATOR_LIKE));
-        OPERATORS.put("!=", new Integer(OPERATOR_NOT_EQUAL_TO));
+        OPERATORS.put("=", JCR_OPERATOR_EQUAL_TO);
+        OPERATORS.put(">", JCR_OPERATOR_GREATER_THAN);
+        OPERATORS.put(">=", JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO);
+        OPERATORS.put("<", JCR_OPERATOR_LESS_THAN);
+        OPERATORS.put("<=", JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO);
+        OPERATORS.put("like", JCR_OPERATOR_LIKE);
+        OPERATORS.put("!=", JCR_OPERATOR_NOT_EQUAL_TO);
     }
 
     public void testEqualsGeneralComparison() throws RepositoryException {
@@ -261,7 +262,7 @@
         for (NodeIterator it = testRootNode.getNodes(); it.hasNext();) {
             it.nextNode().remove();
         }
-        Set matchingNodes = new HashSet();
+        Set<Node> matchingNodes = new HashSet<Node>();
         for (int i = 0; i < values.length; i++) {
             Node n = testRootNode.addNode("node" + i);
             n.setProperty(propertyName1, values[i]);
@@ -271,7 +272,7 @@
         }
         testRootNode.save();
 
-        Node[] nodes = (Node[]) matchingNodes.toArray(new Node[matchingNodes.size()]);
+        Node[] nodes = matchingNodes.toArray(new Node[matchingNodes.size()]);
         String sqlOperation = operation;
         if (operation.equals("!=")) {
             sqlOperation = "<>";
@@ -344,11 +345,7 @@
         return pool.charAt(random.nextInt(pool.length()));
     }
 
-    protected static int getOperatorForString(String operator) {
-        Integer i = (Integer) OPERATORS.get(operator);
-        if (i == null) {
-            throw new IllegalArgumentException("unknown operator: " + operator);
-        }
-        return i.intValue();
+    protected static String getOperatorForString(String operator) {
+        return OPERATORS.get(operator);
     }
 }



Mime
View raw message