assertNull("Check no foo service", osgiHelper.getServiceReference(FooService.class.getName()));
}
@Test
public void testDisposeAfterFactoryInvalidation() {
ComponentFactory cf = (ComponentFactory) ipojoHelper.getFactory("org.apache.felix.ipojo.runtime.core.components.SimpleType");
assertNotNull("Check factory availability -1", cf);
assertEquals("Check factory state -1", Factory.VALID, cf.getState());
ServiceReference ref_arch = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "SimpleInstance");
assertNotNull("Check Architecture availability -1", ref_arch);
HandlerManagerFactory hf = (HandlerManagerFactory) ipojoHelper.getHandlerFactory("controller");
assertNotNull("Check handler availability -1", hf);
assertEquals("Check handler state -1", Factory.VALID, hf.getState());
// Stop the handler
hf.stop();
HandlerManagerFactory hf2 = (HandlerManagerFactory) ipojoHelper.getFactoryHelper().getHandlerFactory("controller", 1, false);
assertNull("Check handler availability -2", hf2);
// Check the factory invalidity
cf = (ComponentFactory) ipojoHelper.getFactory("org.apache.felix.ipojo.runtime.core.components.SimpleType");
assertNotNull("Check factory availability -2", cf);
assertEquals("Check factory state -2", Factory.INVALID, cf.getState());
// Check the instance disappearance, the instance was disposed.
assertFalse("Check Architecture availability -1", ipojoHelper
.isServiceAvailableByName(Architecture.class.getName(), "SimpleInstance"));
// Restart the handler
hf.start();
hf2 = (HandlerManagerFactory) ipojoHelper.getHandlerFactory("controller");
assertNotNull("Check handler availability -3", hf2);
// Check the factory state
cf = (ComponentFactory) ipojoHelper.getFactory("org.apache.felix.ipojo.runtime.core.components.SimpleType");
assertNotNull("Check factory availability -3", cf);
assertEquals("Check factory state -3", Factory.VALID, cf.getState());
// Check the instance re-creation
ref_arch = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "SimpleInstance");
assertNotNull("Check Architecture availability -3", ref_arch);