ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance.getInstanceName());
assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
assertNotNull("FS availability", ref);
FooService fs = (FooService) bc.getService(ref);
Properties p = fs.fooProps();
String mes = p.getProperty("message");
// int count1 = ((Integer) p.get("count")).intValue();
assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
assertEquals("Check message - 1 (" + mes + ")", "message2", mes); // Already reconfigured.
// assertEquals("Check count", 2, count); // Two : 1) "message" on immediate, "message2" on the reconfiguration,
// not necessary as the property can be set before the immediate instance creation
instance.dispose();
//Reconfiguration
try {
configuration = admin.getConfiguration(msp, getTestBundle().getLocation());
Dictionary prc = configuration.getProperties();
if (prc == null) {
prc = new Properties();
}
prc.put("message", "message3");
configuration.update(prc);
grace();
} catch (Exception e) {
fail(e.getMessage());
}
// Recreation of the instance.
props = new Properties();
props.put("managed.service.pid", msp);
props.put("message", "message");
instance = null;
try {
instance = factImm.createComponentInstance(props);
grace();
} catch (Exception e) {
fail(e.getMessage());
}
ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance.getInstanceName());
assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
assertNotNull("FS availability", ref);
fs = (FooService) bc.getService(ref);
p = fs.fooProps();
mes = p.getProperty("message");
// int count = ((Integer) p.get("count")).intValue();
assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
assertEquals("Check message already reconfigured", "message3", mes); // Already reconfigured.
//assertEquals("Check count", count1 + 1, count); // message before the reconfiguration, message3 after the reconfiguration