void initSettings() {
properties = new Properties();
completeProperties(settings, properties, SONAR_JDBC);
- completeDefaultProperties(properties);
+ completeDefaultProperty(properties, DatabaseProperties.PROP_URL, DEFAULT_URL);
doCompleteProperties(properties);
dialect = DialectUtils.find(properties.getProperty(SONAR_JDBC_DIALECT), properties.getProperty(SONAR_JDBC_URL));
return result;
}
- private static void completeDefaultProperties(Properties props) {
- completeDefaultProperty(props, DatabaseProperties.PROP_URL, DEFAULT_URL);
-
- if (props.getProperty(DatabaseProperties.PROP_USER_DEPRECATED) != null) {
- completeDefaultProperty(props, DatabaseProperties.PROP_USER, props.getProperty(DatabaseProperties.PROP_USER_DEPRECATED));
- }
- }
-
private static void completeDefaultProperty(Properties props, String key, String defaultValue) {
if (props.getProperty(key) == null) {
props.setProperty(key, defaultValue);
assertThat(db.toString()).isEqualTo("Database[jdbc:h2:tcp://localhost/sonar]");
}
- @Test
- public void shouldSupportDeprecatedUserProperty() {
- Settings settings = new Settings();
- settings.setProperty("sonar.jdbc.user", "me");
-
- DefaultDatabase db = new DefaultDatabase(settings);
- db.initSettings();
- Properties props = db.getProperties();
-
- assertThat(props.getProperty("sonar.jdbc.username")).isEqualTo("me");
- }
-
@Test
public void shouldExtractCommonsDbcpProperties() {
Properties props = new Properties();
String PROP_URL = "sonar.jdbc.url";
String PROP_DRIVER = "sonar.jdbc.driverClassName";
String PROP_USER = "sonar.jdbc.username";
+
+ /**
+ * @deprecated not documented for a while (before version 3.6) and not supported since version 5.2.
+ */
+ @Deprecated
String PROP_USER_DEPRECATED = "sonar.jdbc.user";
String PROP_USER_DEFAULT_VALUE = "";
String PROP_PASSWORD = "sonar.jdbc.password";