*/
package org.sonar.core.persistence;
+import com.google.common.annotations.VisibleForTesting;
+
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.dbcp.BasicDataSourceFactory;
import org.apache.commons.lang.StringUtils;
public final DefaultDatabase start() {
try {
- doBeforeStart();
initSettings();
initDatasource();
return this;
}
}
+ @VisibleForTesting
void initSettings() {
initProperties();
initDialect();
}
}
- protected void doBeforeStart() {
- }
-
public final DefaultDatabase stop() {
- doBeforeStop();
if (datasource != null) {
try {
datasource.close();
return this;
}
- protected void doBeforeStop() {
-
- }
-
public final Dialect getDialect() {
return dialect;
}
}
- static void completeProperties(Settings settings, Properties properties, String prefix) {
+ private static void completeProperties(Settings settings, Properties properties, String prefix) {
List<String> jdbcKeys = settings.getKeysStartingWith(prefix);
for (String jdbcKey : jdbcKeys) {
String value = settings.getString(jdbcKey);
}
}
+ @VisibleForTesting
static Properties extractCommonsDbcpProperties(Properties properties) {
Properties result = new Properties();
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
return result;
}
- static String getSchemaPropertyValue(Properties props, String deprecatedKey) {
+ private static String getSchemaPropertyValue(Properties props, String deprecatedKey) {
String value = props.getProperty("sonar.jdbc.schema");
if (StringUtils.isBlank(value) && deprecatedKey != null) {
value = props.getProperty(deprecatedKey);