jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1830878 - in /jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test: AbstractJCRTest.java api/SessionRemoveItemTest.java api/version/VersionHistoryTest.java api/version/VersionTest.java
Date Fri, 04 May 2018 04:49:09 GMT
Author: reschke
Date: Fri May  4 04:49:09 2018
New Revision: 1830878

URL: http://svn.apache.org/viewvc?rev=1830878&view=rev
Log:
JCR-4294: TCK tests should pass on repositories without locking support

Modified:
    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/SessionRemoveItemTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/VersionTest.java

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=1830878&r1=1830877&r2=1830878&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
Fri May  4 04:49:09 2018
@@ -728,6 +728,16 @@ public abstract class AbstractJCRTest ex
         }
     }
 
+    /**
+     * Checks that the repository supports locking, otherwise aborts with
+     * {@link NotExecutableException}.
+     * @throws NotExecutableException when the repository does not support locking
+     */
+    protected void ensureLockingSupported() throws RepositoryException, NotExecutableException
{
+        if (!isSupported(Repository.OPTION_LOCKING_SUPPORTED)) {
+            throw new NotExecutableException("This repository does not support locking.");
+        }
+    }
 
     private boolean canSetProperty(NodeType nodeType, String propertyName, int propertyType,
boolean isMultiple) {
         PropertyDefinition propDefs[] = nodeType.getPropertyDefinitions();

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SessionRemoveItemTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SessionRemoveItemTest.java?rev=1830878&r1=1830877&r2=1830878&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SessionRemoveItemTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SessionRemoveItemTest.java
Fri May  4 04:49:09 2018
@@ -94,6 +94,7 @@ public class SessionRemoveItemTest exten
     }
 
     public void testRemoveLockedNode() throws RepositoryException, NotExecutableException
{
+        ensureLockingSupported();
         ensureMixinType(removeNode, mixLockable);
         removeNode.save();
 

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java?rev=1830878&r1=1830877&r2=1830878&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/VersionHistoryTest.java
Fri May  4 04:49:09 2018
@@ -34,6 +34,7 @@ import javax.jcr.NodeIterator;
 import javax.jcr.Property;
 import javax.jcr.PropertyIterator;
 import javax.jcr.PropertyType;
+import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.Value;
@@ -532,6 +533,8 @@ public class VersionHistoryTest extends
             vHistory.getLock();
             fail("VersionHistory should not be lockable: VersionHistory.getLock() did not
throw a LockException");
         } catch (LockException success) {
+        } catch (UnsupportedRepositoryOperationException maybe) {
+            assertFalse(isSupported(Repository.OPTION_LOCKING_SUPPORTED));
         }
     }
 
