public void testManagedService() throws Exception {
// Get the {@link Configuration} for the given PID
Configuration config = configAdmin.getConfiguration(ConfiguredService.SERVICE_PID);
assertNotNull("Config not null", config);
Dictionary<String, String> configProps = new Hashtable<String, String>();
configProps.put("foo", "bar");
config.update(configProps);
// Register a {@link ManagedService}
Dictionary<String, String> serviceProps = new Hashtable<String, String>();
serviceProps.put(Constants.SERVICE_PID, ConfiguredService.SERVICE_PID);
bundlecontext.registerService(new String[] { ConfiguredService.class.getName(),
ManagedService.class.getName() }, new ConfiguredService(), serviceProps);
// Wait a little for the update event
if (latch.await(5, TimeUnit.SECONDS) == false)
throw new TimeoutException();
// Verify service property
ServiceReference sref = bundlecontext.getServiceReference(ConfiguredService.class.getName());
ConfiguredService service = (ConfiguredService) bundlecontext.getService(sref);
assertEquals("bar", service.getValue("foo"));
config.delete();
}