public void testAdapterWithAspectMultipleTimes() {
DependencyManager m = new DependencyManager(context);
// helper class that ensures certain steps get executed in sequence
Ensure e = new Ensure();
Component aspect1 = m.createAspectService(OriginalService.class, null, 10, null)
.setImplementation(ServiceAspect.class);
Component aspect2 = m.createAspectService(OriginalService.class, null, 15, null)
.setImplementation(ServiceAspect.class);
Component adapter = m.createAdapterService(OriginalService.class, null, "add", null, "remove", "swap")
.setInterface(AdaptedService.class.getName(), null)
.setImplementation(ServiceAdapter.class);
m.add(adapter);
m.add(aspect1);
List originals = new ArrayList();
List consumers = new ArrayList();
int count = 100;
for (int i = 0; i < count; i++) {
// create a service provider and consumer
Dictionary props = new Hashtable();
props.put("number", "" + i);
Component original = m.createComponent()
.setImplementation(new ServiceProvider("" + i, e))
.setInterface(OriginalService.class.getName(), props);
Component consumer = m.createComponent()
.setImplementation(new ServiceConsumer(e, "" + i))
.add(m.createServiceDependency()
.setService(AdaptedService.class, "(number=" + i + ")")
.setCallbacks("add", null, "remove", "swap")
.setRequired(true)