jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r770704 - in /jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom: QueryObjectModelFactoryTest.java UpperLowerCaseTest.java
Date Fri, 01 May 2009 14:57:23 GMT
Author: jukka
Date: Fri May  1 14:57:23 2009
New Revision: 770704

URL: http://svn.apache.org/viewvc?rev=770704&view=rev
Log:
JCR-2094: Use an enumeration for QOM operators

Updated more test cases to use the Operator enumeration. This works around the problems caused
by the incorrect QOM constants in JCR 2.0 PFD.

Modified:
    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/UpperLowerCaseTest.java

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=770704&r1=770703&r2=770704&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 14:57:23 2009
@@ -164,7 +164,7 @@
         Column col = qomFactory.column(SELECTOR_NAME1, propertyName1, null);
         assertEquals("Wrong selector name", SELECTOR_NAME1, col.getSelectorName());
         assertEquals("Wrong property name", propertyName1, col.getPropertyName());
-        assertEquals("Wrong column name", propertyName1, col.getColumnName());
+        assertNull("Column name must be null", col.getColumnName());
     }
 
     /**
@@ -207,7 +207,7 @@
             Comparison comp = operator.comparison(qomFactory, op1, op2);
             assertTrue("Not a PropertyValue operand", comp.getOperand1() instanceof PropertyValue);
             assertTrue("Not a BindVariableValue operand", comp.getOperand2() instanceof BindVariableValue);
-            assertEquals("Wrong operator", operator, comp.getOperator());
+            assertEquals("Wrong operator", operator.toString(), comp.getOperator());
         }
     }
 
@@ -310,7 +310,7 @@
      */
     public void testDescendantNode() throws RepositoryException {
         DescendantNode descNode = qomFactory.descendantNode(SELECTOR_NAME1, testRootNode.getPath());
-        assertNull("Selector must be null", descNode.getSelectorName());
+        assertEquals("Wrong selector", SELECTOR_NAME1, descNode.getSelectorName());
         assertEquals("Wrong path", testRootNode.getPath(), descNode.getAncestorPath());
     }
 
@@ -389,7 +389,7 @@
      */
     public void testFullTextSearchScore() throws RepositoryException {
         FullTextSearchScore score = qomFactory.fullTextSearchScore(SELECTOR_NAME1);
-        assertNull("Selector must be null", score.getSelectorName());
+        assertEquals("Wrong selector name", SELECTOR_NAME1, score.getSelectorName());
     }
 
     /**
@@ -439,7 +439,7 @@
      */
     public void testNodeLocalName() throws RepositoryException {
         NodeLocalName localName = qomFactory.nodeLocalName(SELECTOR_NAME1);
-        assertNull("Selector name must be null", localName.getSelectorName());
+        assertEquals("Wrong selector name", SELECTOR_NAME1, localName.getSelectorName());
     }
 
     /**
@@ -455,7 +455,7 @@
      */
     public void testNodeName() throws RepositoryException {
         NodeName nodeName = qomFactory.nodeName(SELECTOR_NAME1);
-        assertNull("Selector name must be null", nodeName.getSelectorName());
+        assertEquals("Wrong selector name", SELECTOR_NAME1, nodeName.getSelectorName());
     }
 
     /**
@@ -493,7 +493,7 @@
      */
     public void testPropertyExistence() throws RepositoryException {
         PropertyExistence propExist = qomFactory.propertyExistence(SELECTOR_NAME1, propertyName1);
-        assertNull("Selector name must be null", propExist.getSelectorName());
+        assertEquals("Wrong selector", SELECTOR_NAME1, propExist.getSelectorName());
         assertEquals("Wrong property name", propertyName1, propExist.getPropertyName());
     }
 
@@ -511,7 +511,7 @@
      */
     public void testPropertyValue() throws RepositoryException {
         PropertyValue propVal = qomFactory.propertyValue(SELECTOR_NAME1, propertyName1);
-        assertNull("Selector name must be null", propVal.getSelectorName());
+        assertEquals("Wrong selector name", SELECTOR_NAME1, propVal.getSelectorName());
         assertEquals("Wrong property name", propertyName1, propVal.getPropertyName());
     }
 
@@ -529,7 +529,7 @@
      */
     public void testSameNode() throws RepositoryException {
         SameNode sameNode = qomFactory.sameNode(SELECTOR_NAME1, testRootNode.getPath());
-        assertNull("Selector name must be null", sameNode.getSelectorName());
+        assertEquals("Wrong selector name", SELECTOR_NAME1, sameNode.getSelectorName());
         assertEquals("Wrong path", testRootNode.getPath(), sameNode.getPath());
     }
 
@@ -549,7 +549,7 @@
         SameNodeJoinCondition cond = qomFactory.sameNodeJoinCondition(SELECTOR_NAME1, SELECTOR_NAME2,
".");
         assertEquals("Wrong selector name", SELECTOR_NAME1, cond.getSelector1Name());
         assertEquals("Wrong selector name", SELECTOR_NAME2, cond.getSelector2Name());
-        assertNull("Path must be null", cond.getSelector2Path());
+        assertEquals("Wrong selector path", ".", cond.getSelector2Path());
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/UpperLowerCaseTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/UpperLowerCaseTest.java?rev=770704&r1=770703&r2=770704&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/UpperLowerCaseTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/UpperLowerCaseTest.java
Fri May  1 14:57:23 2009
@@ -24,6 +24,8 @@
 import javax.jcr.query.Query;
 import javax.jcr.query.qom.DynamicOperand;
 
