You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by ch...@apache.org on 2015/10/13 11:51:20 UTC

svn commit: r1708315 - in /jackrabbit/oak/trunk/oak-pojosr/src: main/java/org/apache/jackrabbit/oak/run/osgi/OakOSGiRepositoryFactory.java test/groovy/org/apache/jackrabbit/oak/run/osgi/RepositoryClosedTest.groovy

Author: chetanm
Date: Tue Oct 13 09:51:19 2015
New Revision: 1708315

URL: http://svn.apache.org/viewvc?rev=1708315&view=rev
Log:
OAK-3513 - Session save going through despite repository being shutdown causing reindex flag to reset

Adding ignored testcase

Added:
    jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/RepositoryClosedTest.groovy
Modified:
    jackrabbit/oak/trunk/oak-pojosr/src/main/java/org/apache/jackrabbit/oak/run/osgi/OakOSGiRepositoryFactory.java

Modified: jackrabbit/oak/trunk/oak-pojosr/src/main/java/org/apache/jackrabbit/oak/run/osgi/OakOSGiRepositoryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-pojosr/src/main/java/org/apache/jackrabbit/oak/run/osgi/OakOSGiRepositoryFactory.java?rev=1708315&r1=1708314&r2=1708315&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-pojosr/src/main/java/org/apache/jackrabbit/oak/run/osgi/OakOSGiRepositoryFactory.java (original)
+++ jackrabbit/oak/trunk/oak-pojosr/src/main/java/org/apache/jackrabbit/oak/run/osgi/OakOSGiRepositoryFactory.java Tue Oct 13 09:51:19 2015
@@ -245,7 +245,7 @@ public class OakOSGiRepositoryFactory im
         return descriptors;
     }
 
-    private static void shutdown(PojoServiceRegistry registry, int timeoutInSecs) throws BundleException {
+    static void shutdown(PojoServiceRegistry registry, int timeoutInSecs) throws BundleException {
         if (registry == null){
             return;
         }

Added: jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/RepositoryClosedTest.groovy
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/RepositoryClosedTest.groovy?rev=1708315&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/RepositoryClosedTest.groovy (added)
+++ jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/RepositoryClosedTest.groovy Tue Oct 13 09:51:19 2015
@@ -0,0 +1,89 @@
+/*
+ * 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.oak.run.osgi
+
+import groovy.util.logging.Slf4j
+import org.apache.felix.connect.launch.PojoServiceRegistry
+import org.apache.felix.scr.Component
+import org.apache.felix.scr.ScrService
+import org.junit.Assert
+import org.junit.Before
+import org.junit.Ignore
+import org.junit.Test
+
+import javax.jcr.RepositoryException
+import javax.jcr.Session
+import java.util.concurrent.TimeUnit
+
+import static org.apache.jackrabbit.oak.run.osgi.OakOSGiRepositoryFactory.REPOSITORY_CONFIG_FILE
+
+@Slf4j
+class RepositoryClosedTest extends AbstractRepositoryFactoryTest{
+
+    @Before
+    void setupRepo() {
+        config[REPOSITORY_CONFIG_FILE] = createConfigValue("oak-base-config.json", "oak-tar-config.json")
+    }
+
+    @Ignore("OAK-3513")
+    @Test
+    public void sessionUsePostClose() throws Exception{
+        repository = repositoryFactory.getRepository(config)
+        PojoServiceRegistry registry = getRegistry()
+
+        //1. Obtain handle to a session
+        Session s = createAdminSession()
+
+        //2 Trigger repository shutdown
+        disableComponents(
+                'org.apache.jackrabbit.oak.jcr.osgi.RepositoryManager',
+                'org.apache.jackrabbit.oak.plugins.name.NameValidatorProvider'
+        )
+        log.info("Repository shutdown complete. Proceeding with save")
+
+        //Null out repository to prevent shutdown attempt in teardown
+        repository = null
+
+        //3. Now try adding a node with invalid name. Such a commit
+        //should have got failed
+        s.getRootNode().addNode("a\nb");
+        try {
+            s.save()
+            Assert.fail("Session save should have failed due to invalid name")
+        } catch (RepositoryException ignore){
+
+        }
+
+
+        OakOSGiRepositoryFactory.shutdown(registry, 5)
+    }
+
+    private void disableComponents(String ... names){
+        ScrService scr = getService(ScrService.class)
+        names.each {String name ->
+            Component[] c = scr.getComponents(name)
+            assert c : "No component with name '$name' found"
+            c[0].componentInstance?.dispose()
+            log.info("Disabling {}", name)
+        }
+
+        TimeUnit.SECONDS.sleep(1)
+    }
+}