-# This file must contain only ISO 8859-1 characters.
-# See http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Properties.html#load(java.io.InputStream)
-#
# Property values can:
# - reference an environment variable, for example sonar.jdbc.url= ${env:SONAR_JDBC_URL}
# - be encrypted. See http://redirect.sonarsource.com/doc/settings-encryption.html
-
#--------------------------------------------------------------------------------------------------
# DATABASE
#
}
}
+ //Remove bad comment of sonar.properties about encoding
+
+ //Encoding is UTF-8, but not ISO-8859-1 as documented
+
+
@Test
public void load_properties_file_if_exists() throws Exception {
FileUtils.write(new File(homeDir, "conf/sonar.properties"), "sonar.jdbc.username=angela\nsonar.origin=file");
rawProperties.setProperty("sonar.origin", "raw");
Props props = new PropsBuilder(rawProperties, jdbcSettings, homeDir).build();
+ // properties loaded from file
assertThat(props.value("sonar.jdbc.username")).isEqualTo("angela");
+
// command-line arguments override sonar.properties file
assertThat(props.value("sonar.origin")).isEqualTo("raw");
}
+ @Test
+ public void utf8_file_encoding() throws Exception {
+ FileUtils.write(new File(homeDir, "conf/sonar.properties"), "utf8prop=Thônes");
+ Props props = new PropsBuilder(new Properties(), jdbcSettings, homeDir).build();
+ assertThat(props.value("utf8prop")).isEqualTo("Thônes");
+ }
+
@Test
public void do_not_load_properties_file_if_not_exists() throws Exception {
FileUtils.forceMkdir(dataDir);