extends Base class in order to remove temporary files from /tmp/tb/. Also added a test which seems to reproduce an issue regarding required Bundle Dependency
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@916033 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/BundleDependencyTest.java b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/BundleDependencyTest.java
index 00234aa..40e06a8 100644
--- a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/BundleDependencyTest.java
+++ b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/BundleDependencyTest.java
@@ -34,7 +34,7 @@
import org.osgi.framework.BundleContext;
@RunWith(JUnit4TestRunner.class)
-public class BundleDependencyTest {
+public class BundleDependencyTest extends Base {
@Configuration
public static Option[] configuration() {
return options(
@@ -71,6 +71,23 @@
e.step(4);
}
+ @Test
+ public void testRequiredBundleDependency(BundleContext context) {
+ DependencyManager m = new DependencyManager(context);
+ // create a service provider and consumer
+ Consumer c = new Consumer();
+
+ // helper class that ensures certain steps get executed in sequence
+ Ensure e = new Ensure();
+ Service consumerWithFilter = m.createService().setImplementation(new FilteredConsumerRequired(e)).add(m.createBundleDependency().setRequired(true).setFilter("(Bundle-SymbolicName=org.apache.felix.dependencymanager)").setCallbacks("add", "remove"));
+ // add a consumer with a filter
+ m.add(consumerWithFilter);
+ e.waitForStep(1, 10000);
+ // remove the consumer again
+ m.remove(consumerWithFilter);
+ e.waitForStep(2, 10000);
+ }
+
static class Consumer {
private volatile int m_count = 0;
@@ -107,4 +124,26 @@
m_ensure.step(3);
}
}
+
+ static class FilteredConsumerRequired {
+ private final Ensure m_ensure;
+
+ public FilteredConsumerRequired(Ensure e) {
+ m_ensure = e;
+ }
+
+ public void add(Bundle b) {
+ Assert.assertNotNull(b);
+ if (b.getSymbolicName().equals("org.apache.felix.dependencymanager")) {
+ m_ensure.step(1);
+ }
+ }
+
+ public void remove(Bundle b) {
+ Assert.assertNotNull(b);
+ if (b.getSymbolicName().equals("org.apache.felix.dependencymanager")) {
+ m_ensure.step(2);
+ }
+ }
+ }
}