jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r784680 - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/ jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/a...
Date Mon, 15 Jun 2009 08:06:18 GMT
Author: mreutegg
Date: Mon Jun 15 08:06:17 2009
New Revision: 784680

URL: http://svn.apache.org/viewvc?rev=784680&view=rev
Log:
JCR-2076: JSR 283: QOM and SQL2
- test case

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/constraint/ConstraintBuilder.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/query/qom/UpperLowerCaseTest.java

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=784680&r1=784679&r2=784680&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 08:06:17 2009
@@ -237,7 +237,7 @@
 
         public Object visit(LowerCaseImpl node, Object data) throws Exception {
             DynamicOperandImpl operand = (DynamicOperandImpl) node.getOperand();
-            return new LowerCaseOperand((DynamicOperand) operand.accept(this, null));
+            return new LowerCaseOperand((DynamicOperand) operand.accept(this, data));
         }
 
         public Object visit(NodeLocalNameImpl node, Object data) throws Exception {
@@ -334,7 +334,7 @@
 
         public Object visit(UpperCaseImpl node, Object data) throws Exception {
             DynamicOperandImpl operand = (DynamicOperandImpl) node.getOperand();
-            return new UpperCaseOperand((DynamicOperand) operand.accept(this, null));
+            return new UpperCaseOperand((DynamicOperand) operand.accept(this, data));
         }
 
         private SelectorImpl getSelector(Name name) {

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=784680&r1=784679&r2=784680&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 08:06:17 2009
@@ -554,6 +554,21 @@
     }
 
     /**
+     * Returns the local name for the given <code>name</code>.
+     *
+     * @param name the name.
+     * @return the local name part.
+     */
+    protected static String getLocalName(String name) {
+        int idx = name.indexOf(':');
+        if (idx != -1) {
+            return name.substring(idx + 1);
+        } else {
+            return name;
+        }
+    }
+
+    /**
      * Returns the name of a workspace that is not accessible from
      * <code>session</code>.
      * @param session the session.

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=784680&r1=784679&r2=784680&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 08:06:17 2009
@@ -41,7 +41,7 @@
         node = testRootNode.addNode(nodeName1, testNodeType);
         node.setProperty(propertyName1, "abc");
         node.setProperty(propertyName2, "ABC");
-        testRootNode.save();
+        superuser.save();
     }
 
     protected void tearDown() throws Exception {
@@ -50,48 +50,54 @@
         super.tearDown();
     }
 
-    public void testFullTextSearchScore() throws RepositoryException {
-        // TODO
-    }
-
     public void testLength() throws RepositoryException {
-        // TODO
+        String lenStr = String.valueOf(node.getProperty(propertyName1).getLength());
+        // upper case
+        checkQueries(qf.length(qf.propertyValue("s", propertyName1)),
+                true, QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO,
+                new String[]{lenStr.toUpperCase()},
+                PropertyType.STRING,
+                new boolean[]{true});
+
+        // lower case
+        checkQueries(qf.length(qf.propertyValue("s", propertyName1)),
+                false, QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO,
+                new String[]{lenStr.toLowerCase()},
+                PropertyType.STRING,
+                new boolean[]{true});
     }
 
     public void testNodeLocalName() throws RepositoryException {
-        // TODO
+        String localName = getLocalName(node.getName());
+        // upper case
+        checkQueries(qf.nodeLocalName("s"),
+                true, QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO,
+                new String[]{localName.toLowerCase(), localName.toUpperCase()},
+                PropertyType.STRING,
+                new boolean[]{false, true});
+
+        // lower case
+        checkQueries(qf.nodeLocalName("s"),
+                false, QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO,
+                new String[]{localName.toLowerCase(), localName.toUpperCase()},
+                PropertyType.STRING,
+                new boolean[]{true, false});
     }
 
     public void testNodeName() throws RepositoryException {
-        node.setProperty(propertyName1, "abc", PropertyType.NAME);
-        node.setProperty(propertyName2, "ABC", PropertyType.NAME);
-        node.save();
-
         // upper case
-        checkQueries(qf.propertyValue("s", propertyName1),
+        checkQueries(qf.nodeName("s"),
                 true, QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO,
-                new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
+                new String[]{node.getName().toLowerCase(), node.getName().toUpperCase()},
                 PropertyType.NAME,
-                new boolean[]{false, false, false, false, true});
-
-        checkQueries(qf.propertyValue("s", propertyName2),
-                true, QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO,
-                new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
-                PropertyType.NAME,
-                new boolean[]{false, false, false, false, true});
+                new boolean[]{false, true});
 
         // lower case
-        checkQueries(qf.propertyValue("s", propertyName1),
+        checkQueries(qf.nodeName("s"),
                 false, QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO,
-                new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
-                PropertyType.NAME,
-                new boolean[]{true, false, false, false, false});
-
-        checkQueries(qf.propertyValue("s", propertyName2),
-                false, QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO,
-                new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
+                new String[]{node.getName().toLowerCase(), node.getName().toUpperCase()},
                 PropertyType.NAME,
-                new boolean[]{true, false, false, false, false});
+                new boolean[]{true, false});
     }
 
     public void testPropertyValue() throws RepositoryException {



Mime
View raw message