Activator implements BundleActivator { static void configureServices(ConfigurationAdmin cm, ServiceConfiguration serviceConfig) { for (Service service : serviceConfig.getServices()) { Dictionary<String, ?> props = service.getProperties(); String pid = service.getServiceID(); try { Configuration config = cm.getConfiguration(pid, null); config.update(props); log.debug("Created configuration for pid {}", pid); } catch (IOException e) { log.error("Could not create configuration for pid {}", pid, e); } } }  void start(BundleContext context); void stop(BundleContext context);  }
@Test public void testStandaloneConfigWithException() throws IOException { ServiceConfiguration serviceConfig = getSimpleConfig(); when(cm.getConfiguration("standaloneID", null)).thenThrow(new IOException()); Activator.configureServices(cm, serviceConfig); verify(log).error(anyString(), anyString(), any(Exception.class)); }