jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r784090 - in /jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom: AbstractQOMTest.java QueryObjectModelFactoryTest.java
Date Fri, 12 Jun 2009 12:17:54 GMT
Author: mreutegg
Date: Fri Jun 12 12:17:54 2009
New Revision: 784090

URL: http://svn.apache.org/viewvc?rev=784090&view=rev
Log:
JCR-2085: test case (TCK) maintenance for JCR 2.0
- include test for QOM Literal

Modified:
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/AbstractQOMTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/QueryObjectModelFactoryTest.java

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/AbstractQOMTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/AbstractQOMTest.java?rev=784090&r1=784089&r2=784090&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/AbstractQOMTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/AbstractQOMTest.java
Fri Jun 12 12:17:54 2009
@@ -19,6 +19,8 @@
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
+import java.util.List;
+import java.util.ArrayList;
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
@@ -33,7 +35,7 @@
 /**
  * <code>AbstractQOMTest</code> is a base class for test cases on the JQOM.
  */
-public class AbstractQOMTest extends AbstractQueryTest {
+public abstract class AbstractQOMTest extends AbstractQueryTest {
 
     /**
      * Binds the given <code>value</code> to the variable named
@@ -51,6 +53,39 @@
         q.bindValue(var, value);
     }
 
+    protected void checkResultOrder(QueryResult result,
+                                    String[] selectorNames,
+                                    Node[][] nodes)
+            throws RepositoryException {
+        // collect rows
+        List expectedPaths = new ArrayList();
+        log.println("expected:");
+        for (int i = 0; i < nodes.length; i++) {
+            StringBuffer aggregatedPaths = new StringBuffer();
+            for (int j = 0; j < nodes[i].length; j++) {
+                aggregatedPaths.append(getPath(nodes[i][j]));
+                aggregatedPaths.append("|");
+            }
+            expectedPaths.add(aggregatedPaths.toString());
+            log.println(aggregatedPaths.toString());
+        }
+
+        List resultPaths = new ArrayList();
+        log.println("result:");
+        for (RowIterator it = result.getRows(); it.hasNext();) {
+            Row r = it.nextRow();
+            StringBuffer aggregatedPaths = new StringBuffer();
+            for (int i = 0; i < selectorNames.length; i++) {
+                aggregatedPaths.append(getPath(r.getNode(selectorNames[i])));
+                aggregatedPaths.append("|");
+            }
+            resultPaths.add(aggregatedPaths.toString());
+            log.println(aggregatedPaths.toString());
+        }
+
+        assertEquals("wrong result order", expectedPaths, resultPaths);
+    }
+
     protected void checkResult(QueryResult result,
                                String[] selectorNames,
                                Node[][] nodes)

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/QueryObjectModelFactoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/QueryObjectModelFactoryTest.java?rev=784090&r1=784089&r2=784090&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/QueryObjectModelFactoryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/QueryObjectModelFactoryTest.java
Fri Jun 12 12:17:54 2009
@@ -21,6 +21,7 @@
 import java.util.Set;
 
 import javax.jcr.RepositoryException;
+import javax.jcr.Value;
 import javax.jcr.query.qom.And;
 import javax.jcr.query.qom.BindVariableValue;
 import javax.jcr.query.qom.ChildNode;
@@ -54,6 +55,7 @@
 import javax.jcr.query.qom.Source;
 import javax.jcr.query.qom.StaticOperand;
 import javax.jcr.query.qom.UpperCase;
+import javax.jcr.query.qom.Literal;
 
 /**
  * <code>QueryObjectModelFactoryTest</code> tests all methods on the
@@ -425,7 +427,7 @@
             Join join = qf.join(s1, s2, joinType, cond);
             assertTrue("Not a selector source", join.getLeft() instanceof Selector);
             assertTrue("Not a selector source", join.getRight() instanceof Selector);
-            assertEquals("Wrong join type", joinType.toString(), join.getJoinType());
+            assertEquals("Wrong join type", joinType, join.getJoinType());
             assertTrue("Not an EquiJoinCondition", join.getJoinCondition() instanceof EquiJoinCondition);
         }
     }
@@ -440,6 +442,16 @@
     }
 
     /**
+     * Test case for {@link QueryObjectModelFactory#literal(Value)}
+     */
+    public void testLiteral() throws RepositoryException {
+        Value v = superuser.getValueFactory().createValue("test");
+        Literal literal = qf.literal(v);
+        assertEquals("Wrong literal value", v.getString(),
+                literal.getLiteralValue().getString());
+    }
+
+    /**
      * Test case for {@link QueryObjectModelFactory#lowerCase(DynamicOperand)}
      */
     public void testLowerCase() throws RepositoryException {



Mime
View raw message