+import org.apache.jackrabbit.spi.commons.query.qom.Operator;
+
 /**
  * <code>UpperLowerCaseTest</code> performs tests with upper- and lower-case
  * operands.
@@ -68,26 +70,26 @@
 
         // upper case
         checkQueries(qomFactory.propertyValue("s", propertyName1),
-                true, JCR_OPERATOR_EQUAL_TO,
+                true, Operator.EQ,
                 new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
                 PropertyType.NAME,
                 new boolean[]{false, false, false, false, true});
 
         checkQueries(qomFactory.propertyValue("s", propertyName2),
-                true, JCR_OPERATOR_EQUAL_TO,
+                true, Operator.EQ,
                 new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
                 PropertyType.NAME,
                 new boolean[]{false, false, false, false, true});
 
         // lower case
         checkQueries(qomFactory.propertyValue("s", propertyName1),
-                false, JCR_OPERATOR_EQUAL_TO,
+                false, Operator.EQ,
                 new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
                 PropertyType.NAME,
                 new boolean[]{true, false, false, false, false});
 
         checkQueries(qomFactory.propertyValue("s", propertyName2),
-                false, JCR_OPERATOR_EQUAL_TO,
+                false, Operator.EQ,
                 new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
                 PropertyType.NAME,
                 new boolean[]{true, false, false, false, false});
@@ -96,26 +98,26 @@
     public void testPropertyValue() throws RepositoryException {
         // upper case
         checkQueries(qomFactory.propertyValue("s", propertyName1),
-                true, JCR_OPERATOR_EQUAL_TO,
+                true, Operator.EQ,
                 new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
                 PropertyType.STRING,
                 new boolean[]{false, false, false, false, true});
 
         checkQueries(qomFactory.propertyValue("s", propertyName2),
-                true, JCR_OPERATOR_EQUAL_TO,
+                true, Operator.EQ,
                 new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
                 PropertyType.STRING,
                 new boolean[]{false, false, false, false, true});
 
         // lower case
         checkQueries(qomFactory.propertyValue("s", propertyName1),
-                false, JCR_OPERATOR_EQUAL_TO,
+                false, Operator.EQ,
                 new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
                 PropertyType.STRING,
                 new boolean[]{true, false, false, false, false});
 
         checkQueries(qomFactory.propertyValue("s", propertyName2),
-                false, JCR_OPERATOR_EQUAL_TO,
+                false, Operator.EQ,
                 new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
                 PropertyType.STRING,
                 new boolean[]{true, false, false, false, false});
@@ -124,7 +126,7 @@
     public void testUpperLowerCase() throws RepositoryException {
         // first upper case, then lower case again
         checkQueries(qomFactory.upperCase(qomFactory.propertyValue("s", propertyName1)),
-                false, JCR_OPERATOR_EQUAL_TO,
+                false, Operator.EQ,
                 new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
                 PropertyType.STRING,
                 new boolean[]{true, false, false, false, false});
@@ -133,7 +135,7 @@
     public void testUpperCaseTwice() throws RepositoryException {
         // upper case twice
         checkQueries(qomFactory.upperCase(qomFactory.propertyValue("s", propertyName1)),
-                true, JCR_OPERATOR_EQUAL_TO,
+                true, Operator.EQ,
                 new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
                 PropertyType.STRING,
                 new boolean[]{false, false, false, false, true});
@@ -142,7 +144,7 @@
     public void testLowerUpperCase() throws RepositoryException {
         // first lower case, then upper case again
         checkQueries(qomFactory.lowerCase(qomFactory.propertyValue("s", propertyName1)),
-                true, JCR_OPERATOR_EQUAL_TO,
+                true, Operator.EQ,
                 new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
                 PropertyType.STRING,
                 new boolean[]{false, false, false, false, true});
@@ -151,7 +153,7 @@
     public void testLowerCaseTwice() throws RepositoryException {
         // lower case twice
         checkQueries(qomFactory.lowerCase(qomFactory.propertyValue("s", propertyName1)),
-                false, JCR_OPERATOR_EQUAL_TO,
+                false, Operator.EQ,
                 new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
                 PropertyType.STRING,
                 new boolean[]{true, false, false, false, false});
@@ -161,7 +163,7 @@
 
     private void checkQueries(DynamicOperand operand,
                               boolean toUpper,
-                              String operator,
+                              Operator operator,
                               String[] literals,
                               int type,
                               boolean[] matches) throws RepositoryException {
@@ -173,7 +175,7 @@
     
     private Query createQuery(DynamicOperand operand,
                               boolean toUpper,
-                              String operator,
+                              Operator operator,
                               Value literal) throws RepositoryException {
         if (toUpper) {
             operand = qomFactory.upperCase(operand);
@@ -184,11 +186,10 @@
                 qomFactory.selector(testNodeType, "s"),
                 qomFactory.and(
                         qomFactory.childNode("s", testRoot),
-                        qomFactory.comparison(
+                        operator.comparison(
+                                qomFactory,
                                 operand,
-                                operator,
-                                qomFactory.literal(literal)
-                        )
+                                qomFactory.literal(literal))
                 ), null, null);
     }
 }



Mime
View raw message