felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r916033 - /felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/BundleDependencyTest.java
Date Wed, 24 Feb 2010 23:00:33 GMT
Author: pderop
Date: Wed Feb 24 23:00:33 2010
New Revision: 916033

URL: http://svn.apache.org/viewvc?rev=916033&view=rev
Log:
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

Modified:
    felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/BundleDependencyTest.java

Modified: felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/BundleDependencyTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/BundleDependencyTest.java?rev=916033&r1=916032&r2=916033&view=diff
==============================================================================
--- felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/BundleDependencyTest.java
(original)
+++ felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/BundleDependencyTest.java
Wed Feb 24 23:00:33 2010
@@ -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);
+            }
+        }
+    }
 }



Mime
View raw message