jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r513267 [2/2] - in /jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit: jcr2spi/ jcr2spi/lock/ jcr2spi/version/ test/
Date Thu, 01 Mar 2007 10:39:44 GMT
Modified: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/lock/OpenScopedLockTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/lock/OpenScopedLockTest.java?view=diff&rev=513267&r1=513266&r2=513267
==============================================================================
--- jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/lock/OpenScopedLockTest.java
(original)
+++ jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/lock/OpenScopedLockTest.java
Thu Mar  1 02:39:43 2007
@@ -21,6 +21,7 @@
 
 import javax.jcr.Node;
 import javax.jcr.Session;
+import javax.jcr.RepositoryException;
 import javax.jcr.lock.LockException;
 import javax.jcr.lock.Lock;
 
@@ -37,7 +38,7 @@
 
     public void testLogoutHasNoEffect() throws Exception {
         // create a second session session. since loggin-out the 'superuser'
-        // will cause all inhertied tear-down to fail
+        // will cause all inherited tear-down to fail
         Session otherSession = helper.getSuperuserSession();
         Node testRoot2 = (Node) otherSession.getItem(testRootNode.getPath());
 
@@ -85,7 +86,7 @@
         }
     }
 
-public void testRefreshAfterTokenTransfer2() throws Exception {
+    public void testRefreshAfterTokenTransfer2() throws Exception {
         String lockToken = lock.getLockToken();
 
         Session otherSession = helper.getSuperuserSession();
@@ -143,12 +144,53 @@
             // otherSession is now lockHolder -> unlock must succeed.
             Node n2 = (Node) otherSession.getItem(lockedNode.getPath());
             n2.unlock();
-        } finally {
+        } catch (RepositoryException e) {
+            // only in case of failure:
+            // move lock token back in order to have lock removed properly
+            // if test succeeds, moving back tokens is not necessary.
+            otherSession.removeLockToken(lockToken);
+            superuser.addLockToken(lockToken);
+
+            // and rethrow
+            throw e;
+        }
+    }
+
+    /**
+     * Test if a Lock created by one session gets properly invalidated
+     * if the lock token has been transfered to another session, which
+     * unlocks the Node.
+     */
+    public void testUnlockAfterTokenTransfer3() throws Exception {
+        String lockToken = lock.getLockToken();
+        Session otherSession = helper.getSuperuserSession();
+        try {
+            superuser.removeLockToken(lockToken);
+            otherSession.addLockToken(lockToken);
+
+            // otherSession is now lockHolder -> unlock must succeed.
+            Node n2 = (Node) otherSession.getItem(lockedNode.getPath());
+            n2.unlock();
+
+            assertFalse("Lock has been release by another session.", lockedNode.holdsLock());
+
+            assertFalse("Lock has been release by another session.", lock.isLive());
+            assertFalse("Lock has been release by another session.", lock.getNode().isLocked());
           
+            try {
+                lockedNode.getLock();
+                fail("Lock has been release by another session.");
+            } catch (LockException e) {
+                // ok
+            }
+        } catch (RepositoryException e) {
             // only in case of failure:
             // move lock token back in order to have lock removed properly
             // if test succeeds, moving back tokens is not necessary.
             otherSession.removeLockToken(lockToken);
             superuser.addLockToken(lockToken);
+
+            // and rethrow
+            throw e;
         }
     }
 }

