ConfigurationFactory { @SuppressWarnings("static-method") public BaseConfiguration getConfiguration(String prefix, Class<? extends BaseConfiguration> configClass) throws ConfigurationException { ResourceBundle bundle = null; BaseConfiguration config = instantiate(configClass); try { bundle = ResourceBundle.getBundle(STANDARD_RESOURCE_NAME, Locale.getDefault(), configClass.getClassLoader()); } catch (MissingResourceException e) { } if (bundle == null) { LOGGER_.debug("Loading default configuration parameters for " + configClass); } else { copyParameters(prefix, config, bundle); } copyParameters(prefix, config, System.getProperties()); return config; }  @SuppressWarnings("static-method") BaseConfiguration getConfiguration(String prefix,
			Class<? extends BaseConfiguration> configClass); @SuppressWarnings("static-method") BaseConfiguration getConfiguration(InputStream source,
			String prefix, Class<? extends BaseConfiguration> configClass); void saveConfiguration(File configOnDisk, BaseConfiguration config);  }
@SuppressWarnings("static-method") @Test public void getDefaultConfiguration() { BaseConfiguration defaultConfig = new ConfigurationFactory() .getConfiguration("elk", BaseConfiguration.class); assertEquals(3, defaultConfig.getParameterNames().size()); }
@SuppressWarnings("static-method") @Test public void getDefaultConfigurationWithPrefix() { BaseConfiguration defaultConfig = new ConfigurationFactory() .getConfiguration("elk.reasoner", BaseConfiguration.class); assertEquals(2, defaultConfig.getParameterNames().size()); defaultConfig = new ConfigurationFactory().getConfiguration( "elk.parser", BaseConfiguration.class); assertEquals(1, defaultConfig.getParameterNames().size()); }
@Test public void getConfigurationFromStream() throws ConfigurationException, IOException { InputStream stream = null; try { stream = this.getClass().getClassLoader() .getResourceAsStream("elk.properties"); BaseConfiguration config = new ConfigurationFactory() .getConfiguration(stream, "elk", BaseConfiguration.class); assertEquals(3, config.getParameterNames().size()); } finally { IOUtils.closeQuietly(stream); } }