use of org.motechproject.config.core.domain.ConfigLocation in project motech by motech.
the class ConfigLoaderTest method shouldReturnFilesInConfigLocation.
@Test
public void shouldReturnFilesInConfigLocation() throws IOException {
ConfigLocation configLocation = mock(ConfigLocation.class);
File file = mock(File.class);
List<File> files = Arrays.asList(file);
when(configLocation.getExistingConfigFiles()).thenReturn(files);
when(coreConfigurationService.getConfigLocation()).thenReturn(configLocation);
List<File> existingConfigs = configLoader.findExistingConfigs();
assertSame(files, existingConfigs);
}
use of org.motechproject.config.core.domain.ConfigLocation in project motech by motech.
the class ConfigLoaderTest method shouldThrowExceptionIfErrorReadingSettingsFile.
@Test(expected = MotechConfigurationException.class)
public void shouldThrowExceptionIfErrorReadingSettingsFile() throws MalformedURLException {
ConfigLocation configLocation = mock(ConfigLocation.class);
UrlResource resource = mock(UrlResource.class);
when(coreConfigurationService.getConfigLocation()).thenReturn(configLocation);
when(configLocation.toResource()).thenReturn(resource);
when(resource.createRelative(ConfigurationConstants.SETTINGS_FILE_NAME)).thenThrow(new MalformedURLException());
configLoader.loadMotechSettings();
}
use of org.motechproject.config.core.domain.ConfigLocation in project motech by motech.
the class ConfigLoaderTest method shouldLoadSupportedFilesFromGivenConfigLocation.
@Test
public void shouldLoadSupportedFilesFromGivenConfigLocation() throws IOException {
final String dirPath = FileHelper.getResourceFile("config").getAbsolutePath();
final File file1 = new File(dirPath, "motech-settings.properties");
final File file2 = new File(dirPath, "org.motechproject.motech-module1/somemodule.properties");
final File file3 = new File(dirPath, "org.motechproject.motech-module2/raw/somemodule.json");
final List<File> expectedFiles = Arrays.asList(file1, file2, file3);
final ConfigLocation configLocation = new ConfigLocation(dirPath);
when(coreConfigurationService.getConfigLocation()).thenReturn(configLocation);
final List<File> actualFiles = configLoader.findExistingConfigs();
assertEquals(expectedFiles.size(), actualFiles.size());
assertTrue(actualFiles.containsAll(expectedFiles));
}
use of org.motechproject.config.core.domain.ConfigLocation in project motech by motech.
the class ConfigurationServiceTest method shouldIndicateThatConfigFilesAreNotRequiredWhenPlatformConfigurationFileIsPresent.
@Test
public void shouldIndicateThatConfigFilesAreNotRequiredWhenPlatformConfigurationFileIsPresent() throws IOException {
BootstrapConfig bootstrapConfig = new BootstrapConfig(new SQLDBConfig("jdbc:mysql://localhost:3306/", "com.mysql.jdbc.Driver", null, null), ConfigSource.FILE, null, null, "tcp://localhost:61616");
when(coreConfigurationService.loadBootstrapConfig()).thenReturn(bootstrapConfig);
ConfigLocation configLocation = mock(ConfigLocation.class);
when(configLocation.hasPlatformConfigurationFile()).thenReturn(true);
when(coreConfigurationService.getConfigLocation()).thenReturn(configLocation);
assertFalse(configurationService.requiresConfigurationFiles());
}
use of org.motechproject.config.core.domain.ConfigLocation in project motech by motech.
the class ConfigurationServiceTest method shouldIndicateThatConfigFilesAreRequiredWhenPlatformConfigurationFileIsMissing.
@Test
public void shouldIndicateThatConfigFilesAreRequiredWhenPlatformConfigurationFileIsMissing() throws IOException {
BootstrapConfig bootstrapConfig = new BootstrapConfig(new SQLDBConfig("jdbc:mysql://localhost:3306/", "com.mysql.jdbc.Driver", null, null), ConfigSource.FILE, null, null, "tcp://localhost:61616");
when(coreConfigurationService.loadBootstrapConfig()).thenReturn(bootstrapConfig);
ConfigLocation configLocation = mock(ConfigLocation.class);
when(configLocation.hasPlatformConfigurationFile()).thenReturn(false);
when(coreConfigurationService.getConfigLocation()).thenReturn(configLocation);
assertTrue(configurationService.requiresConfigurationFiles());
}
Aggregations