Search in sources :

Example 16 with SQLDBConfig

use of org.motechproject.config.core.domain.SQLDBConfig 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()));
}
Also used : BootstrapConfig(org.motechproject.config.core.domain.BootstrapConfig) Properties(java.util.Properties) SQLDBConfig(org.motechproject.config.core.domain.SQLDBConfig) Test(org.junit.Test)

Example 17 with SQLDBConfig

use of org.motechproject.config.core.domain.SQLDBConfig 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()));
}
Also used : BootstrapConfig(org.motechproject.config.core.domain.BootstrapConfig) Properties(java.util.Properties) SQLDBConfig(org.motechproject.config.core.domain.SQLDBConfig) Test(org.junit.Test)

Example 18 with SQLDBConfig

use of org.motechproject.config.core.domain.SQLDBConfig in project motech by motech.

the class SqlDBManagerTest method shouldProperlySetSqlProperties.

@Test
public void shouldProperlySetSqlProperties() throws IOException {
    BootstrapConfig bootstrapConfig = new BootstrapConfig(new SQLDBConfig("jdbc:mysql://localhost:3306/", "com.mysql.jdbc.Driver", "root", "pass"), ConfigSource.FILE, "./felix", motechDir, "tcp://localhost:61616");
    when(coreConfigurationService.loadBootstrapConfig()).thenReturn(bootstrapConfig);
    Properties propertiesToUpdate = new Properties();
    propertiesToUpdate.put("javax.jdo.option.ConnectionURL", "${sql.url}");
    propertiesToUpdate.put("some.username", "${sql.user}");
    propertiesToUpdate.put("some.password", "${sql.password}");
    propertiesToUpdate.put("quartz.delegate", "${sql.quartz.delegateClass}");
    SqlDBManager sqlDBManager = new SqlDBManagerImpl(coreConfigurationService);
    Properties propertiesAfterUpdate = sqlDBManager.getSqlProperties(propertiesToUpdate);
    assertEquals(4, propertiesAfterUpdate.size());
    assertEquals("jdbc:mysql://localhost:3306/", propertiesAfterUpdate.getProperty("javax.jdo.option.ConnectionURL"));
    assertEquals("root", propertiesAfterUpdate.getProperty("some.username"));
    assertEquals("pass", propertiesAfterUpdate.getProperty("some.password"));
    assertEquals(Drivers.QUARTZ_STD_JDBC_DELEGATE, propertiesAfterUpdate.getProperty("quartz.delegate"));
}
Also used : SqlDBManager(org.motechproject.commons.sql.service.SqlDBManager) BootstrapConfig(org.motechproject.config.core.domain.BootstrapConfig) Properties(java.util.Properties) SQLDBConfig(org.motechproject.config.core.domain.SQLDBConfig) Test(org.junit.Test)

Aggregations

SQLDBConfig (org.motechproject.config.core.domain.SQLDBConfig)18 BootstrapConfig (org.motechproject.config.core.domain.BootstrapConfig)17 Test (org.junit.Test)15 Properties (java.util.Properties)10 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 File (java.io.File)3 ConfigLocation (org.motechproject.config.core.domain.ConfigLocation)3 SqlDBManager (org.motechproject.commons.sql.service.SqlDBManager)2 FileInputStream (java.io.FileInputStream)1 ArrayList (java.util.ArrayList)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1