Search in sources :

Example 71 with Props

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

the class TomcatContextsTest method default_context_path_is_root.

@Test
public void default_context_path_is_root() {
    String context = TomcatContexts.getContextPath(new Props(new Properties()));
    assertThat(context).isEmpty();
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Props(org.sonar.process.Props) Properties(java.util.Properties) Test(org.junit.Test)

Example 72 with Props

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

the class TomcatContextsTest method root_context_path_must_be_blank.

@Test
public void root_context_path_must_be_blank() {
    props.setProperty("sonar.web.context", "/");
    assertThat(TomcatContexts.getContextPath(new Props(props))).isEmpty();
}
Also used : Props(org.sonar.process.Props) Test(org.junit.Test)

Example 73 with Props

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

the class TomcatContextsTest method configure_root_webapp.

@Test
public void configure_root_webapp() {
    props.setProperty("foo", "bar");
    StandardContext context = mock(StandardContext.class);
    when(tomcat.addWebapp(anyString(), anyString())).thenReturn(context);
    underTest.configure(tomcat, new Props(props));
    // configure webapp with properties
    verify(context).addParameter("foo", "bar");
}
Also used : StandardContext(org.apache.catalina.core.StandardContext) Props(org.sonar.process.Props) Test(org.junit.Test)

Example 74 with Props

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

the class WebSecurityManagerTest method apply_calls_PluginSecurityManager.

@Test
public void apply_calls_PluginSecurityManager() {
    Properties properties = new Properties();
    properties.setProperty(PATH_HOME.getKey(), "home");
    properties.setProperty(PATH_TEMP.getKey(), "temp");
    Props props = new Props(properties);
    WebSecurityManager securityManager = new WebSecurityManager(pluginSecurityManager, props);
    securityManager.apply();
    verify(pluginSecurityManager).restrictPlugins(any(PluginFileWriteRule.class));
}
Also used : PluginFileWriteRule(org.sonar.process.PluginFileWriteRule) Properties(java.util.Properties) Props(org.sonar.process.Props) Test(org.junit.Test)

Example 75 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)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