jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r807993 - /jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java
Date Wed, 26 Aug 2009 13:09:03 GMT
Author: thomasm
Date: Wed Aug 26 13:09:02 2009
New Revision: 807993

URL: http://svn.apache.org/viewvc?rev=807993&view=rev
Log:
JCR-2162 Data Store: garbage collection continues when the session is closed - test case

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

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java?rev=807993&r1=807992&r2=807993&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java
Wed Aug 26 13:09:02 2009
@@ -41,6 +41,50 @@
     /** logger instance */
     private static final Logger LOG = LoggerFactory.getLogger(GarbageCollectorTest.class);
 
+    public void testCloseSessionWhileRunningGc() throws Exception {
+        final Session session = getHelper().getReadWriteSession();
+        RepositoryImpl rep = (RepositoryImpl) session.getRepository();
+        if (rep.getDataStore() == null) {
+            LOG.info("testConcurrentClose skipped. Data store is not used.");
+            return;
+        }
+        final GarbageCollector gc = ((SessionImpl) session).createDataStoreGarbageCollector();
+        final Exception[] ex = new Exception[1];
+        gc.setScanEventListener(new ScanEventListener() {
+            boolean closed;
+
+            public void afterScanning(Node n) throws RepositoryException {
+                closeTest();
+            }
+
+            public void beforeScanning(Node n) throws RepositoryException {
+                closeTest();
+            }
+
+            public void done() {
+            }
+
+            private void closeTest() throws RepositoryException {
+                if (closed) {
+                    ex[0] = new Exception("Scanning after the session is closed");
+                }
+                closed = true;
+                session.logout();
+            }
+
+        });
+        try {
+            gc.scan();
+            fail("Exception 'session has been closed' expected");
+        } catch (RepositoryException e) {
+            LOG.debug("Expected exception caught: " + e.getMessage());
+        }
+        if (ex[0] != null) {
+            throw ex[0];
+        }
+        gc.close();
+    }
+
     public void testConcurrentGC() throws Exception {
         Node root = testRootNode;
         Session session = root.getSession();



Mime
View raw message