ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance.getInstanceName());
assertEquals("Check no object", 0, ((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 count = (Integer) p.get("count");
assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
assertEquals("Check message", "message2", mes); // Already reconfigured.
assertEquals("Check count", 1, count);
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 = factSvc.createComponentInstance(props);
grace();
} catch (Exception e) {
fail(e.getMessage());
}
ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance.getInstanceName());
assertEquals("Check no object", 0, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
assertNotNull("FS availability", ref);
fs = (FooService) bc.getService(ref);
p = fs.fooProps();
mes = p.getProperty("message");
count = (Integer) p.get("count");
assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
assertEquals("Check message", "message3", mes); // Already reconfigured.
assertEquals("Check count", 1, count);