Search in sources :

Example 31 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)).isEqualTo("jdbc:h2:tcp://localhost:9092/sonar");
}
Also used : Props(org.sonar.process.Props) Test(org.junit.Test)

Example 32 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, url);
    assertThat(underTest.resolveProviderAndEnforceNonnullJdbcUrl(props)).isEqualTo(expected);
    assertThat(props.nonNullValue(JDBC_URL)).isEqualTo(url);
}
Also used : Props(org.sonar.process.Props)

Example 33 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, "jdbc:sqlserver://localhost/sonar;SelectMethod=Cursor");
    underTest.accept(props);
    assertThat(props.nonNullValueAsFile(ProcessProperties.JDBC_DRIVER_PATH)).isEqualTo(driverFile);
}
Also used : Props(org.sonar.process.Props) File(java.io.File) Test(org.junit.Test)

Example 34 with Props

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

the class WebServer method main.

/**
   * Can't be started as is. Needs to be bootstrapped by sonar-application
   */
public static void main(String[] args) {
    ProcessEntryPoint entryPoint = ProcessEntryPoint.createForArguments(args);
    Props props = entryPoint.getProps();
    new WebServerProcessLogging().configure(props);
    WebServer server = new WebServer(props);
    entryPoint.launch(server);
}
Also used : ProcessEntryPoint(org.sonar.process.ProcessEntryPoint) Props(org.sonar.process.Props)

Example 35 with Props

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

the class EsSettingsTest method test_default_settings.

@Test
public void test_default_settings() throws Exception {
    File homeDir = temp.newFolder();
    Props props = new Props(new Properties());
    props.set(ProcessProperties.SEARCH_PORT, "1234");
    props.set(ProcessProperties.SEARCH_HOST, "127.0.0.1");
    props.set(ProcessProperties.PATH_HOME, homeDir.getAbsolutePath());
    props.set(ProcessProperties.CLUSTER_NAME, "sonarqube");
    EsSettings esSettings = new EsSettings(props);
    Settings generated = esSettings.build();
    assertThat(generated.get("transport.tcp.port")).isEqualTo("1234");
    assertThat(generated.get("transport.host")).isEqualTo("127.0.0.1");
    // no cluster, but cluster and node names are set though
    assertThat(generated.get("cluster.name")).isEqualTo("sonarqube");
    assertThat(generated.get("node.name")).isEqualTo("sonarqube");
    assertThat(generated.get("path.data")).isNotNull();
    assertThat(generated.get("path.logs")).isNotNull();
    assertThat(generated.get("path.home")).isNotNull();
    // http is disabled for security reasons
    assertThat(generated.get("http.enabled")).isEqualTo("false");
    assertThat(generated.get("index.number_of_replicas")).isEqualTo("0");
    assertThat(generated.get("discovery.zen.ping.unicast.hosts")).isNull();
}
Also used : Props(org.sonar.process.Props) ProcessProperties(org.sonar.process.ProcessProperties) Properties(java.util.Properties) File(java.io.File) Settings(org.elasticsearch.common.settings.Settings) Test(org.junit.Test)

Aggregations

Props (org.sonar.process.Props)39 Test (org.junit.Test)32 Properties (java.util.Properties)20 File (java.io.File)11 ProcessProperties (org.sonar.process.ProcessProperties)9 Settings (org.elasticsearch.common.settings.Settings)7 InetAddress (java.net.InetAddress)3 Connector (org.apache.catalina.connector.Connector)3 ArgumentMatcher (org.mockito.ArgumentMatcher)3 ProcessEntryPoint (org.sonar.process.ProcessEntryPoint)3 ConnectException (java.net.ConnectException)1 URL (java.net.URL)1 Date (java.util.Date)1 StandardContext (org.apache.catalina.core.StandardContext)1 Tomcat (org.apache.catalina.startup.Tomcat)1 NoNodeAvailableException (org.elasticsearch.client.transport.NoNodeAvailableException)1 InetSocketTransportAddress (org.elasticsearch.common.transport.InetSocketTransportAddress)1 Matchers.anyString (org.mockito.Matchers.anyString)1 MutablePicoContainer (org.picocontainer.MutablePicoContainer)1 CoreProperties (org.sonar.api.CoreProperties)1