public class AdapterWithInstanceBoundDependencyTest extends TestBase {
@Test
public void testInstanceBoundDependency() {
DependencyManager m = new DependencyManager(context);
// helper class that ensures certain steps get executed in sequence
Ensure e = new Ensure();
// create a service provider and consumer
Component sp = m.createComponent()
.setInterface(ServiceInterface.class.getName(), null)
.setImplementation(new ServiceProvider(e));
Component sp2 = m.createComponent()
.setInterface(ServiceInterface2.class.getName(), null)
.setImplementation(new ServiceProvider2(e));
Component sc = m.createComponent()
.setImplementation(new ServiceConsumer())
.add(m.createServiceDependency()
.setService(ServiceInterface3.class)
.setRequired(true));
Component sa = m.createAdapterService(ServiceInterface.class, null)
.setInterface(ServiceInterface3.class.getName(), null)
.setImplementation(new ServiceAdapter(e));
m.add(sc);
m.add(sp);
m.add(sp2);
m.add(sa);
e.waitForStep(5, 15000);
m.remove(sa);
m.remove(sp2);
m.remove(sp);
m.remove(sc);
}