use of org.motechproject.config.core.domain.BootstrapConfig in project motech by motech.
the class BootstrapManagerTest method shouldReturnBootStrapConfigValuesFromEnvironmentVariableWhenMotechConfigDirIsNotSpecified.
@PrepareForTest(ConfigPropertiesUtils.class)
@Test
public void shouldReturnBootStrapConfigValuesFromEnvironmentVariableWhenMotechConfigDirIsNotSpecified() throws IOException {
PowerMockito.mockStatic(ConfigPropertiesUtils.class);
when(environment.getConfigDir()).thenReturn(null);
when(environment.getBootstrapProperties()).thenReturn(createProperties());
BootstrapConfig expectedBootstrapConfig = new BootstrapConfig(new SQLDBConfig(sqlUrl, sqlDriver, sqlUsername, sqlPassword), ConfigSource.FILE, null, null, queueUrl);
assertThat(bootstrapManager.loadBootstrapConfig(), equalTo(expectedBootstrapConfig));
}
use of org.motechproject.config.core.domain.BootstrapConfig in project motech by motech.
the class BootstrapManagerTest method shouldSaveBootstrapConfigToPropertiesFileInDefaultLocation.
@Test
public void shouldSaveBootstrapConfigToPropertiesFileInDefaultLocation() throws IOException {
BootstrapConfig bootstrapConfig = new BootstrapConfig(new SQLDBConfig(sqlUrl, sqlDriver, "some_username", "some_password"), ConfigSource.FILE, felixPath, motechDir, queueUrl);
String tempDir = new File(System.getProperty("java.io.tmpdir"), "config").getAbsolutePath();
List<ConfigLocation> configLocationList = new ArrayList<>();
configLocationList.add(new ConfigLocation(tempDir));
File file = new File(tempDir, BootstrapManager.BOOTSTRAP_PROPERTIES);
when(configLocationFileStore.getAll()).thenReturn(configLocationList);
bootstrapManager.saveBootstrapConfig(bootstrapConfig);
Properties savedBootstrapProperties = new Properties();
savedBootstrapProperties.load(new FileInputStream(new File(tempDir, "bootstrap.properties")));
assertNotNull(savedBootstrapProperties);
assertThat(savedBootstrapProperties.getProperty(SQL_URL), equalTo(sqlUrl));
}
use of org.motechproject.config.core.domain.BootstrapConfig in project motech by motech.
the class BootstrapManagerImpl method getActiveMqConfig.
@Override
public Properties getActiveMqConfig() {
BootstrapConfig bootstrapConfig = loadBootstrapConfig();
Properties activeMqProperties = bootstrapConfig.getActiveMqProperties();
if (activeMqProperties == null) {
return new Properties();
}
replaceQueueNames(activeMqProperties);
return activeMqProperties;
}
use of org.motechproject.config.core.domain.BootstrapConfig in project motech by motech.
the class BootstrapConfigPropertyMapperTest method shouldMapToPropertiesFromBootstrapConfig_WhenUsernameAndPasswordAreBlank.
@Test
public void shouldMapToPropertiesFromBootstrapConfig_WhenUsernameAndPasswordAreBlank() {
Properties bootstrapProperties = BootstrapConfigPropertyMapper.toProperties(new BootstrapConfig(new SQLDBConfig(sqlUrl, sqlDriver, sqlUsername, sqlPassword), configSource, felixPath, motechDir, queueUrl));
Assert.assertThat(bootstrapProperties.getProperty(sqlUsername), nullValue());
Assert.assertThat(bootstrapProperties.getProperty(sqlPassword), nullValue());
Assert.assertThat(bootstrapProperties.getProperty(CONFIG_SOURCE), is(configSource.getName()));
}
use of org.motechproject.config.core.domain.BootstrapConfig in project motech by motech.
the class BootstrapConfigPropertyMapperTest method shouldMapToPropertiesFromBootstrapConfig.
@Test
public void shouldMapToPropertiesFromBootstrapConfig() {
Properties bootstrapProperties = BootstrapConfigPropertyMapper.toProperties(new BootstrapConfig(new SQLDBConfig(sqlUrl, sqlDriver, sqlUsername, sqlPassword), configSource, felixPath, motechDir, queueUrl));
Assert.assertThat(bootstrapProperties.getProperty(CONFIG_SOURCE), is(configSource.getName()));
}
Aggregations