assertTrue("Test component validity", import3.getState() == ComponentInstance.VALID);
ServiceContext sc = getServiceContext(import3);
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, 1);
FooService fs = (FooService) sc.getService(refs[0]);
assertTrue("Test foo invocation", fs.foo());
sc.ungetService(refs[0]);
// Stop the second provider
foo2.dispose();
assertTrue("Test component validity", import3.getState() == ComponentInstance.VALID);
sc = getServiceContext(import3);
refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);
assertNotNull("Test foo availability inside the composite - 2", refs);
assertEquals("Test foo availability inside the composite - 2.1 (" + refs.length + ")", refs.length, 1);
fs = (FooService) sc.getService(refs[0]);
assertTrue("Test foo invocation", fs.foo());
sc.ungetService(refs[0]);
// stop the foo provider
foo.stop();
// No provider -> Invalid
assertTrue("Test component invalidity - 2", import3.getState() == ComponentInstance.VALID);
foo.start();
assertTrue("Test component validity", import3.getState() == ComponentInstance.VALID);
sc = getServiceContext(import3);
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]);
foo.dispose();
// No provider -> Invalid
assertTrue("Test component invalidity - 3", import3.getState() == ComponentInstance.VALID);