Activator implements BundleActivator { static void configureFactories(ConfigurationAdmin cm, ServiceConfiguration serviceConfig) { for (ServiceFactory factory : serviceConfig.getFactories()) { String factoryPID = factory.getFactoryID(); for (Service service : factory.getServices()) { try { Configuration config = cm.createFactoryConfiguration(factoryPID, null); config.update(service.getProperties()); log.debug("Added configuration for factory pid {}", factoryPID); } catch (IOException e) { log.error("Could not create factory configuration for factory pid {}", factoryPID, e); } } } }  void start(BundleContext context); void stop(BundleContext context);  }
@Test public void testInstanceConfigWithException() throws IOException { ServiceConfiguration serviceConfig = getSimpleConfig(); when(cm.createFactoryConfiguration("factoryID", null)).thenThrow(new IOException()); Activator.configureFactories(cm, serviceConfig); verify(log).error(anyString(), anyString(), any(Exception.class)); }