Search in sources :

Example 21 with Props

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

the class TomcatContextsTest method context_path_must_start_with_slash.

@Test
public void context_path_must_start_with_slash() {
    props.setProperty("sonar.web.context", "foo");
    expectedException.expect(MessageException.class);
    expectedException.expectMessage("Value of 'sonar.web.context' must start with a forward slash: 'foo'");
    underTest.configure(tomcat, new Props(props));
}
Also used : Props(org.sonar.process.Props) Test(org.junit.Test)

Example 22 with Props

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

the class EsServerHolder method get.

public static synchronized EsServerHolder get() throws IOException {
    if (HOLDER == null) {
        File homeDir = Files.createTempDirectory("tmp-es-").toFile();
        homeDir.delete();
        homeDir.mkdir();
        String clusterName = "testCluster";
        String hostName = "127.0.0.1";
        int port = NetworkUtils.freePort();
        Properties properties = new Properties();
        properties.setProperty(ProcessProperties.CLUSTER_NAME, clusterName);
        properties.setProperty(ProcessProperties.SEARCH_PORT, String.valueOf(port));
        properties.setProperty(ProcessProperties.SEARCH_HOST, hostName);
        properties.setProperty(ProcessProperties.PATH_HOME, homeDir.getAbsolutePath());
        properties.setProperty(ProcessEntryPoint.PROPERTY_SHARED_PATH, homeDir.getAbsolutePath());
        SearchServer server = new SearchServer(new Props(properties));
        server.start();
        HOLDER = new EsServerHolder(server, clusterName, port, hostName, homeDir);
    }
    HOLDER.reset();
    return HOLDER;
}
Also used : SearchServer(org.sonar.search.SearchServer) Properties(java.util.Properties) ProcessProperties(org.sonar.process.ProcessProperties) Props(org.sonar.process.Props) File(java.io.File) ProcessEntryPoint(org.sonar.process.ProcessEntryPoint)

Example 23 with Props

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

the class TomcatAccessLogTest method enable_access_logs_by_Default.

@Test
public void enable_access_logs_by_Default() throws Exception {
    Tomcat tomcat = mock(Tomcat.class, Mockito.RETURNS_DEEP_STUBS);
    Props props = new Props(new Properties());
    props.set(ProcessProperties.PATH_LOGS, temp.newFolder().getAbsolutePath());
    underTest.configure(tomcat, props);
    verify(tomcat.getHost().getPipeline()).addValve(any(ProgrammaticLogbackValve.class));
}
Also used : Tomcat(org.apache.catalina.startup.Tomcat) Props(org.sonar.process.Props) Properties(java.util.Properties) ProcessProperties(org.sonar.process.ProcessProperties) Test(org.junit.Test)

Example 24 with Props

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

the class TomcatConnectorsTest method configure_thread_pool.

@Test
public void configure_thread_pool() {
    Properties p = new Properties();
    p.setProperty("sonar.web.http.minThreads", "2");
    p.setProperty("sonar.web.http.maxThreads", "30");
    p.setProperty("sonar.web.http.acceptCount", "20");
    Props props = new Props(p);
    TomcatConnectors.configure(tomcat, props);
    verifyHttpConnector(DEFAULT_PORT, ImmutableMap.of("minSpareThreads", 2, "maxThreads", 30, "acceptCount", 20));
}
Also used : Properties(java.util.Properties) Props(org.sonar.process.Props) Test(org.junit.Test)

Example 25 with Props

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

the class TomcatConnectorsTest method bind_to_all_addresses_by_default.

@Test
public void bind_to_all_addresses_by_default() {
    Properties p = new Properties();
    p.setProperty("sonar.web.port", "9000");
    TomcatConnectors.configure(tomcat, new Props(p));
    verify(tomcat.getService()).addConnector(argThat(new ArgumentMatcher<Connector>() {

        @Override
        public boolean matches(Object o) {
            Connector c = (Connector) o;
            return c.getScheme().equals("http") && c.getPort() == 9000 && ((InetAddress) c.getProperty("address")).getHostAddress().equals("0.0.0.0");
        }
    }));
}
Also used : Connector(org.apache.catalina.connector.Connector) ArgumentMatcher(org.mockito.ArgumentMatcher) Properties(java.util.Properties) Props(org.sonar.process.Props) InetAddress(java.net.InetAddress) 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