use of org.motechproject.commons.sql.service.SqlDBManager in project motech by motech.
the class SqlDBManagerTest method shouldARemoveSlash.
@Test
public void shouldARemoveSlash() 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}dbname?useSSL=true");
SqlDBManager sqlDBManager = new SqlDBManagerImpl(coreConfigurationService);
Properties propertiesAfterUpdate = sqlDBManager.getSqlProperties(propertiesToUpdate);
assertEquals("jdbc:mysql://localhost:3306/dbname?useSSL=true", propertiesAfterUpdate.getProperty("javax.jdo.option.ConnectionURL"));
propertiesToUpdate = new Properties();
propertiesToUpdate.put("javax.jdo.option.ConnectionURL", "${sql.url}/dbname?useSSL=true");
propertiesAfterUpdate = sqlDBManager.getSqlProperties(propertiesToUpdate);
assertEquals("jdbc:mysql://localhost:3306/dbname?useSSL=true", propertiesAfterUpdate.getProperty("javax.jdo.option.ConnectionURL"));
}
use of org.motechproject.commons.sql.service.SqlDBManager 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"));
}
Aggregations