Added: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/version/LabelTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/version/LabelTest.java?view=auto&rev=513267
==============================================================================
--- jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/version/LabelTest.java
(added)
+++ jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/version/LabelTest.java
Thu Mar  1 02:39:43 2007
@@ -0,0 +1,76 @@
+/*
+ * 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.jcr2spi.version;
+
+import org.apache.jackrabbit.test.api.version.VersionLabelTest;
+
+import java.util.Arrays;
+import java.util.List;
+import javax.jcr.RepositoryException;
+import javax.jcr.version.Version;
+
+public class LabelTest extends VersionLabelTest {
+
+    public void testRemovedLabel2() throws RepositoryException {
+        vHistory.addVersionLabel(rootVersion.getName(), versionLabel, false);
+        vHistory.removeVersionLabel(versionLabel);
+
+        List labels = Arrays.asList(vHistory.getVersionLabels());
+        assertFalse("VersionHistory.getVersionLabels() must not return a removed label.",labels.contains(versionLabel));
+    }
+
+    public void testRemovedLabel3() throws RepositoryException {
+        vHistory.addVersionLabel(rootVersion.getName(), versionLabel, false);
+        vHistory.removeVersionLabel(versionLabel);
+
+        List labels = Arrays.asList(vHistory.getVersionLabels(rootVersion));
+        assertFalse("VersionHistory.getVersionLabels(Version) must not return a removed label.",labels.contains(versionLabel));
+    }
+
+    public void testMoveLabel2() throws RepositoryException {
+        vHistory.addVersionLabel(rootVersion.getName(), versionLabel, false);
+
+        versionableNode.checkout();
+        Version v = versionableNode.checkin();
+        vHistory.addVersionLabel(v.getName(), versionLabel, true);
+
+        List labels = Arrays.asList(vHistory.getVersionLabels(v));
+        assertTrue(labels.contains(versionLabel));
+    }
+
+    public void testMoveLabel3() throws RepositoryException {
+        versionableNode.checkout();
+        Version v = versionableNode.checkin();
+
+        vHistory.addVersionLabel(rootVersion.getName(), versionLabel, false);
+        vHistory.addVersionLabel(v.getName(), versionLabel, true);
+
+        List labels = Arrays.asList(vHistory.getVersionLabels(rootVersion));
+        assertFalse(labels.contains(versionLabel));
+    }
+
+    public void testMoveLabel4() throws RepositoryException {
+        versionableNode.checkout();
+        Version v = versionableNode.checkin();
+
+        vHistory.addVersionLabel(rootVersion.getName(), versionLabel, false);
+        vHistory.addVersionLabel(v.getName(), versionLabel, true);
+
+        Version v2 = vHistory.getVersionByLabel(versionLabel);
+        assertTrue(v2.isSame(v));
+    }
+}

Modified: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/test/TestGeneralWrite.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/test/TestGeneralWrite.java?view=diff&rev=513267&r1=513266&r2=513267
==============================================================================
--- jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/test/TestGeneralWrite.java
(original)
+++ jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/test/TestGeneralWrite.java
Thu Mar  1 02:39:43 2007
@@ -49,19 +49,11 @@
 
     private static Logger log = LoggerFactory.getLogger(TestGeneralWrite.class);
 
-    /**
-     * Returns a <code>Test</code> suite that executes all tests inside this
-     * package.
-     *
-     * @return a <code>Test</code> suite that executes all tests inside this
-     *         package.
-     */
     public static Test suite() {
 
         TestSuite suite = new TestSuite("javax.jcr General-Write");
 
         suite.addTestSuite(CheckPermissionTest.class);
-
         suite.addTestSuite(NamespaceRegistryTest.class);
 
         suite.addTestSuite(SessionTest.class);

Modified: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/test/TestPropertyRead.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/test/TestPropertyRead.java?view=diff&rev=513267&r1=513266&r2=513267
==============================================================================
--- jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/test/TestPropertyRead.java
(original)
+++ jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/test/TestPropertyRead.java
Thu Mar  1 02:39:43 2007
@@ -41,13 +41,6 @@
 
     private static Logger log = LoggerFactory.getLogger(TestPropertyRead.class);
 
-    /**
-     * Returns a <code>Test</code> suite that executes all tests inside this
-     * package.
-     *
-     * @return a <code>Test</code> suite that executes all tests inside this
-     *         package.
-     */
     public static Test suite() {
 
         TestSuite suite = new TestSuite("javax.jcr Property-Read");



Mime
View raw message