assertTrue("Test component validity", import4.getState() == ComponentInstance.VALID);
ServiceContext sc = getServiceContext(import4);
ServiceReference[] refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);
assertNotNull("Test foo availability inside the composite - 1", refs);
assertEquals("Test foo availability inside the composite - 1.2", refs.length, 2);
FooService fs = (FooService) sc.getService(refs[0]);
assertTrue("Test foo invocation", fs.foo());
sc.ungetService(refs[0]);
fs = (FooService) sc.getService(refs[1]);
assertTrue("Test foo invocation (2)", fs.foo());
sc.ungetService(refs[1]);
foo1.stop();
assertTrue("Test component validity", import4.getState() == ComponentInstance.VALID);
sc = getServiceContext(import4);
refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);
assertNotNull("Test foo availability inside the composite - 1", refs);
assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);
fs = (FooService) sc.getService(refs[0]);
assertTrue("Test foo invocation", fs.foo());
sc.ungetService(refs[0]);
// Stop the second provider
foo2.stop();
assertTrue("Test component validity - 2", import4.getState() == ComponentInstance.VALID);
sc = getServiceContext(import4);
refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);
assertEquals("Test foo availability inside the composite - 1", refs.length, 0);
foo2.start();
assertTrue("Test component validity", import4.getState() == ComponentInstance.VALID);
sc = getServiceContext(import4);
refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);
assertNotNull("Test foo availability inside the composite - 3", refs);
assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);
fs = (FooService) sc.getService(refs[0]);
assertTrue("Test foo invocation", fs.foo());
sc.ungetService(refs[0]);
}