@Test
public void testWithTwoAvailableExtraDependency() {
DependencyManager m = new DependencyManager(context);
// Helper class that ensures certain steps get executed in sequence
Ensure e = new Ensure();
Component c1 = m.createComponent()
.setInterface(Service1.class.getName(), null)
.setImplementation(new MyComponent1(e))
.add(m.createServiceDependency()
.setService(Service2.class)
.setRequired(true)
.setAutoConfig("m_service2"));
Component c2 = m.createComponent()
.setImplementation(new MyComponent2(e))
.add(m.createServiceDependency()
.setService(Service1.class)
.setRequired(false)
.setAutoConfig(false)
.setCallbacks("added", null, null));
Component c3 = m.createComponent()
.setInterface(Service2.class.getName(), null)
.setImplementation(Service2Impl.class);
Hashtable h = new Hashtable();
h.put("type", "xx");
Component c4 = m.createComponent()
.setInterface(Service3.class.getName(), h)
.setImplementation(Service3Impl1.class);
h = new Hashtable();
h.put("type", "yy");
Component c5 = m.createComponent()
.setInterface(Service3.class.getName(), h)
.setImplementation(Service3Impl2.class);
System.out.println("\n+++ Adding c2 / MyComponent2");