ServiceReference ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
assertNotNull("FS availability", ref);
FooService fs = (FooService) getContext().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);
Dictionary prc = configuration.getProperties();
if (prc == null) {
prc = new Properties();
}
prc.put("message", "message3");
configuration.update(prc);
listener.waitForEvent(msp, "1");
} 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);
Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME * 2);
} catch (Exception e) {
fail(e.getMessage());
}
ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
assertNotNull("FS availability", ref);
fs = (FooService) getContext().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