use of org.motechproject.config.core.domain.ConfigLocation in project motech by motech.
the class ConfigLocationFileStoreIT method shouldSubstituteHomeDirectoryInThePath.
@Test
public void shouldSubstituteHomeDirectoryInThePath() throws ConfigurationException, IOException {
PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(getClass().getClassLoader().getResource("config-locations.properties"));
ConfigLocationFileStore configLocationFileStore = new ConfigLocationFileStore(propertiesConfiguration);
Iterable<ConfigLocation> configLocationsIterable = configLocationFileStore.getAll();
assertNotNull(configLocationsIterable);
Iterator<ConfigLocation> configLocationIterator = configLocationsIterable.iterator();
assertTrue(configLocationIterator.hasNext());
ConfigLocation expected = new ConfigLocation(String.format("%s/.motech/configtest/", System.getProperty("user.home")));
assertThat(configLocationIterator.next(), IsEqual.equalTo(expected));
}
use of org.motechproject.config.core.domain.ConfigLocation in project motech by motech.
the class ConfigLocationIT method shouldReturnFalseWhenConfigLocationHasPlatformConfigurationFile.
@Test
public void shouldReturnFalseWhenConfigLocationHasPlatformConfigurationFile() throws IOException {
ConfigLocation configLocation = new ConfigLocation(getConfigDirectoryLocation("some_random_dir/"));
assertFalse(configLocation.hasPlatformConfigurationFile());
}
use of org.motechproject.config.core.domain.ConfigLocation in project motech by motech.
the class ConfigLocationIT method shouldReturnTrueWhenConfigLocationHasPlatformConfigurationFile.
@Test
public void shouldReturnTrueWhenConfigLocationHasPlatformConfigurationFile() throws IOException {
ConfigLocation configLocation = new ConfigLocation(getConfigDirectoryLocation("config/"));
assertTrue(configLocation.hasPlatformConfigurationFile());
}
use of org.motechproject.config.core.domain.ConfigLocation in project motech by motech.
the class ConfigLoader method loadMotechSettings.
/**
* Loads MOTECH settings containing core platform settings.
*
* @return the {SettingsRecord} object
*/
public SettingsRecord loadMotechSettings() {
SettingsRecord settingsRecord;
ConfigLocation configLocation = coreConfigurationService.getConfigLocation();
Resource configLocationResource = configLocation.toResource();
try {
Resource motechSettings = configLocationResource.createRelative(ConfigurationConstants.SETTINGS_FILE_NAME);
settingsRecord = loadSettingsFromStream(motechSettings);
settingsRecord.setFilePath(configLocationResource.getURL().getPath());
checkSettingsRecord(settingsRecord);
} catch (IOException e) {
throw new MotechConfigurationException(String.format("Could not read settings from file at location %s", configLocation), e);
}
return settingsRecord;
}
Aggregations