Search in sources :

Example 91 with Props

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

the class JdbcSettingsTest method checkAndComplete_sets_driver_path_for_oracle.

@Test
public void checkAndComplete_sets_driver_path_for_oracle() throws Exception {
    File driverFile = new File(homeDir, "extensions/jdbc-driver/oracle/ojdbc6.jar");
    FileUtils.touch(driverFile);
    Props props = newProps(JDBC_URL.getKey(), "jdbc:oracle:thin:@localhost/XE");
    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 92 with Props

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

the class JdbcSettingsTest method fail_with_MessageException_when_provider_is_not_supported.

@Test
public void fail_with_MessageException_when_provider_is_not_supported() {
    Props props = newProps(JDBC_URL.getKey(), "jdbc:microsoft:sqlserver://localhost");
    assertThatThrownBy(() -> underTest.resolveProviderAndEnforceNonnullJdbcUrl(props)).isInstanceOf(MessageException.class).hasMessage("Unsupported JDBC driver provider: microsoft");
}
Also used : MessageException(org.sonar.process.MessageException) Props(org.sonar.process.Props) Test(org.junit.Test)

Example 93 with Props

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

the class JdbcSettingsTest method checkAndComplete_sets_driver_path_for_mssql.

@Test
public void checkAndComplete_sets_driver_path_for_mssql() throws Exception {
    File driverFile = new File(homeDir, "lib/jdbc/mssql/sqljdbc4.jar");
    FileUtils.touch(driverFile);
    Props props = newProps(JDBC_URL.getKey(), "jdbc:sqlserver://localhost/sonar;SelectMethod=Cursor");
    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 94 with Props

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

the class JdbcSettingsTest method resolve_H2_provider_when_props_is_empty_and_set_URL_to_default_H2.

@Test
public void resolve_H2_provider_when_props_is_empty_and_set_URL_to_default_H2() {
    Props props = newProps();
    assertThat(underTest.resolveProviderAndEnforceNonnullJdbcUrl(props)).isEqualTo(Provider.H2);
    assertThat(props.nonNullValue(JDBC_URL.getKey())).isEqualTo(String.format("jdbc:h2:tcp://%s:9092/sonar;NON_KEYWORDS=VALUE", InetAddress.getLoopbackAddress().getHostAddress()));
}
Also used : Props(org.sonar.process.Props) Test(org.junit.Test)

Example 95 with Props

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

the class JdbcSettingsTest method checkProviderForUrlAndUnchangedUrl.

private void checkProviderForUrlAndUnchangedUrl(String url, Provider expected) {
    Props props = newProps(JDBC_URL.getKey(), url);
    assertThat(underTest.resolveProviderAndEnforceNonnullJdbcUrl(props)).isEqualTo(expected);
    assertThat(props.nonNullValue(JDBC_URL.getKey())).isEqualTo(url);
}
Also used : Props(org.sonar.process.Props)

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