jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r430370 - in /jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core: ConcurrentLoginTest.java TestAll.java
Date Thu, 10 Aug 2006 13:03:06 GMT
Author: mreutegg
Date: Thu Aug 10 06:03:05 2006
New Revision: 430370

URL: http://svn.apache.org/viewvc?rev=430370&view=rev
Log:
JCR-539: Concurrent Repository.login() throws IllegalStateException
- Test case to reproduce issue

Added:
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/ConcurrentLoginTest.java
  (with props)
Modified:
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/TestAll.java

Added: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/ConcurrentLoginTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/ConcurrentLoginTest.java?rev=430370&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/ConcurrentLoginTest.java
(added)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/ConcurrentLoginTest.java
Thu Aug 10 06:03:05 2006
@@ -0,0 +1,86 @@
+/*
+ * 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.core;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Credentials;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Iterator;
+
+/**
+ * <code>ConcurrentLoginTest</code> starts multiple threads and repeatedly does
+ * a {@link javax.jcr.Repository#login(javax.jcr.Credentials)}.
+ */
+public class ConcurrentLoginTest extends AbstractJCRTest {
+
+    /**
+     * The number of threads.
+     */
+    private static final int NUM_THREADS = 10;
+
+    /**
+     * The number of login calls each thread will do in a test run.
+     */
+    private static final int NUM_LOGINS_PER_THREAD = 100;
+
+    /**
+     * Tests concurrent logins on the Repository.
+     */
+    public void testLogin() throws RepositoryException {
+        final Exception[] exception = new Exception[1];
+        List testRunner = new ArrayList();
+        for (int i = 0; i < NUM_THREADS; i++) {
+            testRunner.add(new Thread(new Runnable() {
+                public void run() {
+                    Credentials cred = helper.getSuperuserCredentials();
+                    for (int i = 0; i < NUM_LOGINS_PER_THREAD; i++) {
+                        try {
+                            Session s = helper.getRepository().login(cred);
+                            // immediately logout
+                            s.logout();
+                        } catch (Exception e) {
+                            exception[0] = e;
+                            break;
+                        }
+                    }
+                }
+            }));
+        }
+
+        // start threads
+        for (Iterator it = testRunner.iterator(); it.hasNext(); ) {
+            ((Thread) it.next()).start();
+        }
+
+        // join threads
+        for (Iterator it = testRunner.iterator(); it.hasNext(); ) {
+            try {
+                ((Thread) it.next()).join();
+            } catch (InterruptedException e) {
+                fail(e.toString());
+            }
+        }
+
+        if (exception[0] != null) {
+            fail(exception[0].toString());
+        }
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/ConcurrentLoginTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/TestAll.java?rev=430370&r1=430369&r2=430370&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/TestAll.java (original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/core/TestAll.java Thu
Aug 10 06:03:05 2006
@@ -41,6 +41,7 @@
         suite.addTestSuite(NamespaceRegistryImplTest.class);
         suite.addTestSuite(TransientRepositoryTest.class);
         suite.addTestSuite(XATest.class);
+        suite.addTestSuite(ConcurrentLoginTest.class);
 
         return suite;
     }



Mime
View raw message