private void _startExtension( String namespace, NamedConfigurationContent... namedConfigurationContents) throws Exception { ConfiguratorExtension configuratorExtension = new ConfiguratorExtension( _configurationAdmin, new Logger(_bundleContext), namespace, Arrays.asList(namedConfigurationContents), Arrays.<ConfigurationDescriptionFactory>asList( new StringConfigurationDescriptionFactory())); configuratorExtension.start(); _configurationExtensions.add(configuratorExtension); }
@Test public void testExceptionInSupplierDoesNotStopExtension() throws Exception { ConfiguratorExtension configuratorExtension = new ConfiguratorExtension( _configurationAdmin, new Logger(_bundleContext), "aBundle", Arrays.<NamedConfigurationContent>asList( new StringSingleNamedConfigurationContent("test.pid", "key=value")), Arrays.asList( new ConfigurationDescriptionFactory() { @Override public ConfigurationDescription create( NamedConfigurationContent namedConfigurationContent) { return new SingleConfigurationDescription( "exception", new Supplier<Dictionary<String, Object>>() { @Override public Dictionary<String, Object> get() { throw new RuntimeException("This should be handled"); } }); } }, new StringConfigurationDescriptionFactory())); configuratorExtension.start(); _configurationExtensions.add(configuratorExtension); Configuration[] configurations = _configurationAdmin.listConfigurations(null); Assert.assertEquals(1, configurations.length); }