use of org.motechproject.config.core.domain.ConfigLocation in project motech by motech.
the class DbConfigManagerTest method shouldCopyFileWhenLoadingPropertiesFromClassPath.
private void shouldCopyFileWhenLoadingPropertiesFromClassPath(String filename) throws IOException {
when(environment.getDatanucleusDataProperties()).thenReturn(new Properties());
when(environment.getConfigDir()).thenReturn("");
tempDir = Files.createTempDir();
File file = new File(tempDir, filename);
List<ConfigLocation> configLocationList = new ArrayList<>();
configLocationList.add(new ConfigLocation(tempDir.getAbsolutePath()));
when(configLocationFileStore.getAll()).thenReturn(configLocationList);
useDbManagerToGetCorrectFile(filename);
Properties properties = new Properties();
try (FileInputStream is = new FileInputStream(file)) {
properties.load(is);
}
assertEquals(getCompleteProperties(filename), properties);
}
use of org.motechproject.config.core.domain.ConfigLocation in project motech by motech.
the class ConfigLocationIT method shouldReturnConfigurationFiles.
@Test
public void shouldReturnConfigurationFiles() throws IOException {
ConfigLocation configLocation = new ConfigLocation(getConfigDirectoryLocation("config/"));
List<File> existingConfigFiles = configLocation.getExistingConfigFiles();
assertThat(existingConfigFiles.isEmpty(), Is.is(false));
assertThat(existingConfigFiles, has("motech-settings.properties"));
assertThat(existingConfigFiles, doesNotHave("bootstrap.properties"));
}
use of org.motechproject.config.core.domain.ConfigLocation in project motech by motech.
the class CoreConfigurationServiceImplTest method shouldGetConfigLocation.
@Test
public void shouldGetConfigLocation() {
String correctConfigPath = this.getClass().getClassLoader().getResource("config").getPath();
String inCorrectConfigPath = this.getClass().getClassLoader().getResource("some_random_dir").getPath();
ConfigLocation incorrectLocation = new ConfigLocation(inCorrectConfigPath);
ConfigLocation correctLocation = new ConfigLocation(correctConfigPath);
when(configLocationFileStoreMock.getAll()).thenReturn(Arrays.asList(incorrectLocation, correctLocation));
ConfigLocation configLocation = coreConfigurationService.getConfigLocation();
assertEquals(correctLocation, configLocation);
}
use of org.motechproject.config.core.domain.ConfigLocation in project motech by motech.
the class CoreConfigurationServiceImplTest method shouldThrowExceptionIfNoneOfTheConfigLocationsAreReadable.
@Test
public void shouldThrowExceptionIfNoneOfTheConfigLocationsAreReadable() {
String inCorrectConfigPath = this.getClass().getClassLoader().getResource("some_random_dir").getPath();
when(configLocationFileStoreMock.getAll()).thenReturn(Arrays.asList(new ConfigLocation(inCorrectConfigPath)));
expectedException.expect(MotechConfigurationException.class);
expectedException.expectMessage(String.format("Could not read settings from any of the config locations. Searched directories: %s .", new ConfigLocation(inCorrectConfigPath).getLocation()));
coreConfigurationService.getConfigLocation();
}
use of org.motechproject.config.core.domain.ConfigLocation in project motech by motech.
the class ConfigFileMonitor method setupLocation.
private void setupLocation() throws FileSystemException {
ConfigLocation configLocation = coreConfigurationService.getConfigLocation();
monitoredDir = VFS.getManager().resolveFile(configLocation.getLocation());
fileMonitor.addFile(monitoredDir);
LOGGER.info(String.format("Setting up monitoring for location: %s", monitoredDir));
}
Aggregations