jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r770714 - /jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/
Date Fri, 01 May 2009 15:33:38 GMT
Author: jukka
Date: Fri May  1 15:33:38 2009
New Revision: 770714

URL: http://svn.apache.org/viewvc?rev=770714&view=rev
Log:
JCR-2095: Use an enumeration for QOM join types

Update tests to use the JoinType enumeration to avoid failures due to incorrect QOM constants

Modified:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/AbstractJoinTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/ChildNodeJoinConditionTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/DescendantNodeJoinConditionTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/EquiJoinConditionTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/QueryObjectModelFactoryTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/SameNodeJoinConditionTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/SelectorTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/AbstractJoinTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/AbstractJoinTest.java?rev=770714&r1=770713&r2=770714&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/AbstractJoinTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/AbstractJoinTest.java
Fri May  1 15:33:38 2009
@@ -20,9 +20,12 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.query.QueryResult;
 import javax.jcr.query.qom.Constraint;
+import javax.jcr.query.qom.Join;
 import javax.jcr.query.qom.JoinCondition;
 import javax.jcr.query.qom.QueryObjectModel;
 
+import org.apache.jackrabbit.spi.commons.query.qom.JoinType;
+
 /**
  * <code>AbstractJoinTest</code> provides utility methods for join related
  * tests.
@@ -51,20 +54,20 @@
         checkResult(result, SELECTOR_NAMES, nodes);
     }
 
-    protected QueryObjectModel createQuery(String joinType,
+    protected QueryObjectModel createQuery(JoinType joinType,
                                            JoinCondition condition)
             throws RepositoryException {
         return createQuery(joinType, condition, null, null);
     }
 
-    protected QueryObjectModel createQuery(String joinType,
+    protected QueryObjectModel createQuery(JoinType joinType,
                                            JoinCondition condition,
                                            Constraint left,
                                            Constraint right)
             throws RepositoryException {
         // only consider nodes under test root
         Constraint constraint;
-        if (JCR_JOIN_TYPE_LEFT_OUTER.equals(joinType)) {
+        if (JoinType.LEFT == joinType) {
             constraint = qomFactory.descendantNode(LEFT, testRoot);
         } else {
             constraint = qomFactory.descendantNode(RIGHT, testRoot);
@@ -76,13 +79,11 @@
         if (right != null) {
             constraint = qomFactory.and(constraint, right);
         }
-        return qomFactory.createQuery(
-                qomFactory.join(
-                        qomFactory.selector(testNodeType, LEFT),
-                        qomFactory.selector(testNodeType, RIGHT),
-                        joinType,
-                        condition
-                ), constraint, null, null
-        );
+        Join join = joinType.join(
+                qomFactory,
+                qomFactory.selector(testNodeType, LEFT),
+                qomFactory.selector(testNodeType, RIGHT),
+                condition);
+        return qomFactory.createQuery(join, constraint, null, null);
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/ChildNodeJoinConditionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/ChildNodeJoinConditionTest.java?rev=770714&r1=770713&r2=770714&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/ChildNodeJoinConditionTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/ChildNodeJoinConditionTest.java
Fri May  1 15:33:38 2009
@@ -24,6 +24,8 @@
 import javax.jcr.query.qom.JoinCondition;
 import javax.jcr.query.qom.QueryObjectModel;
 
+import org.apache.jackrabbit.spi.commons.query.qom.JoinType;
+
 /**
  * <code>ChildNodeJoinConditionTest</code> contains test cases that cover
  * <code>ChildNodeJoinCondition</code>.
@@ -44,19 +46,19 @@
 
     public void testInnerJoin() throws RepositoryException {
         JoinCondition c = qomFactory.childNodeJoinCondition(LEFT, RIGHT);
-        QueryObjectModel qom = createQuery(JCR_JOIN_TYPE_INNER, c);
+        QueryObjectModel qom = createQuery(JoinType.INNER, c);
         checkResult(qom.execute(), new Node[][]{{n2, n1}});
     }
 
     public void testRightOuterJoin() throws RepositoryException {
         JoinCondition c = qomFactory.childNodeJoinCondition(LEFT, RIGHT);
-        QueryObjectModel qom = createQuery(JCR_JOIN_TYPE_RIGHT_OUTER, c);
+        QueryObjectModel qom = createQuery(JoinType.RIGHT, c);
         checkResult(qom.execute(), new Node[][]{{n2, n1}, {null, n2}});
     }
 
     public void testLeftOuterJoin() throws RepositoryException {
         JoinCondition c = qomFactory.childNodeJoinCondition(LEFT, RIGHT);
-        QueryObjectModel qom = createQuery(JCR_JOIN_TYPE_LEFT_OUTER, c);
+        QueryObjectModel qom = createQuery(JoinType.LEFT, c);
         List result = new ArrayList();
         result.add(new Node[]{n2, n1});
         if (testRootNode.isNodeType(testNodeType)) {

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/DescendantNodeJoinConditionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/DescendantNodeJoinConditionTest.java?rev=770714&r1=770713&r2=770714&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/DescendantNodeJoinConditionTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/DescendantNodeJoinConditionTest.java
Fri May  1 15:33:38 2009
@@ -24,6 +24,8 @@
 import javax.jcr.query.qom.JoinCondition;
 import javax.jcr.query.qom.QueryObjectModel;
 
+import org.apache.jackrabbit.spi.commons.query.qom.JoinType;
+
 /**
  * <code>DescendantNodeJoinConditionTest</code> contains test cases that cover
  * <code>DescendantNodeJoinCondition</code>.
@@ -44,19 +46,19 @@
 
     public void testInnerJoin() throws RepositoryException {
         JoinCondition c = qomFactory.descendantNodeJoinCondition(LEFT, RIGHT);
-        QueryObjectModel qom = createQuery(JCR_JOIN_TYPE_INNER, c);
+        QueryObjectModel qom = createQuery(JoinType.INNER, c);
         checkResult(qom.execute(), new Node[][]{{n2, n1}});
     }
 
     public void testRightOuterJoin() throws RepositoryException {
         JoinCondition c = qomFactory.descendantNodeJoinCondition(LEFT, RIGHT);
-        QueryObjectModel qom = createQuery(JCR_JOIN_TYPE_RIGHT_OUTER, c);
+        QueryObjectModel qom = createQuery(JoinType.RIGHT, c);
         checkResult(qom.execute(), new Node[][]{{n2, n1}, {null, n2}});
     }
 
     public void testLeftOuterJoin() throws RepositoryException {
         JoinCondition c = qomFactory.descendantNodeJoinCondition(LEFT, RIGHT);
-        QueryObjectModel qom = createQuery(JCR_JOIN_TYPE_LEFT_OUTER, c);
+        QueryObjectModel qom = createQuery(JoinType.LEFT, c);
         List result = new ArrayList();
         result.add(new Node[]{n2, n1});
         // for each ancestor-or-self of testRootNode check

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/EquiJoinConditionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/EquiJoinConditionTest.java?rev=770714&r1=770713&r2=770714&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/EquiJoinConditionTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/EquiJoinConditionTest.java
Fri May  1 15:33:38 2009
@@ -21,6 +21,8 @@
 import javax.jcr.query.qom.JoinCondition;
 import javax.jcr.query.qom.QueryObjectModel;
 
+import org.apache.jackrabbit.spi.commons.query.qom.JoinType;
+
 /**
  * <code>EquiJoinConditionTest</code> contains test cases that cover
  * <code>EquiJoinCondition</code>.
@@ -47,35 +49,35 @@
     public void testInnerJoin1() throws RepositoryException {
         JoinCondition c = qomFactory.equiJoinCondition(
                 LEFT, propertyName1, RIGHT, propertyName2);
-        QueryObjectModel qom = createQuery(JCR_JOIN_TYPE_INNER, c);
+        QueryObjectModel qom = createQuery(JoinType.INNER, c);
         checkResult(qom.execute(), new Node[][]{{n1, n2}, {n2, n2}});
     }
 
     public void testInnerJoin2() throws RepositoryException {
         JoinCondition c = qomFactory.equiJoinCondition(
                 LEFT, propertyName2, RIGHT, propertyName1);
-        QueryObjectModel qom = createQuery(JCR_JOIN_TYPE_INNER, c);
+        QueryObjectModel qom = createQuery(JoinType.INNER, c);
         checkResult(qom.execute(), new Node[][]{{n2, n1}, {n2, n2}});
     }
 
     public void testRightOuterJoin1() throws RepositoryException {
         JoinCondition c = qomFactory.equiJoinCondition(
                 LEFT, propertyName1, RIGHT, propertyName2);
-        QueryObjectModel qom = createQuery(JCR_JOIN_TYPE_RIGHT_OUTER, c);
+        QueryObjectModel qom = createQuery(JoinType.RIGHT, c);
         checkResult(qom.execute(), new Node[][]{{null, n1}, {n1, n2}, {n2, n2}});
     }
 
     public void testRightOuterJoin2() throws RepositoryException {
         JoinCondition c = qomFactory.equiJoinCondition(
                 LEFT, propertyName2, RIGHT, propertyName1);
-        QueryObjectModel qom = createQuery(JCR_JOIN_TYPE_RIGHT_OUTER, c);
+        QueryObjectModel qom = createQuery(JoinType.RIGHT, c);
         checkResult(qom.execute(), new Node[][]{{n2, n1}, {n2, n2}});
     }
 
     public void testLeftOuterJoin1() throws RepositoryException {
         JoinCondition c = qomFactory.equiJoinCondition(
                 LEFT, propertyName1, RIGHT, propertyName2);
-        QueryObjectModel qom = createQuery(JCR_JOIN_TYPE_LEFT_OUTER, c);
+        QueryObjectModel qom = createQuery(JoinType.LEFT, c);
         checkResult(qom.execute(), new Node[][]{{n1, n2}, {n2, n2}});
     }
 
@@ -83,7 +85,7 @@
     public void testLeftOuterJoin2() throws RepositoryException {
         JoinCondition c = qomFactory.equiJoinCondition(
                 LEFT, propertyName2, RIGHT, propertyName1);
-        QueryObjectModel qom = createQuery(JCR_JOIN_TYPE_LEFT_OUTER, c);
+        QueryObjectModel qom = createQuery(JoinType.LEFT, c);
         checkResult(qom.execute(), new Node[][]{{n1, null}, {n2, n1}, {n2, n2}});
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/QueryObjectModelFactoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/QueryObjectModelFactoryTest.java?rev=770714&r1=770713&r2=770714&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/QueryObjectModelFactoryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/QueryObjectModelFactoryTest.java
Fri May  1 15:33:38 2009
@@ -16,9 +16,6 @@
  */
 package org.apache.jackrabbit.api.jsr283.query.qom;
 