@@ -540,6 +543,7 @@ public class VersionHistoryTest extends
      * javax.jcr.lock.LockException}
      */
     public void testGetLockJcr2() throws Exception {
+        ensureLockingSupported();
         try {
             vHistory.getSession().getWorkspace().getLockManager().getLock(vHistory.getPath());
             fail("VersionHistory should not be lockable: VersionHistory.getLock() did not
throw a LockException");
@@ -750,6 +754,7 @@ public class VersionHistoryTest extends
      * <code>false</code>
      */
     public void testHoldsLock() throws Exception {
+        ensureLockingSupported();
         assertFalse("VersionHistory.holdsLock() did not return false", vHistory.holdsLock());
     }
 
@@ -758,6 +763,7 @@ public class VersionHistoryTest extends
      * <code>false</code>
      */
     public void testHoldsLockJcr2() throws Exception {
+        ensureLockingSupported();
         assertFalse("VersionHistory.holdsLock() did not return false", vHistory.getSession().getWorkspace().getLockManager().holdsLock(vHistory.getPath()));
     }
 
@@ -790,6 +796,7 @@ public class VersionHistoryTest extends
      * <code>false</code>
      */
     public void testIsLockedJcr2() throws Exception {
+        ensureLockingSupported();
         assertFalse("VersionHistory.isLocked() did not return false", vHistory.getSession().getWorkspace().getLockManager().isLocked(vHistory.getPath()));
     }
 
@@ -837,6 +844,7 @@ public class VersionHistoryTest extends
      */
     @SuppressWarnings("deprecation")
     public void testLock() throws Exception {
+        ensureLockingSupported();
         try {
             vHistory.lock(true, true);
             fail("VersionHistory should not be lockable: VersionHistory.lock(true,true) did
not throw a LockException");
@@ -864,6 +872,7 @@ public class VersionHistoryTest extends
      * {@link javax.jcr.lock.LockException}
      */
     public void testLockJcr2() throws Exception {
+        ensureLockingSupported();
         LockManager lockManager = vHistory.getSession().getWorkspace().getLockManager();
         String path = vHistory.getPath();
         try {
@@ -1146,6 +1155,7 @@ public class VersionHistoryTest extends
      * javax.jcr.lock.LockException}
      */
     public void testUnlock() throws Exception {
+        ensureLockingSupported();
         try {
             vHistory.unlock();
             fail("VersionHistory should not be lockable: VersionHistory.unlock() did not
throw a LockException");
@@ -1158,6 +1168,7 @@ public class VersionHistoryTest extends
      * javax.jcr.lock.LockException}
      */
     public void testUnlockJcr2() throws Exception {
+        ensureLockingSupported();
         try {
             vHistory.getSession().getWorkspace().getLockManager().unlock(vHistory.getPath());
             fail("VersionHistory should not be lockable: VersionHistory.unlock() did not
throw a LockException");

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/VersionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/VersionTest.java?rev=1830878&r1=1830877&r2=1830878&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/VersionTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/VersionTest.java
Fri May  4 04:49:09 2018
@@ -29,6 +29,7 @@ import javax.jcr.ItemNotFoundException;
 import javax.jcr.PropertyIterator;
 import javax.jcr.Value;
 import javax.jcr.PropertyType;
+import javax.jcr.Repository;
 import javax.jcr.lock.LockException;
 import javax.jcr.lock.LockManager;
 
@@ -296,6 +297,8 @@ public class VersionTest extends Abstrac
             version.getLock();
             fail("Version should not be lockable: Version.getLock() did not throw a LockException");
         } catch (LockException success) {
+        } catch (UnsupportedRepositoryOperationException maybe) {
+            assertFalse(isSupported(Repository.OPTION_LOCKING_SUPPORTED));
         }
     }
 
@@ -304,6 +307,7 @@ public class VersionTest extends Abstrac
      * javax.jcr.lock.LockException}
      */
     public void testGetLockJcr2() throws Exception {
+        ensureLockingSupported();
         try {
             version.getSession().getWorkspace().getLockManager().getLock(version.getPath());
             fail("Version should not be lockable: Version.getLock() did not throw a LockException");
@@ -482,6 +486,7 @@ public class VersionTest extends Abstrac
      * Tests if <code>Version.holdsLock()</code> returns <code>false</code>
      */
     public void testHoldsLock() throws Exception {
+        ensureLockingSupported();
         assertFalse("Version.holdsLock() did not return false", version.holdsLock());
     }
 
@@ -489,6 +494,7 @@ public class VersionTest extends Abstrac
      * Tests if <code>Version.holdsLock()</code> returns <code>false</code>
      */
     public void testHoldsLockJcr2() throws Exception {
+        ensureLockingSupported();
         assertFalse("Version.holdsLock() did not return false", version.getSession().getWorkspace().getLockManager().holdsLock(version.getPath()));
     }
 
@@ -517,6 +523,7 @@ public class VersionTest extends Abstrac
      * Tests if <code>Version.isLocked()</code> returns <code>false</code>
      */
     public void testIsLockedJcr2() throws Exception {
+        ensureLockingSupported();
         assertFalse("Version.isLocked() did not return false", version.getSession().getWorkspace().getLockManager().isLocked(version.getPath()));
     }
 
@@ -570,6 +577,7 @@ public class VersionTest extends Abstrac
      * LockException}
      */
     public void testLock() throws Exception {
+        ensureLockingSupported();
         try {
             version.lock(true, true);
             fail("Version should not be lockable: Version.lock(true,true) did not throw a
LockException");
@@ -597,6 +605,7 @@ public class VersionTest extends Abstrac
      * LockException}
      */
     public void testLockJcr2() throws Exception {
+        ensureLockingSupported();
         LockManager lockManager = version.getSession().getWorkspace().getLockManager();
         String path = version.getPath();
         try {
@@ -884,6 +893,8 @@ public class VersionTest extends Abstrac
             version.unlock();
             fail("Version should not be lockable: Version.unlock() did not throw a LockException");
         } catch (LockException success) {
+        } catch (UnsupportedRepositoryOperationException maybe) {
+            assertFalse(isSupported(Repository.OPTION_LOCKING_SUPPORTED));
         }
     }
 
@@ -892,6 +903,7 @@ public class VersionTest extends Abstrac
      * javax.jcr.lock.LockException}
      */
     public void testUnlockJcr2() throws Exception {
+        ensureLockingSupported();
         try {
             version.getSession().getWorkspace().getLockManager().unlock(version.getPath());
             fail("Version should not be lockable: Version.unlock() did not throw a LockException");



Mime
View raw message