Search in sources :

Example 51 with Props

use of org.sonar.process.Props in project sonarqube by SonarSource.

the class JdbcSettingsTest method checkAndComplete_sets_driver_path_for_postgresql.

@Test
public void checkAndComplete_sets_driver_path_for_postgresql() throws Exception {
    File driverFile = new File(homeDir, "lib/jdbc/postgresql/pg.jar");
    FileUtils.touch(driverFile);
    Props props = newProps(JDBC_URL.getKey(), "jdbc:postgresql://localhost/sonar");
    underTest.accept(props);
    assertThat(props.nonNullValueAsFile(JDBC_DRIVER_PATH.getKey())).isEqualTo(driverFile);
}
Also used : Props(org.sonar.process.Props) File(java.io.File) Test(org.junit.Test)

Example 52 with Props

use of org.sonar.process.Props in project sonarqube by SonarSource.

the class JdbcSettingsTest method fail_with_MessageException_when_url_does_not_have_jdbc_prefix.

@Test
public void fail_with_MessageException_when_url_does_not_have_jdbc_prefix() {
    Props props = newProps(JDBC_URL.getKey(), "oracle:thin:@localhost/XE");
    assertThatThrownBy(() -> underTest.resolveProviderAndEnforceNonnullJdbcUrl(props)).isInstanceOf(MessageException.class).hasMessage("Bad format of JDBC URL: oracle:thin:@localhost/XE");
}
Also used : MessageException(org.sonar.process.MessageException) Props(org.sonar.process.Props) Test(org.junit.Test)

Example 53 with Props

use of org.sonar.process.Props in project sonarqube by SonarSource.

the class JdbcSettingsTest method newProps.

private Props newProps(String... params) {
    Properties properties = new Properties();
    for (int i = 0; i < params.length; i++) {
        properties.setProperty(params[i], params[i + 1]);
        i++;
    }
    properties.setProperty(PATH_HOME.getKey(), homeDir.getAbsolutePath());
    return new Props(properties);
}
Also used : Properties(java.util.Properties) Props(org.sonar.process.Props)

Example 54 with Props

use of org.sonar.process.Props in project sonarqube by SonarSource.

the class EsInstallationTest method getHomeDirectory_is_elasticsearch_subdirectory_of_sq_home_directory.

@Test
public void getHomeDirectory_is_elasticsearch_subdirectory_of_sq_home_directory() throws IOException {
    File sqHomeDir = temp.newFolder();
    Props props = new Props(new Properties());
    props.set(PATH_DATA.getKey(), temp.newFolder().getAbsolutePath());
    props.set(PATH_HOME.getKey(), sqHomeDir.getAbsolutePath());
    props.set(PATH_TEMP.getKey(), temp.newFolder().getAbsolutePath());
    props.set(PATH_LOGS.getKey(), temp.newFolder().getAbsolutePath());
    EsInstallation underTest = new EsInstallation(props);
    assertThat(underTest.getHomeDirectory()).isEqualTo(new File(sqHomeDir, "elasticsearch"));
}
Also used : Props(org.sonar.process.Props) Properties(java.util.Properties) File(java.io.File) Test(org.junit.Test)

Example 55 with Props

use of org.sonar.process.Props in project sonarqube by SonarSource.

the class EsInstallationTest method constructor_fails_with_IAE_if_data_dir_property_is_not_defined.

@Test
public void constructor_fails_with_IAE_if_data_dir_property_is_not_defined() throws IOException {
    Props props = new Props(new Properties());
    props.set(PATH_HOME.getKey(), temp.newFolder().getAbsolutePath());
    assertThatThrownBy(() -> new EsInstallation(props)).isInstanceOf(IllegalArgumentException.class).hasMessage("Missing property: sonar.path.data");
}
Also used : Props(org.sonar.process.Props) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

Props (org.sonar.process.Props)143 Test (org.junit.Test)119 Properties (java.util.Properties)71 File (java.io.File)44 MessageException (org.sonar.process.MessageException)21 ProcessProperties (org.sonar.process.ProcessProperties)19 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)13 Settings (org.elasticsearch.common.settings.Settings)7 NodeHealth (org.sonar.process.cluster.health.NodeHealth)6 InetAddress (java.net.InetAddress)5 LoggerContext (ch.qos.logback.classic.LoggerContext)4 Tomcat (org.apache.catalina.startup.Tomcat)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 Map (java.util.Map)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 Assert.fail (org.junit.Assert.fail)3 ArgumentMatchers.argThat (org.mockito.ArgumentMatchers.argThat)3 Mockito (org.mockito.Mockito)3 Mockito.mock (org.mockito.Mockito.mock)3 Mockito.verify (org.mockito.Mockito.verify)3