jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r784091 - in /jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom: OrderingTest.java TestAll.java
Date Fri, 12 Jun 2009 12:21:58 GMT
Author: mreutegg
Date: Fri Jun 12 12:21:58 2009
New Revision: 784091

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

Added:
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/OrderingTest.java
  (with props)
Modified:
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/TestAll.java

Added: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/OrderingTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/OrderingTest.java?rev=784091&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/OrderingTest.java
(added)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/OrderingTest.java
Fri Jun 12 12:21:58 2009
@@ -0,0 +1,71 @@
+/*
+ * 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.JoinCondition;
+import javax.jcr.query.qom.QueryObjectModel;
+import javax.jcr.query.qom.QueryObjectModelConstants;
+import javax.jcr.query.qom.Ordering;
+
+/**
+ * <code>OrderingTest</code> contains test cases that check 
+ */
+public class OrderingTest extends AbstractJoinTest {
+
+    private Node n1;
+
+    private Node n2;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        String value = "a";
+        n1 = testRootNode.addNode(nodeName1, testNodeType);
+        n1.setProperty(propertyName1, value);
+        n1.setProperty(propertyName2, "b");
+
+        n2 = n1.addNode(nodeName2, testNodeType);
+        n2.setProperty(propertyName1, value);
+        n2.setProperty(propertyName2, value);
+        superuser.save();
+    }
+
+    public void testMultipleSelectors() throws RepositoryException {
+        // ascending
+        Ordering[] orderings = new Ordering[]{
+                qf.ascending(qf.propertyValue(RIGHT, propertyName2))
+        };
+        QueryObjectModel qom = createQuery(orderings);
+        checkResultOrder(qom.execute(), SELECTOR_NAMES, new Node[][]{{n2, n2}, {n1, n2}});
+
+        // descending
+        orderings[0] = qf.descending(qf.propertyValue(RIGHT, propertyName2));
+        qom = createQuery(orderings);
+        checkResultOrder(qom.execute(), SELECTOR_NAMES, new Node[][]{{n1, n2}, {n2, n2}});
+    }
+
+    protected QueryObjectModel createQuery(Ordering[] orderings)
+            throws RepositoryException {
+        JoinCondition c = qf.equiJoinCondition(
+                LEFT, propertyName1, RIGHT, propertyName2);
+        QueryObjectModel qom = createQuery(
+                QueryObjectModelConstants.JCR_JOIN_TYPE_INNER, c);
+        return qf.createQuery(qom.getSource(), qom.getConstraint(),
+                orderings, qom.getColumns());
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/OrderingTest.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=784091&r1=784090&r2=784091&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
Fri Jun 12 12:21:58 2009
@@ -39,6 +39,7 @@
         suite.addTestSuite(LengthTest.class);
         suite.addTestSuite(NodeLocalNameTest.class);
         suite.addTestSuite(NodeNameTest.class);
+        suite.addTestSuite(OrderingTest.class);
         suite.addTestSuite(PropertyExistenceTest.class);
         suite.addTestSuite(QueryObjectModelFactoryTest.class);
         suite.addTestSuite(RowTest.class);



Mime
View raw message