You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by mr...@apache.org on 2006/08/03 16:34:08 UTC

svn commit: r428412 - in /jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/query: GetPersistentQueryPathTest.java SaveTest.java

Author: mreutegg
Date: Thu Aug  3 07:34:07 2006
New Revision: 428412

URL: http://svn.apache.org/viewvc?rev=428412&view=rev
Log:
JCR-528: TCK: GetPersistentQueryPathTest and SaveTest require nt:query

Modified:
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/query/GetPersistentQueryPathTest.java
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/query/SaveTest.java

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/query/GetPersistentQueryPathTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/query/GetPersistentQueryPathTest.java?rev=428412&r1=428411&r2=428412&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/query/GetPersistentQueryPathTest.java (original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/query/GetPersistentQueryPathTest.java Thu Aug  3 07:34:07 2006
@@ -16,8 +16,11 @@
  */
 package org.apache.jackrabbit.test.api.query;
 
+import org.apache.jackrabbit.test.NotExecutableException;
+
 import javax.jcr.query.Query;
 import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
 
 /**
  * Test the method {@link javax.jcr.query.Query#getStoredQueryPath()}.
@@ -34,10 +37,19 @@
 public class GetPersistentQueryPathTest extends AbstractQueryTest {
 
     /**
-     * Tests if {@link Query#getStoredQueryPath()} returns the correct
-     * path where the query had been saved.
+     * Tests if {@link Query#getStoredQueryPath()} returns the correct path
+     * where the query had been saved.
+     *
+     * @throws NotExecutableException if the repository does not support the
+     *                                node type nt:query.
      */
-    public void testGetPersistentQueryPath() throws RepositoryException {
+    public void testGetPersistentQueryPath() throws RepositoryException, NotExecutableException {
+        try {
+            superuser.getWorkspace().getNodeTypeManager().getNodeType(ntQuery);
+        } catch (NoSuchNodeTypeException e) {
+            // not supported
+            throw new NotExecutableException("repository does not support nt:query");
+        }
         String statement = "/" + jcrRoot;
         Query q = superuser.getWorkspace().getQueryManager().createQuery(statement, Query.XPATH);
         String path = testRoot + "/" + nodeName1;

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/query/SaveTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/query/SaveTest.java?rev=428412&r1=428411&r2=428412&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/query/SaveTest.java (original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/query/SaveTest.java Thu Aug  3 07:34:07 2006
@@ -25,6 +25,7 @@
 import javax.jcr.lock.LockException;
 import javax.jcr.version.VersionException;
 import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.query.Query;
 import org.apache.jackrabbit.test.AbstractJCRTest;
 import org.apache.jackrabbit.test.NotExecutableException;
@@ -50,8 +51,10 @@
     /**
      * Stores a {@link javax.jcr.query.Query.XPATH} query at:
      * <code>testRoot + "/" + nodeName1</code>.
+     * @throws NotExecutableException if nt:query is not supported.
      */
-    public void testSave() throws RepositoryException {
+    public void testSave() throws RepositoryException, NotExecutableException {
+        checkNtQuery();
         Query query = superuser.getWorkspace().getQueryManager().createQuery(statement, Query.XPATH);
         query.storeAsNode(testRoot + "/" + nodeName1);
 
@@ -67,8 +70,10 @@
     /**
      * Tests if an {@link javax.jcr.ItemExistsException} is thrown when a query
      * is stored on an existing node and same name siblings are not allowed.
+     * @throws NotExecutableException if nt:query is not supported.
      */
-    public void testItemExistsException() throws RepositoryException {
+    public void testItemExistsException() throws RepositoryException, NotExecutableException {
+        checkNtQuery();
         Query query = superuser.getWorkspace().getQueryManager().createQuery(statement, Query.XPATH);
         Node qNode = query.storeAsNode(testRoot + "/" + nodeName1);
 
@@ -93,8 +98,10 @@
     /**
      * Tests if a {@link javax.jcr.PathNotFoundException} is thrown when a query
      * is stored to a non existent path.
+     * @throws NotExecutableException if nt:query is not supported.
      */
-    public void testPathNotFoundException() throws RepositoryException {
+    public void testPathNotFoundException() throws RepositoryException, NotExecutableException {
+        checkNtQuery();
         Query query = superuser.getWorkspace().getQueryManager().createQuery(statement, Query.XPATH);
         try {
             query.storeAsNode(testRoot + "/" + nodeName1 + "/" + nodeName1);
@@ -113,8 +120,10 @@
      * not already versionable.
      * Then the test tries to store a query as <code>nodeName2</code> under node
      * <code>nodeName1</code>.
+     * @throws NotExecutableException if nt:query is not supported.
      */
     public void testVersionException() throws RepositoryException, NotExecutableException {
+        checkNtQuery();
         // check if repository supports versioning
         if (!isSupported(Repository.OPTION_VERSIONING_SUPPORTED)) {
             throw new NotExecutableException();
@@ -149,9 +158,10 @@
      * The test creates a node <code>nodeName1</code> of type <code>testNodeType</code>
      * under <code>testRoot</code>. Then the test tries to store a query as
      * <code>nodeName2</code> under <code>nodeName1</code>.
-     *
+     * @throws NotExecutableException if nt:query is not supported.
      */
-    public void testConstraintViolationException() throws RepositoryException {
+    public void testConstraintViolationException() throws RepositoryException, NotExecutableException {
+        checkNtQuery();
         Query query = superuser.getWorkspace().getQueryManager().createQuery(statement, Query.XPATH);
         testRootNode.addNode(nodeName1, testNodeType);
         try {
@@ -170,8 +180,10 @@
      * under <code>testRoot</code> and locks the node with the superuser session.
      * Then the test tries to store a query as <code>nodeName2</code> under
      * <code>nodeName1</code> with the readWrite <code>Session</code>.
+     * @throws NotExecutableException if nt:query is not supported.
      */
     public void testLockException() throws RepositoryException, NotExecutableException {
+        checkNtQuery();
         // check if repository supports locking
         if (!isSupported(Repository.OPTION_LOCKING_SUPPORTED)) {
             throw new NotExecutableException();
@@ -205,14 +217,33 @@
     /**
      * Tests if the a {@link javax.jcr.RepositoryException} is thrown when
      * an malformed path is passed in {@link javax.jcr.query.Query#storeAsNode(String)}.
+     * @throws NotExecutableException if nt:query is not supported.
      */
-    public void testRepositoryException() throws RepositoryException {
+    public void testRepositoryException() throws RepositoryException, NotExecutableException {
+        checkNtQuery();
         Query query = superuser.getWorkspace().getQueryManager().createQuery(statement, Query.XPATH);
         try {
             query.storeAsNode(testRoot + "/invalid[path");
             fail("Query.storeAsNode() must throw RepositoryException on malformed path.");
         } catch (RepositoryException e) {
             // expected behaviour
+        }
+    }
+
+    //-------------------------------< internal >-------------------------------
+
+    /**
+     * Checks if the repository supports the nt:query node type otherwise throws
+     * a <code>NotExecutableException</code>.
+     *
+     * @throws NotExecutableException if nt:query is not supported.
+     */
+    private void checkNtQuery() throws RepositoryException, NotExecutableException {
+        try {
+            superuser.getWorkspace().getNodeTypeManager().getNodeType(ntQuery);
+        } catch (NoSuchNodeTypeException e) {
+            // not supported
+            throw new NotExecutableException("repository does not support nt:query");
         }
     }
 }