jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r533162 - /jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentVersioningTest.java
Date Fri, 27 Apr 2007 16:44:54 GMT
Author: mreutegg
Date: Fri Apr 27 09:44:48 2007
New Revision: 533162

URL: http://svn.apache.org/viewvc?view=rev&rev=533162
Log:
JCR-672: Deadlock on concurrent save/checkin operations possible
- restore test case

Modified:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentVersioningTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentVersioningTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentVersioningTest.java?view=diff&rev=533162&r1=533161&r2=533162
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentVersioningTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentVersioningTest.java
Fri Apr 27 09:44:48 2007
@@ -21,6 +21,10 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.Node;
+import javax.jcr.version.Version;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Random;
 
 /**
  * <code>ConcurrentVersioningTest</code> contains test cases that run version
@@ -37,7 +41,7 @@
      * The total number of operations to execute. E.g. number of checkins
      * performed by the threads.
      */
-    private static final int NUM_OPERATIONS = 100;
+    private static final int NUM_OPERATIONS = 200;
 
     public void testConcurrentAddVersionable() throws RepositoryException {
         runTask(new Task() {
@@ -88,6 +92,33 @@
                         n.checkin();
                         n.checkout();
                     }
+                } finally {
+                    session.logout();
+                }
+            }
+        }, CONCURRENCY);
+    }
+
+    public void testConcurrentRestore() throws RepositoryException {
+        runTask(new Task() {
+            public void execute(Session session, Node test) throws RepositoryException {
+                try {
+                    Node n = test.addNode("test");
+                    n.addMixin(mixVersionable);
+                    session.save();
+                    // create 3 version
+                    List versions = new ArrayList();
+                    for (int i = 0; i < 3; i++) {
+                        n.checkout();
+                        versions.add(n.checkin());
+                    }
+                    // do random restores
+                    Random rand = new Random();
+                    for (int i = 0; i < NUM_OPERATIONS / CONCURRENCY; i++) {
+                        Version v = (Version) versions.get(rand.nextInt(versions.size()));
+                        n.restore(v, true);
+                    }
+                    n.checkout();
                 } finally {
                     session.logout();
                 }



Mime
View raw message