felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r1745936 - in /felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest: api/FELIX5268_AddRemoveServiceTest.java bundle2/ bundle2/Activator.java bundle2/AddRemoveService.java bundle2/packageinfo
Date Sat, 28 May 2016 20:39:30 GMT
Author: pderop
Date: Sat May 28 20:39:30 2016
New Revision: 1745936

URL: http://svn.apache.org/viewvc?rev=1745936&view=rev
Log:
FELIX-5268: Added test case which reproduces the issue for FELIX-5268.

Added:
    felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/api/FELIX5268_AddRemoveServiceTest.java
    felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/bundle2/
    felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/bundle2/Activator.java
    felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/bundle2/AddRemoveService.java
    felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/bundle2/packageinfo

Added: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/api/FELIX5268_AddRemoveServiceTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/api/FELIX5268_AddRemoveServiceTest.java?rev=1745936&view=auto
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/api/FELIX5268_AddRemoveServiceTest.java
(added)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/api/FELIX5268_AddRemoveServiceTest.java
Sat May 28 20:39:30 2016
@@ -0,0 +1,58 @@
+/*
+ * 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.felix.dm.itest.api;
+
+import java.util.stream.Stream;
+
+import org.apache.felix.dm.itest.bundle2.AddRemoveService;
+import org.apache.felix.dm.itest.util.TestBase;
+import org.junit.Assert;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * FELIX_XXX: When a bundle activator is invoked because the bundle is starting, then if
the
+ * activator adds/removes a DM service providing component, then the service should be also
removed from the
+ * OSGI service registry.
+ */
+public class FELIX5268_AddRemoveServiceTest extends TestBase {
+	
+	public void testStartStop() throws BundleException {
+		// Lookup our test bundle which adds/removes a "AddRemoveService" component.
+		
+		Bundle testBundle = Stream.of(context.getBundles())
+			.filter(b -> b.getSymbolicName().equals("org.apache.felix.dependencymanager.itest.bundle2"))
+			.findFirst()
+			.orElseThrow(() -> new RuntimeException("cound not find bundle2 test."));
+		
+		// Stop it
+		testBundle.stop();
+		
+		// Restart it
+		testBundle.start();
+		
+		// At this point, then AddRemoveService should not be registered in the OSGI service registry.
+		ServiceReference ref = context.getServiceReference(AddRemoveService.class.getName());
+		Assert.assertNull(ref);
+
+		// We don't need this bundle anymore, stop it.
+		testBundle.stop();
+	}
+}

Added: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/bundle2/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/bundle2/Activator.java?rev=1745936&view=auto
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/bundle2/Activator.java
(added)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/bundle2/Activator.java
Sat May 28 20:39:30 2016
@@ -0,0 +1,41 @@
+/*
+ * 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.felix.dm.itest.bundle2;
+
+import org.apache.felix.dm.Component;
+import org.apache.felix.dm.DependencyActivatorBase;
+import org.apache.felix.dm.DependencyManager;
+import org.osgi.framework.BundleContext;
+
+/**
+ * Activator used to test the FELIX_5268 issue: a service providing component must be removed
from
+ * the OSGI registry in case the component is removed from DependencyManager and if the bundle
is starting. 
+ */
+public class Activator extends DependencyActivatorBase {
+
+	@Override
+	public void init(BundleContext context, DependencyManager dm) throws Exception {
+		Component c = createComponent()
+				.setImplementation(AddRemoveService.class)
+				.setInterface(AddRemoveService.class.getName(), null);
+		dm.add(c);
+		dm.remove(c);		
+	}
+	
+}

Added: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/bundle2/AddRemoveService.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/bundle2/AddRemoveService.java?rev=1745936&view=auto
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/bundle2/AddRemoveService.java
(added)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/bundle2/AddRemoveService.java
Sat May 28 20:39:30 2016
@@ -0,0 +1,26 @@
+/*
+ * 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.felix.dm.itest.bundle2;
+
+/**
+ * a Service which is added, and then immediately removed from DependencyManager while the
bundle is starting.
+ */
+public class AddRemoveService {
+
+}

Added: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/bundle2/packageinfo
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/bundle2/packageinfo?rev=1745936&view=auto
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/bundle2/packageinfo
(added)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/bundle2/packageinfo
Sat May 28 20:39:30 2016
@@ -0,0 +1 @@
+version 1.0.0



Mime
View raw message