under = Utils.getComponentInstance(getContext(), "LFC-Test-Immediate", props);
// The conf is correct, the PS must be provided
ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under1");
assertNotNull("Check service availability -1", ref);
CheckService cs = (CheckService) getContext().getService(ref);
assertTrue("Check state 1", cs.check());
getContext().ungetService(ref);
cs = null;
// Reconfigure the instance with a bad configuration
props.put("conf", "bar"); // Bar is a bad conf
try {
factory.reconfigure(props);
} catch(Exception e) {
fail("The reconfiguration is not unacceptable and seems unacceptable : " + props);
}
// The instance should now be invalid
ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under1");
assertNull("Check service availability -2", ref);
// Reconfigure the instance with a valid configuration
props.put("conf", "foo"); // Bar is a bad conf
try {
factory.reconfigure(props);
} catch(Exception e) {
fail("The reconfiguration is not unacceptable and seems unacceptable (2) : " + props);
}
ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under1");
assertNotNull("Check service availability -3", ref);
cs = (CheckService) getContext().getService(ref);
assertTrue("Check state 2", cs.check());
getContext().ungetService(ref);
cs = null;
under.dispose();
}