private void setUpClientLifeCycleListeners(String[] names, String[] restricted, String excludes) throws Exception {
ServiceReference[] svcrefs = createTestServiceReferences(names, restricted);
EasyMock.expect(bundleContext.getServiceReferences(ClientLifeCycleListener.class.getName(), null))
.andReturn(svcrefs);
ClientLifeCycleManager lcmanager = control.createMock(ClientLifeCycleManager.class);
EasyMock.expect(bus.getExtension(ClientLifeCycleManager.class)).andReturn(lcmanager).anyTimes();
for (int i = 0; i < names.length; i++) {
ClientLifeCycleListener cl = control.createMock(ClientLifeCycleListener.class);
EasyMock.expect(bundleContext.getService(svcrefs[i])).andReturn(cl).anyTimes();
if (!isExcluded(BUNDLE_NAME, names[i], restricted[i], excludes)) {
lcmanager.registerListener(cl);
EasyMock.expectLastCall();
}
}
}