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 al...@apache.org on 2015/10/26 16:59:21 UTC

svn commit: r1710637 - /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/osgi/OsgiWhiteboardTest.java

Author: alexparvulescu
Date: Mon Oct 26 15:59:21 2015
New Revision: 1710637

URL: http://svn.apache.org/viewvc?rev=1710637&view=rev
Log:
OAK-3409 CompositeRegistration.unregister diagnostics not helpful
 - forgot to commit the test

Added:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/osgi/OsgiWhiteboardTest.java   (with props)

Added: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/osgi/OsgiWhiteboardTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/osgi/OsgiWhiteboardTest.java?rev=1710637&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/osgi/OsgiWhiteboardTest.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/osgi/OsgiWhiteboardTest.java Mon Oct 26 15:59:21 2015
@@ -0,0 +1,82 @@
+/*
+ * 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.osgi;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Hashtable;
+
+import org.apache.jackrabbit.oak.spi.whiteboard.Registration;
+import org.junit.Test;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+public class OsgiWhiteboardTest {
+
+    /**
+     * OAK-3409
+     */
+    @Test
+    public void testDoubleUnregister() {
+        BundleContext bundleContext = mock(BundleContext.class);
+        OsgiWhiteboard w = new OsgiWhiteboard(bundleContext);
+
+        Runnable r = new Runnable() {
+            @Override
+            public void run() {
+                //
+            }
+        };
+
+        ServiceRegistration sr = new ServiceRegistration() {
+
+            boolean isUnregistering = false;
+
+            @Override
+            public void unregister() {
+                if (isUnregistering) {
+                    throw new IllegalStateException(
+                            "Service already unregistered.");
+                }
+                isUnregistering = true;
+            }
+
+            @Override
+            public void setProperties(Dictionary properties) {
+            }
+
+            @Override
+            public ServiceReference getReference() {
+                return null;
+            }
+        };
+
+        when(
+                bundleContext.registerService(Runnable.class.getName(), r,
+                        new Hashtable<Object, Object>())).thenReturn(sr);
+        Registration reg = w.register(Runnable.class, r,
+                new HashMap<String, Object>());
+        reg.unregister();
+        reg.unregister();
+    }
+
+}

Propchange: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/osgi/OsgiWhiteboardTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain