felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r1572771 - /felix/sandbox/pderop/dependencymanager-prototype/dm.it/src/dm/it/ComponentTest.java
Date Thu, 27 Feb 2014 22:45:32 GMT
Author: pderop
Date: Thu Feb 27 22:45:32 2014
New Revision: 1572771

URL: http://svn.apache.org/r1572771
Log:
Provides the "Provider" interface using dependency manager API (component.setInterface(...)).

Modified:
    felix/sandbox/pderop/dependencymanager-prototype/dm.it/src/dm/it/ComponentTest.java

Modified: felix/sandbox/pderop/dependencymanager-prototype/dm.it/src/dm/it/ComponentTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.it/src/dm/it/ComponentTest.java?rev=1572771&r1=1572770&r2=1572771&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.it/src/dm/it/ComponentTest.java (original)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.it/src/dm/it/ComponentTest.java Thu
Feb 27 22:45:32 2014
@@ -1,11 +1,14 @@
 package dm.it;
 
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Map;
+
 import junit.framework.Assert;
 import junit.framework.TestCase;
 
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceRegistration;
 
 import dm.Component;
 import dm.DependencyManager;
@@ -20,37 +23,50 @@ public class ComponentTest extends TestC
         consumer
             .setImplementation(new Consumer())
             .add(dm.createServiceDependency()
-                .setService(Provider.class)
+                .setService(Provider.class, "(name=provider2)")
                 .setRequired(true)
                 .setCallbacks("add", "remove"))
             .add(dm.createServiceDependency()
-                .setService(Provider.class)
+                .setService(Provider.class, "(name=provider1)")
                 .setRequired(true)
                 .setAutoConfig("m_autoConfiguredProvider"));
-        ServiceRegistration sr = m_context.registerService(Provider.class.getName(), new
ProviderImpl(), null);
+        
+        Dictionary props = new Hashtable();
+        props.put("name", "provider1");
+        Component provider1 = dm.createComponent()
+        		.setImplementation(new Provider() { public String toString() { return "provider1";}})
+        		.setInterface(Provider.class.getName(), props);
+        props = new Hashtable();
+        props.put("name", "provider2");
+        Component provider2 = dm.createComponent()
+				   .setImplementation(new Provider() { public String toString() { return "provider2";}})
+				   .setInterface(Provider.class.getName(), props);
+        dm.add(provider1);
+        dm.add(provider2);
         dm.add(consumer);
         m_ensure.waitForStep(2, 5000);
-        sr.unregister();    
+        dm.remove(provider1); 
+        dm.remove(provider2);    
         m_ensure.waitForStep(5, 5000);
     }
     
-    public static interface Provider {        
+    public static interface Provider {    	
     }
     
-    public class ProviderImpl implements Provider {}
-    
     public class Consumer {
         Provider m_provider;
         Provider m_autoConfiguredProvider;
         
-        void add(Provider provider) {
+        void add(Map props, Provider provider) {
             Assert.assertNotNull(provider);
+            Assert.assertEquals("provider2", props.get("name"));
             m_provider = provider;
             m_ensure.step(1);
         }
         
         void start() {
             Assert.assertNotNull(m_autoConfiguredProvider);
+            Assert.assertEquals("provider1", m_autoConfiguredProvider.toString());
             m_ensure.step(2);
         }
         



Mime
View raw message