Search in sources :

Example 41 with Props

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

the class EsJvmOptionsTest method boostrap_checks_can_be_set_false_if_h2.

@Test
public void boostrap_checks_can_be_set_false_if_h2() throws IOException {
    properties.put("sonar.jdbc.url", "jdbc:h2:tcp://ffoo:bar/sonar");
    properties.put("sonar.es.bootstrap.checks.disable", "false");
    File tmpDir = temporaryFolder.newFolder();
    EsJvmOptions underTest = new EsJvmOptions(new Props(properties), tmpDir);
    assertThat(underTest.getAll()).isNotEmpty().contains("-Des.enforce.bootstrap.checks=true");
}
Also used : Props(org.sonar.process.Props) File(java.io.File) Test(org.junit.Test)

Example 42 with Props

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

the class EsJvmOptionsTest method writeToJvmOptionFile_throws_ISE_in_case_of_IOException.

@Test
public void writeToJvmOptionFile_throws_ISE_in_case_of_IOException() throws IOException {
    File notAFile = temporaryFolder.newFolder();
    EsJvmOptions underTest = new EsJvmOptions(new Props(properties), temporaryFolder.newFolder());
    assertThatThrownBy(() -> underTest.writeToJvmOptionFile(notAFile)).isInstanceOf(IllegalStateException.class).hasMessage("Cannot write Elasticsearch jvm options file").hasRootCauseInstanceOf(IOException.class);
}
Also used : Props(org.sonar.process.Props) File(java.io.File) Test(org.junit.Test)

Example 43 with Props

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

the class JvmOptionsTest method addFromMandatoryProperty_checks_against_mandatory_options_is_case_sensitive.

@Test
public void addFromMandatoryProperty_checks_against_mandatory_options_is_case_sensitive() {
    String[] optionOverrides = { randomPrefix, randomPrefix + randomValue.substring(1), randomPrefix + randomValue.substring(1), randomPrefix + randomValue.substring(2), randomPrefix + randomValue.substring(3), randomPrefix + randomValue.substring(3) + randomAlphanumeric(1), randomPrefix + randomValue.substring(3) + randomAlphanumeric(2), randomPrefix + randomValue.substring(3) + randomAlphanumeric(3), randomPrefix + randomValue + randomAlphanumeric(1) };
    JvmOptions underTest = new JvmOptions(ImmutableMap.of(randomPrefix, randomValue));
    for (String optionOverride : optionOverrides) {
        properties.setProperty(randomPropertyName, optionOverride.toUpperCase(Locale.ENGLISH));
        underTest.addFromMandatoryProperty(new Props(properties), randomPropertyName);
    }
}
Also used : Props(org.sonar.process.Props) Test(org.junit.Test)

Example 44 with Props

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

the class JvmOptionsTest method addFromMandatoryProperty_supports_spaces_inside_options.

@Test
public void addFromMandatoryProperty_supports_spaces_inside_options() {
    properties.put(randomPropertyName, "-foo bar -duck");
    underTest.addFromMandatoryProperty(new Props(properties), randomPropertyName);
    assertThat(underTest.getAll()).containsOnly("-foo bar", "-duck");
}
Also used : Props(org.sonar.process.Props) Test(org.junit.Test)

Example 45 with Props

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

the class AppSettingsImplTest method reload_updates_properties.

@Test
public void reload_updates_properties() {
    Props initialProps = new Props(new Properties());
    initialProps.set("foo", "bar");
    Props newProps = new Props(new Properties());
    newProps.set("foo", "baz");
    newProps.set("newProp", "newVal");
    AppSettingsImpl underTest = new AppSettingsImpl(initialProps);
    underTest.reload(newProps);
    assertThat(underTest.getValue("foo").get()).isEqualTo("baz");
    assertThat(underTest.getValue("newProp").get()).isEqualTo("newVal");
    assertThat(underTest.getProps().rawProperties()).hasSize(2);
}
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