use of org.motechproject.config.core.domain.SQLDBConfig in project motech by motech.
the class ConfigurationServiceTest method shouldSaveBootstrapConfig.
@Test
public void shouldSaveBootstrapConfig() 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");
configurationService.save(bootstrapConfig);
verify(coreConfigurationService).saveBootstrapConfig(bootstrapConfig);
}
use of org.motechproject.config.core.domain.SQLDBConfig in project motech by motech.
the class ConfigurationServiceTest method shouldLoadBootstrapDBConfiguration.
@Test
public void shouldLoadBootstrapDBConfiguration() {
BootstrapConfig expectedConfig = new BootstrapConfig(new SQLDBConfig("jdbc:mysql://localhost:3306/", "com.mysql.jdbc.Driver", null, null), null, null, null, "tcp://localhost:61616");
when(coreConfigurationService.loadBootstrapConfig()).thenReturn(expectedConfig);
BootstrapConfig bootstrapConfig = configurationService.loadBootstrapConfig();
assertNotNull(bootstrapConfig);
assertThat(bootstrapConfig, IsEqual.equalTo(bootstrapConfig));
}
use of org.motechproject.config.core.domain.SQLDBConfig 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.SQLDBConfig 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.SQLDBConfig in project motech by motech.
the class SqlDBManagerImpl method loadSqlProperties.
private void loadSqlProperties() {
sqlProperties = new Properties();
SQLDBConfig sqlConfig = coreConfigurationService.loadBootstrapConfig().getSqlConfig();
String sqlUrl = sqlConfig.getUrl();
if (!sqlUrl.endsWith("/")) {
sqlUrl.concat("/");
}
sqlProperties.setProperty(SQL_URL, sqlUrl);
String sqlUser = sqlConfig.getUsername();
if (sqlUser != null) {
sqlProperties.setProperty(SQL_USER, sqlUser);
}
String sqlPassword = sqlConfig.getPassword();
if (sqlPassword != null) {
sqlProperties.setProperty(SQL_PASSWORD, sqlPassword);
}
String sqlDriver = sqlConfig.getDriver();
if (sqlDriver != null) {
sqlProperties.setProperty(SQL_DRIVER, sqlDriver);
}
String quartzDelegate = getQuartzDriverDeletegate(sqlDriver);
sqlProperties.setProperty("sql.quartz.delegateClass", quartzDelegate);
}
Aggregations