jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r633523 - in /jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/qom: AbstractQOMTest.java ChildNodeTest.java SelectorTest.java
Date Tue, 04 Mar 2008 15:54:43 GMT
Author: mreutegg
Date: Tue Mar  4 07:54:42 2008
New Revision: 633523

URL: http://svn.apache.org/viewvc?rev=633523&view=rev
Log:
JCR-1104: JSR 283 support
- selector test cases

Modified:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/qom/AbstractQOMTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/qom/ChildNodeTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/qom/SelectorTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/qom/AbstractQOMTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/qom/AbstractQOMTest.java?rev=633523&r1=633522&r2=633523&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/qom/AbstractQOMTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/qom/AbstractQOMTest.java
Tue Mar  4 07:54:42 2008
@@ -19,12 +19,15 @@
 import org.apache.jackrabbit.test.api.query.AbstractQueryTest;
 
 import org.apache.jackrabbit.spi.commons.query.jsr283.qom.QueryObjectModelFactory;
+import org.apache.jackrabbit.spi.commons.query.jsr283.qom.QueryObjectModelConstants;
 import org.apache.jackrabbit.core.query.QueryManagerImpl;
 
 /**
  * <code>AbstractQOMTest</code> is a base class for test cases on the JQOM.
  */
-public class AbstractQOMTest extends AbstractQueryTest {
+public class AbstractQOMTest
+        extends AbstractQueryTest
+        implements QueryObjectModelConstants {
 
     protected QueryObjectModelFactory qomFactory;
 

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/qom/ChildNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/qom/ChildNodeTest.java?rev=633523&r1=633522&r2=633523&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/qom/ChildNodeTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/qom/ChildNodeTest.java
Tue Mar  4 07:54:42 2008
@@ -28,7 +28,6 @@
 
 /**
  * <code>ChildNodeTest</code>...
- * TODO: add tests with default selector
  */
 public class ChildNodeTest extends AbstractQOMTest {
 

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/qom/SelectorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/qom/SelectorTest.java?rev=633523&r1=633522&r2=633523&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/qom/SelectorTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/qom/SelectorTest.java
Tue Mar  4 07:54:42 2008
@@ -18,7 +18,10 @@
 
 import javax.jcr.RepositoryException;
 import javax.jcr.NodeIterator;
+import javax.jcr.nodetype.NodeTypeManager;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.query.Query;
+import javax.jcr.query.InvalidQueryException;
 
 /**
  * <code>SelectorTest</code>...
@@ -34,6 +37,66 @@
         NodeIterator it = q.execute().getNodes();
         while (it.hasNext()) {
             assertTrue("Wrong node type", it.nextNode().isNodeType(testNodeType));
+        }
+    }
+
+    public void testSyntacticallyInvalidName() throws RepositoryException {
+        try {
+            Query q = qomFactory.createQuery(
+                    qomFactory.selector(testNodeType + "["), null, null, null);
+            q.execute();
+            fail("Selector with syntactically invalid name must throw InvalidQueryException");
+        } catch (InvalidQueryException e) {
+            // expected
+        }
+    }
+
+    public void testUnknownNodeType() throws RepositoryException {
+        NodeTypeManager ntMgr = superuser.getWorkspace().getNodeTypeManager();
+        String ntName = testNodeType;
+        for (;;) {
+            try {
+                ntMgr.getNodeType(ntName);
+                ntName += "x";
+            } catch (NoSuchNodeTypeException e) {
+                break;
+            }
+        }
+        Query q = qomFactory.createQuery(qomFactory.selector(ntName),
+                null, null, null);
+        assertFalse("Selector must not select nodes for unknown node type",
+                q.execute().getNodes().hasNext());
+    }
+
+    public void testDuplicateNodeType() throws RepositoryException {
+        try {
+            Query q = qomFactory.createQuery(
+                    qomFactory.join(
+                            qomFactory.selector(testNodeType, "nt"),
+                            qomFactory.selector(testNodeType, "nt"),
+                            JOIN_TYPE_INNER,
+                            qomFactory.descendantNodeJoinCondition("nt", "nt")),
+                    null, null, null);
+            q.execute();
+            fail("Selector with two identical selector names must throw InvalidQueryException");
+        } catch (InvalidQueryException e) {
+            // expected
+        }
+
+        // using one argument selector method
+        try {
+            Query q = qomFactory.createQuery(
+                    qomFactory.join(
+                            qomFactory.selector(testNodeType),
+                            qomFactory.selector(testNodeType),
+                            JOIN_TYPE_INNER,
+                            qomFactory.descendantNodeJoinCondition(
+                                    testNodeType, testNodeType)),
+                    null, null, null);
+            q.execute();
+            fail("Selector with two identical selector names must throw InvalidQueryException");
+        } catch (InvalidQueryException e) {
+            // expected
         }
     }
 }



Mime
View raw message