-import java.util.HashSet;
-import java.util.Set;
-
 import javax.jcr.RepositoryException;
 import javax.jcr.query.qom.And;
 import javax.jcr.query.qom.BindVariableValue;
@@ -54,6 +51,7 @@
 import javax.jcr.query.qom.StaticOperand;
 import javax.jcr.query.qom.UpperCase;
 
+import org.apache.jackrabbit.spi.commons.query.qom.JoinType;
 import org.apache.jackrabbit.spi.commons.query.qom.Operator;
 
 /**
@@ -88,17 +86,6 @@
     private static final String FULLTEXT_SEARCH_EXPR = "foo -bar";
 
     /**
-     * Set of all possible join types.
-     */
-    private static final Set<String> JOIN_TYPES = new HashSet<String>();
-
-    static {
-        JOIN_TYPES.add(QueryObjectModelConstants.JCR_JOIN_TYPE_INNER);
-        JOIN_TYPES.add(QueryObjectModelConstants.JCR_JOIN_TYPE_LEFT_OUTER);
-        JOIN_TYPES.add(QueryObjectModelConstants.JCR_JOIN_TYPE_RIGHT_OUTER);
-    }
-
-    /**
      * Test case for {@link QueryObjectModelFactory#and(Constraint, Constraint)}
      */
     public void testAnd() throws RepositoryException {
@@ -407,11 +394,11 @@
         Selector s1 = qomFactory.selector(ntBase, SELECTOR_NAME1);
         Selector s2 = qomFactory.selector(testNodeType, SELECTOR_NAME1);
         JoinCondition cond = qomFactory.equiJoinCondition(ntBase, jcrPrimaryType, testNodeType,
jcrPrimaryType);
-        for (String joinType : JOIN_TYPES) {
-            Join join = qomFactory.join(s1, s2, joinType, cond);
+        for (JoinType joinType : JoinType.values()) {
+            Join join = joinType.join(qomFactory, s1, s2, cond);
             assertTrue("Not a selector source", join.getLeft() instanceof Selector);
             assertTrue("Not a selector source", join.getRight() instanceof Selector);
-            assertEquals("Wrong join type", joinType, join.getJoinType());
+            assertEquals("Wrong join type", joinType.toString(), join.getJoinType());
             assertTrue("Not an EquiJoinCondition", join.getJoinCondition() instanceof EquiJoinCondition);
         }
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/SameNodeJoinConditionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/SameNodeJoinConditionTest.java?rev=770714&r1=770713&r2=770714&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/SameNodeJoinConditionTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/SameNodeJoinConditionTest.java
Fri May  1 15:33:38 2009
@@ -22,6 +22,8 @@
 import javax.jcr.query.qom.JoinCondition;
 import javax.jcr.query.qom.QueryObjectModel;
 
+import org.apache.jackrabbit.spi.commons.query.qom.JoinType;
+
 /**
  * <code>SameNodeJoinConditionTest</code> contains test cases that cover
  * <code>SameNodeJoinCondition</code>.
@@ -41,13 +43,13 @@
     }
 
     public void testInnerJoin() throws RepositoryException {
-        QueryObjectModel qom = createQueryX(JCR_JOIN_TYPE_INNER, (String) null);
+        QueryObjectModel qom = createQuery(JoinType.INNER, (String) null);
         QueryResult result = qom.execute();
         checkResult(result, new Node[][]{{n1, n1}, {n2, n2}});
     }
 
     public void testInnerJoinWithPath() throws RepositoryException {
-        QueryObjectModel qom = createQueryX(JCR_JOIN_TYPE_INNER, nodeName2);
+        QueryObjectModel qom = createQuery(JoinType.INNER, nodeName2);
         QueryResult result = qom.execute();
         checkResult(result, new Node[][]{{n2, n1}});
     }
@@ -68,7 +70,7 @@
     }
 
     public void testLeftOuterJoinWithPath() throws RepositoryException {
-        QueryObjectModel qom = createQueryX(JCR_JOIN_TYPE_LEFT_OUTER, nodeName2);
+        QueryObjectModel qom = createQuery(JoinType.LEFT, nodeName2);
         QueryResult result = qom.execute();
         checkResult(result, new Node[][]{{n1, null}, {n2, n1}});
     }
@@ -105,7 +107,7 @@
 
     //-----------------------------< utilities >--------------------------------
 
-    private QueryObjectModel createQueryX(String joinType, String relPath)
+    private QueryObjectModel createQuery(JoinType joinType, String relPath)
             throws RepositoryException {
         JoinCondition c;
         if (relPath != null) {

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/SelectorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/SelectorTest.java?rev=770714&r1=770713&r2=770714&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/SelectorTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/SelectorTest.java
Fri May  1 15:33:38 2009
@@ -23,6 +23,8 @@
 import javax.jcr.query.InvalidQueryException;
 import javax.jcr.query.Query;
 
+import org.apache.jackrabbit.spi.commons.query.qom.JoinType;
+
 /**
  * <code>SelectorTest</code>...
  */
@@ -71,10 +73,10 @@
     public void testDuplicateNodeType() throws RepositoryException {
         try {
             Query q = qomFactory.createQuery(
-                    qomFactory.join(
+                    JoinType.INNER.join(
+                            qomFactory,
                             qomFactory.selector(testNodeType, "nt"),
                             qomFactory.selector(testNodeType, "nt"),
-                            JCR_JOIN_TYPE_INNER,
                             qomFactory.descendantNodeJoinCondition("nt", "nt")),
                     null, null, null);
             q.execute();



Mime
View raw message