@Test public void shouldReturnPropertiesWithValues() throws IOException { String basePath = System.getProperty("java.io.tmpdir"); String fileName = "fileName"; createNewFile(new File(basePath, fileName)); PropertiesConfiguration propertiesConfiguration = ConfigPropertiesUtils.createPropertiesConfiguration(basePath, fileName); assertNotNull(propertiesConfiguration); assertFalse(propertiesConfiguration.isEmpty()); String[] array = propertiesConfiguration.getStringArray(ConfigLocationFileStore.CONFIG_LOCATION_PROPERTY_KEY); assertEquals(1, array.length); assertEquals("/home/user/.motech/config", array[0]); }
public static PropertiesConfiguration createPropertiesConfiguration(String basePath, String fileName) { createFileIfDoesNotExist(basePath, fileName); PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(); propertiesConfiguration.setBasePath(basePath); propertiesConfiguration.setFileName(fileName); try { propertiesConfiguration.load(); } catch (ConfigurationException e) { throw new MotechConfigurationException(String.format("Cannot load configuration from: %s", propertiesConfiguration.getPath()), e); } return propertiesConfiguration; }
ConfigPropertiesUtils { public static PropertiesConfiguration createPropertiesConfiguration(String basePath, String fileName) { createFileIfDoesNotExist(basePath, fileName); PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(); propertiesConfiguration.setBasePath(basePath); propertiesConfiguration.setFileName(fileName); try { propertiesConfiguration.load(); } catch (ConfigurationException e) { throw new MotechConfigurationException(String.format("Cannot load configuration from: %s", propertiesConfiguration.getPath()), e); } return propertiesConfiguration; } }
ConfigPropertiesUtils { public static PropertiesConfiguration createPropertiesConfiguration(String basePath, String fileName) { createFileIfDoesNotExist(basePath, fileName); PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(); propertiesConfiguration.setBasePath(basePath); propertiesConfiguration.setFileName(fileName); try { propertiesConfiguration.load(); } catch (ConfigurationException e) { throw new MotechConfigurationException(String.format("Cannot load configuration from: %s", propertiesConfiguration.getPath()), e); } return propertiesConfiguration; } private  ConfigPropertiesUtils(); }
ConfigPropertiesUtils { public static PropertiesConfiguration createPropertiesConfiguration(String basePath, String fileName) { createFileIfDoesNotExist(basePath, fileName); PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(); propertiesConfiguration.setBasePath(basePath); propertiesConfiguration.setFileName(fileName); try { propertiesConfiguration.load(); } catch (ConfigurationException e) { throw new MotechConfigurationException(String.format("Cannot load configuration from: %s", propertiesConfiguration.getPath()), e); } return propertiesConfiguration; } private  ConfigPropertiesUtils(); static Properties getPropertiesFromFile(File file); static void saveConfig(File file, Properties properties); static File getDefaultPropertiesFile(ConfigLocation.FileAccessType accessType, Iterable<ConfigLocation> configLocations,
                                                String fileName); static Properties getPropertiesFromSystemVarString(String string); static PropertiesConfiguration createPropertiesConfiguration(String basePath, String fileName); }
ConfigPropertiesUtils { public static PropertiesConfiguration createPropertiesConfiguration(String basePath, String fileName) { createFileIfDoesNotExist(basePath, fileName); PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(); propertiesConfiguration.setBasePath(basePath); propertiesConfiguration.setFileName(fileName); try { propertiesConfiguration.load(); } catch (ConfigurationException e) { throw new MotechConfigurationException(String.format("Cannot load configuration from: %s", propertiesConfiguration.getPath()), e); } return propertiesConfiguration; } private  ConfigPropertiesUtils(); static Properties getPropertiesFromFile(File file); static void saveConfig(File file, Properties properties); static File getDefaultPropertiesFile(ConfigLocation.FileAccessType accessType, Iterable<ConfigLocation> configLocations,
                                                String fileName); static Properties getPropertiesFromSystemVarString(String string); static PropertiesConfiguration createPropertiesConfiguration(String basePath, String fileName);  }