]> source.dussan.org Git - sonarqube.git/commitdiff
Central definition of properties shared by ES, web and monitor processes
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 8 Oct 2014 20:09:55 +0000 (22:09 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 8 Oct 2014 20:36:37 +0000 (22:36 +0200)
29 files changed:
server/sonar-process/src/main/java/org/sonar/process/ProcessConstants.java [new file with mode: 0644]
server/sonar-process/src/main/java/org/sonar/process/ProcessEntryPoint.java
server/sonar-process/src/main/java/org/sonar/process/ProcessLogging.java
server/sonar-search/src/main/java/org/sonar/search/EsSettings.java [deleted file]
server/sonar-search/src/main/java/org/sonar/search/SearchServer.java
server/sonar-search/src/main/java/org/sonar/search/SearchSettings.java [new file with mode: 0644]
server/sonar-search/src/test/java/org/sonar/search/EsSettingsTest.java [deleted file]
server/sonar-search/src/test/java/org/sonar/search/SearchServerTest.java
server/sonar-search/src/test/java/org/sonar/search/SearchSettingsTest.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/app/EmbeddedTomcat.java
server/sonar-server/src/main/java/org/sonar/server/app/Logging.java
server/sonar-server/src/main/java/org/sonar/server/app/Webapp.java
server/sonar-server/src/main/java/org/sonar/server/db/EmbeddedDatabase.java
server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java
server/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java
server/sonar-server/src/main/java/org/sonar/server/search/IndexProperties.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/search/SearchClient.java
server/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java
server/sonar-server/src/test/java/org/sonar/server/app/LoggingTest.java
server/sonar-server/src/test/java/org/sonar/server/db/EmbeddedDatabaseTest.java
server/sonar-server/src/test/java/org/sonar/server/platform/ServerImplTest.java
server/sonar-server/src/test/java/org/sonar/server/search/BaseIndexTest.java
server/sonar-server/src/test/java/org/sonar/server/tester/ServerTester.java
sonar-application/src/main/java/org/sonar/application/App.java
sonar-application/src/main/java/org/sonar/application/DefaultSettings.java
sonar-application/src/main/java/org/sonar/application/JdbcSettings.java
sonar-application/src/main/java/org/sonar/application/PropsBuilder.java
sonar-application/src/test/java/org/sonar/application/AppTest.java
sonar-application/src/test/java/org/sonar/application/JdbcSettingsTest.java

diff --git a/server/sonar-process/src/main/java/org/sonar/process/ProcessConstants.java b/server/sonar-process/src/main/java/org/sonar/process/ProcessConstants.java
new file mode 100644 (file)
index 0000000..57aeb2b
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.process;
+
+/**
+ * Constants shared by search, web server and monitor processes.
+ * It represents more or less all the properties commented in conf/sonar.properties
+ */
+public interface ProcessConstants {
+
+  String CLUSTER_ACTIVATION = "sonar.cluster.activation";
+  String CLUSTER_MASTER_HOSTS = "sonar.cluster.master";
+  String CLUSTER_NAME = "sonar.cluster.name";
+  String CLUSTER_NODE_NAME = "sonar.node.name";
+
+  String JDBC_URL = "sonar.jdbc.url";
+  String JDBC_LOGIN = "sonar.jdbc.username";
+  String JDBC_PASSWORD = "sonar.jdbc.password";
+  String JDBC_DRIVER_PATH = "sonar.jdbc.driverPath";
+
+  String PATH_DATA = "sonar.path.data";
+  String PATH_HOME = "sonar.path.home";
+  String PATH_LOGS = "sonar.path.logs";
+  String PATH_TEMP = "sonar.path.temp";
+  String PATH_WEB = "sonar.path.web";
+
+  String SEARCH_PORT = "sonar.search.port";
+  String SEARCH_JAVA_OPTS = "sonar.search.javaOpts";
+  String SEARCH_JAVA_ADDITIONAL_OPTS = "sonar.search.javaAdditionalOpts";
+  String SEARCH_TYPE = "sonar.search.type";
+
+  String WEB_JAVA_OPTS = "sonar.web.javaOpts";
+  String WEB_JAVA_ADDITIONAL_OPTS = "sonar.web.javaAdditionalOpts";
+
+  /**
+   * Used by Orchestrator to ask for shutdown of monitor process
+   */
+  String ENABLE_STOP_COMMAND = "sonar.enableStopCommand";
+
+}
index 870f1aea067075bbfa40e28f7325a69fbc2ecf94..69327b8115ae253c8df1e7e4b64a589f8f0aa223 100644 (file)
@@ -70,7 +70,7 @@ public class ProcessEntryPoint implements Stoppable {
     monitored = mp;
 
     try {
-      LoggerFactory.getLogger(getClass()).warn("Starting " + getKey());
+      LoggerFactory.getLogger(getClass()).info("Starting " + getKey());
       Runtime.getRuntime().addShutdownHook(shutdownHook);
       stopWatcher.start();
 
index 2fb7baa865e119a5dd4cad02ae340e3508f23aad..fe7f647d2e9d6bf9570fae3cba0f5c845c000ae5 100644 (file)
@@ -30,15 +30,13 @@ import org.slf4j.LoggerFactory;
 
 public class ProcessLogging {
 
-  private static final String PATH_LOGS_PROPERTY = "sonar.path.logs";
-
   public void configure(Props props, String logbackXmlResource) {
     LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
     try {
       JoranConfigurator configurator = new JoranConfigurator();
       configurator.setContext(context);
       context.reset();
-      context.putProperty(PATH_LOGS_PROPERTY, props.nonNullValue(PATH_LOGS_PROPERTY));
+      context.putProperty(ProcessConstants.PATH_LOGS, props.nonNullValue(ProcessConstants.PATH_LOGS));
       doConfigure(configurator, logbackXmlResource);
     } catch (JoranException ignored) {
       // StatusPrinter will handle this
diff --git a/server/sonar-search/src/main/java/org/sonar/search/EsSettings.java b/server/sonar-search/src/main/java/org/sonar/search/EsSettings.java
deleted file mode 100644 (file)
index 210742b..0000000
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.search;
-
-import org.apache.commons.lang.StringUtils;
-import org.elasticsearch.common.settings.ImmutableSettings;
-import org.elasticsearch.common.settings.Settings;
-import org.slf4j.LoggerFactory;
-import org.sonar.process.MessageException;
-import org.sonar.process.Props;
-import org.sonar.search.script.ListUpdate;
-
-import java.io.File;
-import java.net.InetAddress;
-import java.util.Arrays;
-import java.util.LinkedHashSet;
-import java.util.Set;
-import java.util.TreeSet;
-
-class EsSettings {
-
-  // set by monitor process, so value is never null
-  public static final String PROP_TCP_PORT = "sonar.search.port";
-
-  public static final String PROP_CLUSTER_ACTIVATION = "sonar.cluster.activation";
-  public static final String PROP_NODE_NAME = "sonar.node.name";
-  public static final String PROP_CLUSTER_NAME = "sonar.cluster.name";
-  public static final String PROP_CLUSTER_MASTER = "sonar.cluster.master";
-  public static final String PROP_HTTP_PORT = "sonar.search.httpPort";
-  public static final String PROP_MARVEL = "sonar.search.marvel";
-
-  public static final String SONAR_PATH_HOME = "sonar.path.home";
-  public static final String SONAR_PATH_DATA = "sonar.path.data";
-  public static final String SONAR_PATH_TEMP = "sonar.path.temp";
-  public static final String SONAR_PATH_LOG = "sonar.path.log";
-
-  private final Props props;
-  private final Set<String> clusterNodes = new LinkedHashSet<String>();
-  private final String clusterName;
-  private final int tcpPort;
-
-  EsSettings(Props props) {
-    this.props = props;
-    clusterNodes.addAll(Arrays.asList(StringUtils.split(props.value(PROP_CLUSTER_MASTER, ""), ",")));
-
-    clusterName = props.value(PROP_CLUSTER_NAME);
-    Integer port = props.valueAsInt(PROP_TCP_PORT);
-    if (port == null) {
-      throw new MessageException("Property is not set: " + PROP_TCP_PORT);
-    }
-    tcpPort = port.intValue();
-  }
-
-  boolean inCluster() {
-    return !clusterNodes.isEmpty();
-  }
-
-  String clusterName() {
-    return clusterName;
-  }
-
-  int tcpPort() {
-    return tcpPort;
-  }
-
-  Settings build() {
-    ImmutableSettings.Builder builder = ImmutableSettings.settingsBuilder();
-    configureFileSystem(builder);
-    configureStorage(builder);
-    configurePlugins(builder);
-    configureNetwork(builder);
-    configureCluster(builder);
-    configureMarvel(builder);
-    System.out.println(builder.build());
-    return builder.build();
-  }
-
-  private void configureFileSystem(ImmutableSettings.Builder builder) {
-    File homeDir = props.nonNullValueAsFile(SONAR_PATH_HOME);
-    File dataDir, workDir, logDir;
-
-    // data dir
-    String dataPath = props.value(SONAR_PATH_DATA);
-    if (StringUtils.isNotEmpty(dataPath)) {
-      dataDir = new File(dataPath, "es");
-    } else {
-      dataDir = new File(homeDir, "data/es");
-    }
-    builder.put("path.data", dataDir.getAbsolutePath());
-
-    // working dir
-    String workPath = props.value(SONAR_PATH_TEMP);
-    if (StringUtils.isNotEmpty(workPath)) {
-      workDir = new File(workPath);
-    } else {
-      workDir = new File(homeDir, "temp");
-    }
-    builder.put("path.work", workDir.getAbsolutePath());
-    builder.put("path.plugins", workDir.getAbsolutePath());
-
-    // log dir
-    String logPath = props.value(SONAR_PATH_LOG);
-    if (StringUtils.isNotEmpty(logPath)) {
-      logDir = new File(logPath);
-    } else {
-      logDir = new File(homeDir, "log");
-    }
-    builder.put("path.logs", logDir.getAbsolutePath());
-  }
-
-  private void configurePlugins(ImmutableSettings.Builder builder) {
-    builder
-      .put("script.default_lang", "native")
-      .put("script.native." + ListUpdate.NAME + ".type", ListUpdate.UpdateListScriptFactory.class.getName());
-  }
-
-  private void configureNetwork(ImmutableSettings.Builder builder) {
-    // disable multicast
-    builder.put("discovery.zen.ping.multicast.enabled", "false");
-
-    builder.put("transport.tcp.port", tcpPort);
-
-    Integer httpPort = props.valueAsInt(PROP_HTTP_PORT);
-    if (httpPort ==null) {
-      // standard configuration
-      builder.put("http.enabled", false);
-    } else {
-      builder.put("http.enabled", true);
-      builder.put("http.host", "127.0.0.1");
-      builder.put("http.port", httpPort);
-    }
-  }
-
-  private void configureStorage(ImmutableSettings.Builder builder) {
-    builder
-      .put("index.number_of_shards", "1")
-      .put("index.refresh_interval", "30s")
-      .put("index.store.type", "mmapfs")
-      .put("indices.store.throttle.type", "none")
-      .put("index.merge.scheduler.max_thread_count",
-        Math.max(1, Math.min(3, Runtime.getRuntime().availableProcessors() / 2)));
-  }
-
-  private void configureCluster(ImmutableSettings.Builder builder) {
-    if (!clusterNodes.isEmpty()) {
-      LoggerFactory.getLogger(SearchServer.class).info("Joining ES cluster with master: {}", clusterNodes);
-      builder.put("discovery.zen.ping.unicast.hosts", StringUtils.join(clusterNodes, ","));
-      builder.put("node.master", false);
-
-      // Enforce a N/2+1 number of masters in cluster
-      builder.put("discovery.zen.minimum_master_nodes", 1);
-    }
-
-    // When SQ is ran as a cluster
-    // see https://jira.codehaus.org/browse/SONAR-5687
-    int replicationFactor = props.valueAsBoolean(PROP_CLUSTER_ACTIVATION, false) ? 1 : 0;
-    builder.put("index.number_of_replicas", replicationFactor);
-
-    // Set cluster coordinates
-    builder.put("cluster.name", clusterName);
-    builder.put("cluster.routing.allocation.awareness.attributes", "rack_id");
-    builder.put("node.rack_id", props.value(PROP_NODE_NAME, "unknown"));
-    if (props.contains(PROP_NODE_NAME)) {
-      builder.put("node.name", props.value(PROP_NODE_NAME));
-    } else {
-      try {
-        builder.put("node.name", InetAddress.getLocalHost().getHostName());
-      } catch (Exception e) {
-        LoggerFactory.getLogger(SearchServer.class).warn("Could not determine hostname", e);
-        builder.put("node.name", "sq-" + System.currentTimeMillis());
-      }
-    }
-  }
-
-  private void configureMarvel(ImmutableSettings.Builder builder) {
-    Set<String> marvels = new TreeSet<String>();
-    marvels.addAll(Arrays.asList(StringUtils.split(props.value(PROP_MARVEL, ""), ",")));
-
-    // Enable marvel's index creation
-    builder.put("action.auto_create_index", ".marvel-*");
-    // If we're collecting indexing data send them to the Marvel host(s)
-    if (!marvels.isEmpty()) {
-      builder.put("marvel.agent.exporter.es.hosts", StringUtils.join(marvels, ","));
-    }
-  }
-}
index 21c86b59a66fd65880f3cfdf44c1f6865ead0e51..0a46070f4fb66b52379d06e927d764b2dc625e85 100644 (file)
@@ -34,11 +34,11 @@ import org.sonar.process.Props;
 
 public class SearchServer implements Monitored {
 
-  private final EsSettings settings;
+  private final SearchSettings settings;
   private InternalNode node;
 
   public SearchServer(Props props) {
-    this.settings = new EsSettings(props);
+    this.settings = new SearchSettings(props);
     new MinimumViableSystem().check();
   }
 
diff --git a/server/sonar-search/src/main/java/org/sonar/search/SearchSettings.java b/server/sonar-search/src/main/java/org/sonar/search/SearchSettings.java
new file mode 100644 (file)
index 0000000..e82efd8
--- /dev/null
@@ -0,0 +1,196 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.search;
+
+import org.apache.commons.lang.StringUtils;
+import org.elasticsearch.common.settings.ImmutableSettings;
+import org.elasticsearch.common.settings.Settings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.sonar.process.MessageException;
+import org.sonar.process.ProcessConstants;
+import org.sonar.process.Props;
+import org.sonar.search.script.ListUpdate;
+
+import java.io.File;
+import java.net.InetAddress;
+import java.util.Arrays;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import java.util.TreeSet;
+
+class SearchSettings {
+
+  private static Logger LOGGER = LoggerFactory.getLogger(SearchSettings.class);
+
+  public static final String PROP_HTTP_PORT = "sonar.search.httpPort";
+  public static final String PROP_MARVEL_HOSTS = "sonar.search.marvelHosts";
+
+  private final Props props;
+  private final Set<String> clusterNodes = new LinkedHashSet<String>();
+  private final String clusterName;
+  private final int tcpPort;
+
+  SearchSettings(Props props) {
+    this.props = props;
+    clusterNodes.addAll(Arrays.asList(StringUtils.split(props.value(ProcessConstants.CLUSTER_MASTER_HOSTS, ""), ",")));
+    clusterName = props.value(ProcessConstants.CLUSTER_NAME);
+    Integer port = props.valueAsInt(ProcessConstants.SEARCH_PORT);
+    if (port == null) {
+      throw new MessageException("Property is not set: " + ProcessConstants.SEARCH_PORT);
+    }
+    tcpPort = port.intValue();
+  }
+
+  boolean inCluster() {
+    return !clusterNodes.isEmpty();
+  }
+
+  String clusterName() {
+    return clusterName;
+  }
+
+  int tcpPort() {
+    return tcpPort;
+  }
+
+  Settings build() {
+    ImmutableSettings.Builder builder = ImmutableSettings.settingsBuilder();
+    configureFileSystem(builder);
+    configureStorage(builder);
+    configurePlugins(builder);
+    configureNetwork(builder);
+    configureCluster(builder);
+    configureMarvel(builder);
+    return builder.build();
+  }
+
+  private void configureFileSystem(ImmutableSettings.Builder builder) {
+    File homeDir = props.nonNullValueAsFile(ProcessConstants.PATH_HOME);
+    File dataDir, workDir, logDir;
+
+    // data dir
+    String dataPath = props.value(ProcessConstants.PATH_DATA);
+    if (StringUtils.isNotEmpty(dataPath)) {
+      dataDir = new File(dataPath, "es");
+    } else {
+      dataDir = new File(homeDir, "data/es");
+    }
+    builder.put("path.data", dataDir.getAbsolutePath());
+
+    // working dir
+    String workPath = props.value(ProcessConstants.PATH_TEMP);
+    if (StringUtils.isNotEmpty(workPath)) {
+      workDir = new File(workPath);
+    } else {
+      workDir = new File(homeDir, "temp");
+    }
+    builder.put("path.work", workDir.getAbsolutePath());
+    builder.put("path.plugins", workDir.getAbsolutePath());
+
+    // log dir
+    String logPath = props.value(ProcessConstants.PATH_LOGS);
+    if (StringUtils.isNotEmpty(logPath)) {
+      logDir = new File(logPath);
+    } else {
+      logDir = new File(homeDir, "log");
+    }
+    builder.put("path.logs", logDir.getAbsolutePath());
+  }
+
+  private void configurePlugins(ImmutableSettings.Builder builder) {
+    builder
+      .put("script.default_lang", "native")
+      .put("script.native." + ListUpdate.NAME + ".type", ListUpdate.UpdateListScriptFactory.class.getName());
+  }
+
+  private void configureNetwork(ImmutableSettings.Builder builder) {
+    // disable multicast
+    builder.put("discovery.zen.ping.multicast.enabled", "false");
+    builder.put("transport.tcp.port", tcpPort);
+
+    Integer httpPort = props.valueAsInt(PROP_HTTP_PORT);
+    if (httpPort == null) {
+      // standard configuration
+      builder.put("http.enabled", false);
+    } else {
+      LOGGER.warn(String.format(
+        "Elasticsearch HTTP connector is enabled on port %d. MUST NOT BE USED INTO PRODUCTION", httpPort));
+      builder.put("http.enabled", true);
+      builder.put("http.host", "127.0.0.1");
+      builder.put("http.port", httpPort);
+    }
+  }
+
+  private void configureStorage(ImmutableSettings.Builder builder) {
+    builder
+      .put("index.number_of_shards", "1")
+      .put("index.refresh_interval", "30s")
+      .put("index.store.type", "mmapfs")
+      .put("indices.store.throttle.type", "none")
+      .put("index.merge.scheduler.max_thread_count",
+        Math.max(1, Math.min(3, Runtime.getRuntime().availableProcessors() / 2)));
+  }
+
+  private void configureCluster(ImmutableSettings.Builder builder) {
+    if (!clusterNodes.isEmpty()) {
+      LoggerFactory.getLogger(SearchServer.class).info("Joining ES cluster with master: {}", clusterNodes);
+      builder.put("discovery.zen.ping.unicast.hosts", StringUtils.join(clusterNodes, ","));
+      builder.put("node.master", false);
+
+      // Enforce a N/2+1 number of masters in cluster
+      builder.put("discovery.zen.minimum_master_nodes", 1);
+    }
+
+    // When SQ is ran as a cluster
+    // see https://jira.codehaus.org/browse/SONAR-5687
+    int replicationFactor = props.valueAsBoolean(ProcessConstants.CLUSTER_ACTIVATION, false) ? 1 : 0;
+    builder.put("index.number_of_replicas", replicationFactor);
+
+    // Set cluster coordinates
+    builder.put("cluster.name", clusterName);
+    builder.put("cluster.routing.allocation.awareness.attributes", "rack_id");
+    builder.put("node.rack_id", props.value(ProcessConstants.CLUSTER_NODE_NAME, "unknown"));
+    if (props.contains(ProcessConstants.CLUSTER_NODE_NAME)) {
+      builder.put("node.name", props.value(ProcessConstants.CLUSTER_NODE_NAME));
+    } else {
+      try {
+        builder.put("node.name", InetAddress.getLocalHost().getHostName());
+      } catch (Exception e) {
+        LoggerFactory.getLogger(SearchServer.class).warn("Could not determine hostname", e);
+        builder.put("node.name", "sq-" + System.currentTimeMillis());
+      }
+    }
+  }
+
+  private void configureMarvel(ImmutableSettings.Builder builder) {
+    Set<String> marvels = new TreeSet<String>();
+    marvels.addAll(Arrays.asList(StringUtils.split(props.value(PROP_MARVEL_HOSTS, ""), ",")));
+
+    // Enable marvel's index creation
+    builder.put("action.auto_create_index", ".marvel-*");
+    // If we're collecting indexing data send them to the Marvel host(s)
+    if (!marvels.isEmpty()) {
+      String hosts = StringUtils.join(marvels, ",");
+      LOGGER.info(String.format("Elasticsearch Marvel is enabled for %s", hosts));
+      builder.put("marvel.agent.exporter.es.hosts", hosts);
+    }
+  }
+}
diff --git a/server/sonar-search/src/test/java/org/sonar/search/EsSettingsTest.java b/server/sonar-search/src/test/java/org/sonar/search/EsSettingsTest.java
deleted file mode 100644 (file)
index 0f15c69..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.search;
-
-import org.elasticsearch.common.settings.Settings;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.sonar.process.MessageException;
-import org.sonar.process.Props;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Properties;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-
-public class EsSettingsTest {
-
-  @Rule
-  public TemporaryFolder temp = new TemporaryFolder();
-
-  @Test
-  public void fail_if_tcp_port_is_not_set() throws Exception {
-    try {
-      new EsSettings(new Props(new Properties()));
-      fail();
-    } catch (MessageException e) {
-      assertThat(e).hasMessage("Property is not set: sonar.search.port");
-    }
-  }
-
-  @Test
-  public void test_default_settings() throws Exception {
-    File homeDir = temp.newFolder();
-    Props props = new Props(new Properties());
-    props.set(EsSettings.PROP_TCP_PORT, "1234");
-    props.set(EsSettings.SONAR_PATH_HOME, homeDir.getAbsolutePath());
-    props.set(EsSettings.PROP_CLUSTER_NAME, "test");
-
-    EsSettings esSettings = new EsSettings(props);
-    assertThat(esSettings.inCluster()).isFalse();
-    assertThat(esSettings.clusterName()).isEqualTo("test");
-    assertThat(esSettings.tcpPort()).isEqualTo(1234);
-
-    Settings generated = esSettings.build();
-    assertThat(generated.get("transport.tcp.port")).isEqualTo("1234");
-    assertThat(generated.get("cluster.name")).isEqualTo("test");
-    assertThat(generated.get("path.data")).isNotNull();
-    assertThat(generated.get("path.logs")).isNotNull();
-    assertThat(generated.get("path.work")).isNotNull();
-
-    // http is disabled for security reasons
-    assertThat(generated.get("http.enabled")).isEqualTo("false");
-
-    // no cluster, but node name is set though
-    assertThat(generated.get("index.number_of_replicas")).isEqualTo("0");
-    assertThat(generated.get("discovery.zen.ping.unicast.hosts")).isNull();
-    assertThat(generated.get("node.name")).isNotEmpty();
-  }
-
-  @Test
-  public void override_dirs() throws Exception {
-    File homeDir = temp.newFolder(), dataDir = temp.newFolder(), logDir = temp.newFolder(), tempDir = temp.newFolder();
-    Props props = new Props(new Properties());
-    props.set(EsSettings.PROP_TCP_PORT, "1234");
-    props.set(EsSettings.SONAR_PATH_HOME, homeDir.getAbsolutePath());
-    props.set(EsSettings.SONAR_PATH_DATA, dataDir.getAbsolutePath());
-    props.set(EsSettings.SONAR_PATH_LOG, logDir.getAbsolutePath());
-    props.set(EsSettings.SONAR_PATH_TEMP, tempDir.getAbsolutePath());
-    props.set(EsSettings.PROP_CLUSTER_NAME, "test");
-
-    Settings settings = new EsSettings(props).build();
-
-    assertThat(settings.get("path.data")).isEqualTo(new File(dataDir, "es").getAbsolutePath());
-    assertThat(settings.get("path.logs")).isEqualTo(logDir.getAbsolutePath());
-    assertThat(settings.get("path.work")).isEqualTo(tempDir.getAbsolutePath());
-  }
-
-  @Test
-  public void test_cluster_master() throws Exception {
-    Props props = minProps();
-    props.set(EsSettings.PROP_CLUSTER_ACTIVATION, "true");
-    Settings settings = new EsSettings(props).build();
-
-    assertThat(settings.get("index.number_of_replicas")).isEqualTo("1");
-    assertThat(settings.get("discovery.zen.ping.unicast.hosts")).isNull();
-    // TODO set node.master=true ?
-  }
-
-  @Test
-  public void test_cluster_slave() throws Exception {
-    Props props = minProps();
-    props.set(EsSettings.PROP_CLUSTER_MASTER, "127.0.0.2,127.0.0.3");
-    Settings settings = new EsSettings(props).build();
-
-    assertThat(settings.get("discovery.zen.ping.unicast.hosts")).isEqualTo("127.0.0.2,127.0.0.3");
-    assertThat(settings.get("node.master")).isEqualTo("false");
-  }
-
-  @Test
-  public void enable_marvel() throws Exception {
-    Props props = minProps();
-    props.set(EsSettings.PROP_MARVEL, "127.0.0.2,127.0.0.3");
-    Settings settings = new EsSettings(props).build();
-
-    assertThat(settings.get("marvel.agent.exporter.es.hosts")).isEqualTo("127.0.0.2,127.0.0.3");
-  }
-
-  @Test
-  public void enable_http_connector() throws Exception {
-    Props props = minProps();
-    props.set(EsSettings.PROP_HTTP_PORT, "9010");
-    Settings settings = new EsSettings(props).build();
-
-    assertThat(settings.get("http.port")).isEqualTo("9010");
-    assertThat(settings.get("http.host")).isEqualTo("127.0.0.1");
-    assertThat(settings.get("http.enabled")).isEqualTo("true");
-  }
-
-  private Props minProps() throws IOException {
-    File homeDir = temp.newFolder();
-    Props props = new Props(new Properties());
-    props.set(EsSettings.PROP_TCP_PORT, "1234");
-    props.set(EsSettings.SONAR_PATH_HOME, homeDir.getAbsolutePath());
-    props.set(EsSettings.PROP_CLUSTER_NAME, "test");
-    return props;
-  }
-}
index 7f49f41ed050dab881bcf4d58bfdb5874aec5460..d91f11a853ed2ca6f29266f36236d660d537cdf9 100644 (file)
@@ -32,6 +32,7 @@ import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 import org.junit.rules.Timeout;
 import org.sonar.process.NetworkUtils;
+import org.sonar.process.ProcessConstants;
 import org.sonar.process.Props;
 
 import java.util.Properties;
@@ -67,9 +68,9 @@ public class SearchServerTest {
   @Test
   public void start_stop_server() throws Exception {
     Props props = new Props(new Properties());
-    props.set(EsSettings.PROP_TCP_PORT, String.valueOf(port));
-    props.set(EsSettings.PROP_CLUSTER_NAME, CLUSTER_NAME);
-    props.set(EsSettings.SONAR_PATH_HOME, temp.newFolder().getAbsolutePath());
+    props.set(ProcessConstants.SEARCH_PORT, String.valueOf(port));
+    props.set(ProcessConstants.CLUSTER_NAME, CLUSTER_NAME);
+    props.set(ProcessConstants.PATH_HOME, temp.newFolder().getAbsolutePath());
 
     searchServer = new SearchServer(props);
     searchServer.start();
@@ -91,11 +92,11 @@ public class SearchServerTest {
   public void slave_success_replication() throws Exception {
 
     Props props = new Props(new Properties());
-    props.set(EsSettings.PROP_CLUSTER_ACTIVATION, "true");
-    props.set(EsSettings.PROP_TCP_PORT, String.valueOf(port));
-    props.set(EsSettings.PROP_NODE_NAME, "MASTER");
-    props.set(EsSettings.PROP_CLUSTER_NAME, CLUSTER_NAME);
-    props.set(EsSettings.SONAR_PATH_HOME, temp.newFolder().getAbsolutePath());
+    props.set(ProcessConstants.CLUSTER_ACTIVATION, "true");
+    props.set(ProcessConstants.SEARCH_PORT, String.valueOf(port));
+    props.set(ProcessConstants.CLUSTER_NODE_NAME, "MASTER");
+    props.set(ProcessConstants.CLUSTER_NAME, CLUSTER_NAME);
+    props.set(ProcessConstants.PATH_HOME, temp.newFolder().getAbsolutePath());
     searchServer = new SearchServer(props);
     assertThat(searchServer).isNotNull();
 
@@ -107,11 +108,11 @@ public class SearchServerTest {
 
     // start a slave
     props = new Props(new Properties());
-    props.set(EsSettings.PROP_CLUSTER_MASTER, "localhost:" + port);
-    props.set(EsSettings.PROP_NODE_NAME, "SLAVE");
-    props.set(EsSettings.PROP_TCP_PORT, String.valueOf(NetworkUtils.freePort()));
-    props.set(EsSettings.PROP_CLUSTER_NAME, CLUSTER_NAME);
-    props.set(EsSettings.SONAR_PATH_HOME, temp.newFolder().getAbsolutePath());
+    props.set(ProcessConstants.CLUSTER_MASTER_HOSTS, "localhost:" + port);
+    props.set(ProcessConstants.CLUSTER_NODE_NAME, "SLAVE");
+    props.set(ProcessConstants.SEARCH_PORT, String.valueOf(NetworkUtils.freePort()));
+    props.set(ProcessConstants.CLUSTER_NAME, CLUSTER_NAME);
+    props.set(ProcessConstants.PATH_HOME, temp.newFolder().getAbsolutePath());
     SearchServer slaveServer = new SearchServer(props);
     assertThat(slaveServer).isNotNull();
 
@@ -130,11 +131,11 @@ public class SearchServerTest {
   @Test
   public void slave_failed_replication() throws Exception {
     Props props = new Props(new Properties());
-    props.set(EsSettings.PROP_CLUSTER_ACTIVATION, "false");
-    props.set(EsSettings.PROP_TCP_PORT, String.valueOf(port));
-    props.set(EsSettings.PROP_NODE_NAME, "MASTER");
-    props.set(EsSettings.PROP_CLUSTER_NAME, CLUSTER_NAME);
-    props.set(EsSettings.SONAR_PATH_HOME, temp.newFolder().getAbsolutePath());
+    props.set(ProcessConstants.CLUSTER_ACTIVATION, "false");
+    props.set(ProcessConstants.SEARCH_PORT, String.valueOf(port));
+    props.set(ProcessConstants.CLUSTER_NODE_NAME, "MASTER");
+    props.set(ProcessConstants.CLUSTER_NAME, CLUSTER_NAME);
+    props.set(ProcessConstants.PATH_HOME, temp.newFolder().getAbsolutePath());
     searchServer = new SearchServer(props);
     assertThat(searchServer).isNotNull();
 
@@ -146,11 +147,11 @@ public class SearchServerTest {
 
     // start a slave
     props = new Props(new Properties());
-    props.set(EsSettings.PROP_CLUSTER_MASTER, "localhost:" + port);
-    props.set(EsSettings.PROP_NODE_NAME, "SLAVE");
-    props.set(EsSettings.PROP_TCP_PORT, String.valueOf(NetworkUtils.freePort()));
-    props.set(EsSettings.PROP_CLUSTER_NAME, CLUSTER_NAME);
-    props.set(EsSettings.SONAR_PATH_HOME, temp.newFolder().getAbsolutePath());
+    props.set(ProcessConstants.CLUSTER_MASTER_HOSTS, "localhost:" + port);
+    props.set(ProcessConstants.CLUSTER_NODE_NAME, "SLAVE");
+    props.set(ProcessConstants.SEARCH_PORT, String.valueOf(NetworkUtils.freePort()));
+    props.set(ProcessConstants.CLUSTER_NAME, CLUSTER_NAME);
+    props.set(ProcessConstants.PATH_HOME, temp.newFolder().getAbsolutePath());
     SearchServer slaveServer = new SearchServer(props);
     assertThat(slaveServer).isNotNull();
 
diff --git a/server/sonar-search/src/test/java/org/sonar/search/SearchSettingsTest.java b/server/sonar-search/src/test/java/org/sonar/search/SearchSettingsTest.java
new file mode 100644 (file)
index 0000000..cece4e0
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.search;
+
+import org.elasticsearch.common.settings.Settings;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import org.sonar.process.MessageException;
+import org.sonar.process.ProcessConstants;
+import org.sonar.process.Props;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.fest.assertions.Fail.fail;
+
+public class SearchSettingsTest {
+
+  @Rule
+  public TemporaryFolder temp = new TemporaryFolder();
+
+  @Test
+  public void fail_if_tcp_port_is_not_set() throws Exception {
+    try {
+      new SearchSettings(new Props(new Properties()));
+      fail();
+    } catch (MessageException e) {
+      assertThat(e).hasMessage("Property is not set: sonar.search.port");
+    }
+  }
+
+  @Test
+  public void test_default_settings() throws Exception {
+    File homeDir = temp.newFolder();
+    Props props = new Props(new Properties());
+    props.set(ProcessConstants.SEARCH_PORT, "1234");
+    props.set(ProcessConstants.PATH_HOME, homeDir.getAbsolutePath());
+    props.set(ProcessConstants.CLUSTER_NAME, "test");
+
+    SearchSettings searchSettings = new SearchSettings(props);
+    assertThat(searchSettings.inCluster()).isFalse();
+    assertThat(searchSettings.clusterName()).isEqualTo("test");
+    assertThat(searchSettings.tcpPort()).isEqualTo(1234);
+
+    Settings generated = searchSettings.build();
+    assertThat(generated.get("transport.tcp.port")).isEqualTo("1234");
+    assertThat(generated.get("cluster.name")).isEqualTo("test");
+    assertThat(generated.get("path.data")).isNotNull();
+    assertThat(generated.get("path.logs")).isNotNull();
+    assertThat(generated.get("path.work")).isNotNull();
+
+    // http is disabled for security reasons
+    assertThat(generated.get("http.enabled")).isEqualTo("false");
+
+    // no cluster, but node name is set though
+    assertThat(generated.get("index.number_of_replicas")).isEqualTo("0");
+    assertThat(generated.get("discovery.zen.ping.unicast.hosts")).isNull();
+    assertThat(generated.get("node.name")).isNotEmpty();
+  }
+
+  @Test
+  public void override_dirs() throws Exception {
+    File homeDir = temp.newFolder(), dataDir = temp.newFolder(), logDir = temp.newFolder(), tempDir = temp.newFolder();
+    Props props = new Props(new Properties());
+    props.set(ProcessConstants.SEARCH_PORT, "1234");
+    props.set(ProcessConstants.PATH_HOME, homeDir.getAbsolutePath());
+    props.set(ProcessConstants.PATH_DATA, dataDir.getAbsolutePath());
+    props.set(ProcessConstants.PATH_LOGS, logDir.getAbsolutePath());
+    props.set(ProcessConstants.PATH_TEMP, tempDir.getAbsolutePath());
+    props.set(ProcessConstants.CLUSTER_NAME, "test");
+
+    Settings settings = new SearchSettings(props).build();
+
+    assertThat(settings.get("path.data")).isEqualTo(new File(dataDir, "es").getAbsolutePath());
+    assertThat(settings.get("path.logs")).isEqualTo(logDir.getAbsolutePath());
+    assertThat(settings.get("path.work")).isEqualTo(tempDir.getAbsolutePath());
+  }
+
+  @Test
+  public void test_cluster_master() throws Exception {
+    Props props = minProps();
+    props.set(ProcessConstants.CLUSTER_ACTIVATION, "true");
+    Settings settings = new SearchSettings(props).build();
+
+    assertThat(settings.get("index.number_of_replicas")).isEqualTo("1");
+    assertThat(settings.get("discovery.zen.ping.unicast.hosts")).isNull();
+    // TODO set node.master=true ?
+  }
+
+  @Test
+  public void test_cluster_slave() throws Exception {
+    Props props = minProps();
+    props.set(ProcessConstants.CLUSTER_MASTER_HOSTS, "127.0.0.2,127.0.0.3");
+    Settings settings = new SearchSettings(props).build();
+
+    assertThat(settings.get("discovery.zen.ping.unicast.hosts")).isEqualTo("127.0.0.2,127.0.0.3");
+    assertThat(settings.get("node.master")).isEqualTo("false");
+  }
+
+  @Test
+  public void enable_marvel() throws Exception {
+    Props props = minProps();
+    props.set(SearchSettings.PROP_MARVEL_HOSTS, "127.0.0.2,127.0.0.3");
+    Settings settings = new SearchSettings(props).build();
+
+    assertThat(settings.get("marvel.agent.exporter.es.hosts")).isEqualTo("127.0.0.2,127.0.0.3");
+  }
+
+  @Test
+  public void enable_http_connector() throws Exception {
+    Props props = minProps();
+    props.set(SearchSettings.PROP_HTTP_PORT, "9010");
+    Settings settings = new SearchSettings(props).build();
+
+    assertThat(settings.get("http.port")).isEqualTo("9010");
+    assertThat(settings.get("http.host")).isEqualTo("127.0.0.1");
+    assertThat(settings.get("http.enabled")).isEqualTo("true");
+  }
+
+  private Props minProps() throws IOException {
+    File homeDir = temp.newFolder();
+    Props props = new Props(new Properties());
+    props.set(ProcessConstants.SEARCH_PORT, "1234");
+    props.set(ProcessConstants.PATH_HOME, homeDir.getAbsolutePath());
+    props.set(ProcessConstants.CLUSTER_NAME, "test");
+    return props;
+  }
+}
index 01a5305c53dd46d2fd96912047e768de8af64ea0..049b2d208fa385d13fe7e7f9ec39b24fd992e5fc 100644 (file)
@@ -25,6 +25,7 @@ import org.apache.catalina.core.StandardContext;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.commons.io.FileUtils;
 import org.slf4j.LoggerFactory;
+import org.sonar.process.ProcessConstants;
 import org.sonar.process.Props;
 
 import java.io.File;
@@ -81,7 +82,7 @@ class EmbeddedTomcat {
   }
 
   private File tomcatBasedir() {
-    return new File(props.value("sonar.path.temp"), "tc");
+    return new File(props.value(ProcessConstants.PATH_TEMP), "tc");
   }
 
   void terminate() {
index e5d8c52b225aa1f6c44ee235b47a5a8e7abf416a..d83e49501bb16959c063b639b94f0fa512ff3e77 100644 (file)
@@ -29,6 +29,7 @@ import org.slf4j.LoggerFactory;
 import org.slf4j.bridge.SLF4JBridgeHandler;
 import org.sonar.core.config.Logback;
 import org.sonar.core.profiling.Profiling;
+import org.sonar.process.ProcessConstants;
 import org.sonar.process.Props;
 
 import java.io.File;
@@ -67,7 +68,7 @@ class Logging {
     String configProfilingLevel = props.value(Profiling.CONFIG_PROFILING_LEVEL, "NONE");
     Profiling.Level profilingLevel = Profiling.Level.fromConfigString(configProfilingLevel);
     Map<String, String> variables = ImmutableMap.of(
-      "sonar.path.logs", props.nonNullValue("sonar.path.logs"),
+      ProcessConstants.PATH_LOGS, props.nonNullValue(ProcessConstants.PATH_LOGS),
       "LOGGING_FORMAT", profilingLevel == Profiling.Level.FULL ? LOGFILE_FULL_LOGGING_FORMAT : LOGFILE_STANDARD_LOGGING_FORMAT);
     Logback.configure("/org/sonar/server/platform/logback.xml", variables);
   }
@@ -82,7 +83,7 @@ class Logging {
     if (props.valueAsBoolean(PROPERTY_ENABLE_ACCESS_LOGS, true)) {
       LogbackValve valve = new LogbackValve();
       valve.setQuiet(true);
-      valve.setFilename(new File(props.nonNullValue("sonar.path.web"), ACCESS_RELATIVE_PATH).getAbsolutePath());
+      valve.setFilename(new File(props.nonNullValue(ProcessConstants.PATH_WEB), ACCESS_RELATIVE_PATH).getAbsolutePath());
       tomcat.getHost().getPipeline().addValve(valve);
     }
   }
index 8445efb22be9514e151ed17668650bf4ae879761..f858128b4b0dca70ab359df74ae64b5bb126e7a2 100644 (file)
@@ -24,6 +24,7 @@ import org.apache.catalina.core.StandardContext;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.LoggerFactory;
+import org.sonar.process.ProcessConstants;
 import org.sonar.process.Props;
 
 import java.io.File;
@@ -99,7 +100,7 @@ class Webapp {
   static String webappPath(Props props) {
     String webDir = props.value("sonar.web.dev.sources");
     if (StringUtils.isEmpty(webDir)) {
-      webDir = new File(props.value("sonar.path.home"), "web").getAbsolutePath();
+      webDir = new File(props.value(ProcessConstants.PATH_HOME), "web").getAbsolutePath();
     }
     LoggerFactory.getLogger(Webapp.class).info(String.format("Webapp directory: %s", webDir));
     return webDir;
index 9e52ba4024b4e215721c5a2c25a7ad486fdfad84..51d8b6dd593d95080b04ce0635bbe745b70193f3 100644 (file)
@@ -29,6 +29,7 @@ import org.slf4j.LoggerFactory;
 import org.sonar.api.config.Settings;
 import org.sonar.api.database.DatabaseProperties;
 import org.sonar.api.utils.SonarException;
+import org.sonar.process.ProcessConstants;
 
 import java.io.File;
 import java.sql.DriverManager;
@@ -83,7 +84,7 @@ public class EmbeddedDatabase implements Startable {
 
   @VisibleForTesting
   File getDataDirectory(Settings settings) {
-    return new File(settings.getString("sonar.path.data"));
+    return new File(settings.getString(ProcessConstants.PATH_DATA));
   }
 
   private String getSetting(String name, String defaultValue) {
index fbfce9bc9f49183d00e47851bb43a30b2bcb2a23..a23eab31aa980dc4195df41901c4a3c8b4471b9b 100644 (file)
@@ -27,6 +27,7 @@ import org.slf4j.LoggerFactory;
 import org.sonar.api.config.Settings;
 import org.sonar.api.platform.Server;
 import org.sonar.api.platform.ServerFileSystem;
+import org.sonar.process.ProcessConstants;
 
 import java.io.File;
 import java.io.FileFilter;
@@ -49,7 +50,7 @@ public class DefaultServerFileSystem implements ServerFileSystem, Startable {
 
   public DefaultServerFileSystem(Settings settings, Server server) {
     this.server = server;
-    this.homeDir = new File(settings.getString("sonar.path.home"));
+    this.homeDir = new File(settings.getString(ProcessConstants.PATH_HOME));
   }
 
   /**
index f1f4a4000f2008d02d82ba92f0068d091c0d8ba7..8da34aad46a39fbc690612a1ca1f3dd42f44d7a9 100644 (file)
@@ -31,6 +31,7 @@ import org.slf4j.LoggerFactory;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.config.Settings;
 import org.sonar.api.platform.Server;
+import org.sonar.process.ProcessConstants;
 
 import java.io.File;
 import java.io.IOException;
@@ -77,7 +78,7 @@ public final class ServerImpl extends Server implements Startable {
         // Remove trailing slashes
         .replaceFirst("(\\/+)$", "");
 
-      sonarHome = new File(settings.getString("sonar.path.home"));
+      sonarHome = new File(settings.getString(ProcessConstants.PATH_HOME));
       if (!sonarHome.isDirectory()) {
         throw new IllegalStateException("SonarQube home directory is not valid");
       }
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/IndexProperties.java b/server/sonar-server/src/main/java/org/sonar/server/search/IndexProperties.java
deleted file mode 100644 (file)
index f11d801..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.search;
-
-public final class IndexProperties {
-
-  private IndexProperties() {
-    // only static stuff
-  }
-
-  public static final String CLUSTER_ACTIVATION = "sonar.cluster.activation";
-  public static final String NODE_PORT = "sonar.search.port";
-  public static final String CLUSTER_NAME = "sonar.cluster.name";
-  public static final String NODE_NAME = "sonar.node.name";
-
-}
index de1234cd280f181f379d9852ce0f39df98b35ea8..14519ad063f03349812d3f85dc63a90ce69303a1 100644 (file)
@@ -40,6 +40,7 @@ import org.sonar.api.config.Settings;
 import org.sonar.core.profiling.Profiling;
 import org.sonar.core.profiling.StopWatch;
 import org.sonar.process.LoopbackAddress;
+import org.sonar.process.ProcessConstants;
 
 /**
  * ElasticSearch Node used to connect to index.
@@ -52,14 +53,14 @@ public class SearchClient extends TransportClient implements Startable {
 
   public SearchClient(Settings settings) {
     super(ImmutableSettings.settingsBuilder()
-      .put("node.name", StringUtils.defaultIfEmpty(settings.getString(IndexProperties.NODE_NAME), "sq_local_client"))
+      .put("node.name", StringUtils.defaultIfEmpty(settings.getString(ProcessConstants.CLUSTER_NODE_NAME), "sq_local_client"))
       .put("network.bind_host", "localhost")
-      .put("node.rack_id", StringUtils.defaultIfEmpty(settings.getString(IndexProperties.NODE_NAME), "unknown"))
-      .put("cluster.name", StringUtils.defaultIfBlank(settings.getString(IndexProperties.CLUSTER_NAME), "sonarqube"))
+      .put("node.rack_id", StringUtils.defaultIfEmpty(settings.getString(ProcessConstants.CLUSTER_NODE_NAME), "unknown"))
+      .put("cluster.name", StringUtils.defaultIfBlank(settings.getString(ProcessConstants.CLUSTER_NAME), "sonarqube"))
       .build());
     initLogging();
     this.addTransportAddress(new InetSocketTransportAddress(LoopbackAddress.get().getHostAddress(),
-      settings.getInt(IndexProperties.NODE_PORT)));
+      settings.getInt(ProcessConstants.SEARCH_PORT)));
     this.profiling = new Profiling(settings);
   }
 
index 5fdc07b3fcaad0fb60fffce338dda6faecd75fb7..6baabe0e347fc5d84355d6e3a83c228f32afd7bc 100644 (file)
@@ -35,6 +35,7 @@ import org.sonar.core.persistence.Database;
 import org.sonar.core.preview.PreviewCache;
 import org.sonar.core.resource.ResourceIndexerDao;
 import org.sonar.core.timemachine.Periods;
+import org.sonar.process.ProcessConstants;
 import org.sonar.server.component.ComponentCleanerService;
 import org.sonar.server.db.migrations.DatabaseMigrator;
 import org.sonar.server.measure.MeasureFilterEngine;
@@ -355,7 +356,7 @@ public final class JRubyFacade {
   }
 
   public String getServerHome() {
-    return get(Settings.class).getString("sonar.path.home");
+    return get(Settings.class).getString(ProcessConstants.PATH_HOME);
   }
 
   public ComponentContainer getContainer() {
index 2bc4665be9c6cf28e4410d4047ba5e865f47d276..da9ee50d4af7c764436822de6ba3d870861aa8c3 100644 (file)
@@ -31,6 +31,7 @@ import org.junit.rules.TemporaryFolder;
 import org.mockito.ArgumentMatcher;
 import org.mockito.Mockito;
 import org.slf4j.Logger;
+import org.sonar.process.ProcessConstants;
 import org.sonar.process.Props;
 
 import java.io.File;
@@ -57,7 +58,7 @@ public class LoggingTest {
   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("sonar.path.web", temp.newFolder().getAbsolutePath());
+    props.set(ProcessConstants.PATH_WEB, temp.newFolder().getAbsolutePath());
     Logging.configure(tomcat, props);
 
     verify(tomcat.getHost().getPipeline()).addValve(argThat(new ArgumentMatcher<Valve>() {
index 555fea545c3bce36655b83d00dfc7b0505b9da29..548340194d5856483637e6382a88f6528690fa90 100644 (file)
@@ -26,6 +26,7 @@ import org.junit.rules.ExpectedException;
 import org.sonar.api.config.Settings;
 import org.sonar.api.database.DatabaseProperties;
 import org.sonar.process.NetworkUtils;
+import org.sonar.process.ProcessConstants;
 
 import java.io.File;
 import java.io.IOException;
@@ -92,6 +93,6 @@ public class EmbeddedDatabaseTest {
       .setProperty(DatabaseProperties.PROP_USER, "login")
       .setProperty(DatabaseProperties.PROP_PASSWORD, "pwd")
       .setProperty(DatabaseProperties.PROP_EMBEDDED_PORT, "" + port)
-      .setProperty("sonar.path.data", "./target/testDB");
+      .setProperty(ProcessConstants.PATH_DATA, "./target/testDB");
   }
 }
index c81d952bbb38323a10c73d4be2e15635d7a7e129..13552476953acbbd69c71d0b809c0cc0f17bf4fc 100644 (file)
@@ -27,6 +27,7 @@ import org.junit.rules.ExpectedException;
 import org.junit.rules.TemporaryFolder;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.config.Settings;
+import org.sonar.process.ProcessConstants;
 
 import java.io.File;
 
@@ -47,7 +48,7 @@ public class ServerImplTest {
 
   @Before
   public void setUp() throws Exception {
-    settings = new Settings().setProperty("sonar.path.home", sonarHome.getRoot().getAbsolutePath());
+    settings = new Settings().setProperty(ProcessConstants.PATH_HOME, sonarHome.getRoot().getAbsolutePath());
     new File(sonarHome.getRoot(), "web/deploy").mkdirs();
 
     server = new ServerImpl(settings, "/org/sonar/server/platform/ServerImplTest/build.properties", "/org/sonar/server/platform/ServerImplTest/version.txt");
index 21a98972be2e21a78dbb6e9219aa77cdf271500f..f9d971e20b1655ea65c1fe119c9003346f0df57f 100644 (file)
@@ -29,6 +29,7 @@ import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 import org.sonar.api.config.Settings;
 import org.sonar.process.NetworkUtils;
+import org.sonar.process.ProcessConstants;
 import org.sonar.process.Props;
 import org.sonar.search.SearchServer;
 
@@ -56,9 +57,9 @@ public class BaseIndexTest {
     clusterName = "cluster-mem-" + System.currentTimeMillis();
     clusterPort = NetworkUtils.freePort();
     Properties properties = new Properties();
-    properties.setProperty(IndexProperties.CLUSTER_NAME, clusterName);
-    properties.setProperty(IndexProperties.NODE_PORT, clusterPort.toString());
-    properties.setProperty("sonar.path.home", temp.getRoot().getAbsolutePath());
+    properties.setProperty(ProcessConstants.CLUSTER_NAME, clusterName);
+    properties.setProperty(ProcessConstants.SEARCH_PORT, clusterPort.toString());
+    properties.setProperty(ProcessConstants.PATH_HOME, temp.getRoot().getAbsolutePath());
     try {
       searchServer = new SearchServer(new Props(properties));
     } catch (Exception e) {
@@ -76,10 +77,10 @@ public class BaseIndexTest {
   public void setup() throws IOException {
     File dataDir = temp.newFolder();
     Settings settings = new Settings();
-    settings.setProperty(IndexProperties.CLUSTER_ACTIVATION, false);
-    settings.setProperty(IndexProperties.CLUSTER_NAME, clusterName);
-    settings.setProperty(IndexProperties.NODE_PORT, clusterPort.toString());
-    settings.setProperty("sonar.path.home", dataDir.getAbsolutePath());
+    settings.setProperty(ProcessConstants.CLUSTER_ACTIVATION, false);
+    settings.setProperty(ProcessConstants.CLUSTER_NAME, clusterName);
+    settings.setProperty(ProcessConstants.SEARCH_PORT, clusterPort.toString());
+    settings.setProperty(ProcessConstants.PATH_HOME, dataDir.getAbsolutePath());
     searchClient = new SearchClient(settings);
   }
 
index 8924b835fef22c68360066c6301216ff1e9d6c1e..067b80abfb3754dcff8630ddae9d60c316ff2da7 100644 (file)
@@ -27,11 +27,11 @@ import org.junit.rules.ExternalResource;
 import org.sonar.api.database.DatabaseProperties;
 import org.sonar.api.resources.Language;
 import org.sonar.process.NetworkUtils;
+import org.sonar.process.ProcessConstants;
 import org.sonar.process.Props;
 import org.sonar.search.SearchServer;
 import org.sonar.server.platform.BackendCleanup;
 import org.sonar.server.platform.Platform;
-import org.sonar.server.search.IndexProperties;
 import org.sonar.server.ws.WsTester;
 
 import javax.annotation.Nullable;
@@ -70,9 +70,9 @@ public class ServerTester extends ExternalResource {
     clusterName = "cluster-mem-" + System.currentTimeMillis();
     clusterPort = NetworkUtils.freePort();
     Properties properties = new Properties();
-    properties.setProperty(IndexProperties.CLUSTER_NAME, clusterName);
-    properties.setProperty(IndexProperties.NODE_PORT, clusterPort.toString());
-    properties.setProperty("sonar.path.home", homeDir.getAbsolutePath());
+    properties.setProperty(ProcessConstants.CLUSTER_NAME, clusterName);
+    properties.setProperty(ProcessConstants.SEARCH_PORT, clusterPort.toString());
+    properties.setProperty(ProcessConstants.PATH_HOME, homeDir.getAbsolutePath());
     searchServer = new SearchServer(new Props(properties));
   }
 
@@ -92,11 +92,9 @@ public class ServerTester extends ExternalResource {
 
     Properties properties = new Properties();
     properties.putAll(initialProps);
-
-    properties.setProperty(IndexProperties.CLUSTER_NAME, clusterName);
-    properties.setProperty(IndexProperties.NODE_PORT, clusterPort.toString());
-
-    properties.setProperty("sonar.path.home", homeDir.getAbsolutePath());
+    properties.setProperty(ProcessConstants.CLUSTER_NAME, clusterName);
+    properties.setProperty(ProcessConstants.SEARCH_PORT, clusterPort.toString());
+    properties.setProperty(ProcessConstants.PATH_HOME, homeDir.getAbsolutePath());
     properties.setProperty(DatabaseProperties.PROP_URL, "jdbc:h2:" + homeDir.getAbsolutePath() + "/h2");
     for (Map.Entry<Object, Object> entry : System.getProperties().entrySet()) {
       String key = entry.getKey().toString();
index 9c027abebdf7c76008be6826534f933c6ded2f98..f0a859435ef9692ba9d27c90017ed2e5813a86cc 100644 (file)
@@ -23,6 +23,7 @@ import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.lang.StringUtils;
 import org.sonar.process.MinimumViableSystem;
 import org.sonar.process.ProcessCommands;
+import org.sonar.process.ProcessConstants;
 import org.sonar.process.ProcessLogging;
 import org.sonar.process.Props;
 import org.sonar.process.StopWatcher;
@@ -52,9 +53,9 @@ public class App implements Stoppable {
   }
 
   public void start(Props props) {
-    if (props.valueAsBoolean("sonar.enableStopCommand", false)) {
+    if (props.valueAsBoolean(ProcessConstants.ENABLE_STOP_COMMAND, false)) {
       // stop application when file <temp>/app.stop is created
-      File tempDir = props.nonNullValueAsFile("sonar.path.temp");
+      File tempDir = props.nonNullValueAsFile(ProcessConstants.PATH_TEMP);
       ProcessCommands commands = new ProcessCommands(tempDir, "app");
       stopWatcher = new StopWatcher(commands, this);
       stopWatcher.start();
@@ -65,14 +66,14 @@ public class App implements Stoppable {
 
   List<JavaCommand> createCommands(Props props) {
     List<JavaCommand> commands = new ArrayList<JavaCommand>();
-    File homeDir = props.nonNullValueAsFile("sonar.path.home");
-    File tempDir = props.nonNullValueAsFile("sonar.path.temp");
+    File homeDir = props.nonNullValueAsFile(ProcessConstants.PATH_HOME);
+    File tempDir = props.nonNullValueAsFile(ProcessConstants.PATH_TEMP);
     JavaCommand elasticsearch = new JavaCommand("search");
     elasticsearch
       .setWorkDir(homeDir)
       .addJavaOptions("-Djava.awt.headless=true")
-      .addJavaOptions(props.nonNullValue(DefaultSettings.SEARCH_JAVA_OPTS))
-      .addJavaOptions(props.nonNullValue(DefaultSettings.SEARCH_JAVA_ADDITIONAL_OPTS))
+      .addJavaOptions(props.nonNullValue(ProcessConstants.SEARCH_JAVA_OPTS))
+      .addJavaOptions(props.nonNullValue(ProcessConstants.SEARCH_JAVA_ADDITIONAL_OPTS))
       .setTempDir(tempDir.getAbsoluteFile())
       .setClassName("org.sonar.search.SearchServer")
       .setArguments(props.rawProperties())
@@ -81,20 +82,20 @@ public class App implements Stoppable {
     commands.add(elasticsearch);
 
     // do not yet start SQ in cluster mode. See SONAR-5483 & SONAR-5391
-    if (StringUtils.isEmpty(props.value(DefaultSettings.CLUSTER_MASTER))) {
+    if (StringUtils.isEmpty(props.value(ProcessConstants.CLUSTER_MASTER_HOSTS))) {
       JavaCommand webServer = new JavaCommand("web")
         .setWorkDir(homeDir)
         .addJavaOptions("-Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djruby.management.enabled=false")
-        .addJavaOptions(props.nonNullValue(DefaultSettings.WEB_JAVA_OPTS))
-        .addJavaOptions(props.nonNullValue(DefaultSettings.WEB_JAVA_ADDITIONAL_OPTS))
+        .addJavaOptions(props.nonNullValue(ProcessConstants.WEB_JAVA_OPTS))
+        .addJavaOptions(props.nonNullValue(ProcessConstants.WEB_JAVA_ADDITIONAL_OPTS))
         .setTempDir(tempDir.getAbsoluteFile())
         // required for logback tomcat valve
-        .setEnvVariable("sonar.path.logs", props.nonNullValue("sonar.path.logs"))
+        .setEnvVariable(ProcessConstants.PATH_LOGS, props.nonNullValue(ProcessConstants.PATH_LOGS))
         .setClassName("org.sonar.server.app.WebServer")
         .setArguments(props.rawProperties())
         .addClasspath("./lib/common/*")
         .addClasspath("./lib/server/*");
-      String driverPath = props.value(JdbcSettings.PROPERTY_DRIVER_PATH);
+      String driverPath = props.value(ProcessConstants.JDBC_DRIVER_PATH);
       if (driverPath != null) {
         webServer.addClasspath(driverPath);
       }
index 4a9367894998cebc31f7c469c53215b67a689c63..3a710e779c552e4fb6269bcba688c0bf19b8a9a8 100644 (file)
@@ -20,6 +20,7 @@
 package org.sonar.application;
 
 import org.sonar.process.NetworkUtils;
+import org.sonar.process.ProcessConstants;
 import org.sonar.process.Props;
 
 import java.util.HashMap;
@@ -31,21 +32,9 @@ class DefaultSettings {
     // only static stuff
   }
 
-  static final String CLUSTER_MASTER = "sonar.cluster.master";
-  static final String CLUSTER_NAME = "sonar.cluster.name";
-  static final String CLUSTER_NODE_NAME = "sonar.node.name";
-  static final String SEARCH_PORT = "sonar.search.port";
-  static final String SEARCH_JAVA_OPTS = "sonar.search.javaOpts";
-  static final String SEARCH_JAVA_ADDITIONAL_OPTS = "sonar.search.javaAdditionalOpts";
-  static final String WEB_JAVA_OPTS = "sonar.web.javaOpts";
-  static final String WEB_JAVA_ADDITIONAL_OPTS = "sonar.web.javaAdditionalOpts";
-  static final String JDBC_URL = "sonar.jdbc.url";
-  static final String JDBC_LOGIN = "sonar.jdbc.username";
-  static final String JDBC_PASSWORD = "sonar.jdbc.password";
-
   static void init(Props props) {
     // forced property
-    props.set("sonar.search.type", "TRANSPORT");
+    props.set(ProcessConstants.SEARCH_TYPE, "TRANSPORT");
 
     // init string properties
     for (Map.Entry<String, String> entry : defaults().entrySet()) {
@@ -68,24 +57,24 @@ class DefaultSettings {
 
   private static Map<String, String> defaults() {
     Map<String, String> defaults = new HashMap<String, String>();
-    defaults.put(CLUSTER_NAME, "sonarqube");
-    defaults.put(SEARCH_JAVA_OPTS, "-Xmx256m -Xms256m -Xss256k -Djava.net.preferIPv4Stack=true " +
+    defaults.put(ProcessConstants.CLUSTER_NAME, "sonarqube");
+    defaults.put(ProcessConstants.SEARCH_JAVA_OPTS, "-Xmx256m -Xms256m -Xss256k -Djava.net.preferIPv4Stack=true " +
       "-XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly " +
       "-XX:+HeapDumpOnOutOfMemoryError -Djava.awt.headless=true");
-    defaults.put(SEARCH_JAVA_ADDITIONAL_OPTS, "");
-    defaults.put(CLUSTER_NODE_NAME, "sonar-" + System.currentTimeMillis());
-    defaults.put(WEB_JAVA_OPTS, "-Xmx768m -XX:MaxPermSize=160m -XX:+HeapDumpOnOutOfMemoryError -Djava.net.preferIPv4Stack=true " +
+    defaults.put(ProcessConstants.SEARCH_JAVA_ADDITIONAL_OPTS, "");
+    defaults.put(ProcessConstants.CLUSTER_NODE_NAME, "sonar-" + System.currentTimeMillis());
+    defaults.put(ProcessConstants.WEB_JAVA_OPTS, "-Xmx768m -XX:MaxPermSize=160m -XX:+HeapDumpOnOutOfMemoryError -Djava.net.preferIPv4Stack=true " +
       "-Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djruby.management.enabled=false");
-    defaults.put(WEB_JAVA_ADDITIONAL_OPTS, "");
-    defaults.put(JDBC_URL, "jdbc:h2:tcp://localhost:9092/sonar");
-    defaults.put(JDBC_LOGIN, "sonar");
-    defaults.put(JDBC_PASSWORD, "sonar");
+    defaults.put(ProcessConstants.WEB_JAVA_ADDITIONAL_OPTS, "");
+    defaults.put(ProcessConstants.JDBC_URL, "jdbc:h2:tcp://localhost:9092/sonar");
+    defaults.put(ProcessConstants.JDBC_LOGIN, "sonar");
+    defaults.put(ProcessConstants.JDBC_PASSWORD, "sonar");
     return defaults;
   }
 
   private static Map<String, Integer> defaultPorts() {
     Map<String, Integer> defaults = new HashMap<String, Integer>();
-    defaults.put(SEARCH_PORT, 9001);
+    defaults.put(ProcessConstants.SEARCH_PORT, 9001);
     return defaults;
   }
 }
index 20e32cacd02b25ff12ebaec62f3f763ef20161c3..294eed9a108b668f067e730c758dc2f2e9c16880 100644 (file)
@@ -22,6 +22,7 @@ package org.sonar.application;
 import org.apache.commons.io.FileUtils;
 import org.slf4j.LoggerFactory;
 import org.sonar.process.MessageException;
+import org.sonar.process.ProcessConstants;
 import org.sonar.process.Props;
 
 import javax.annotation.CheckForNull;
@@ -36,8 +37,6 @@ import java.util.regex.Pattern;
 
 public class JdbcSettings {
 
-  static final String PROPERTY_DRIVER_PATH = "sonar.jdbc.driverPath";
-
   static enum Provider {
     h2(null), jtds("lib/jdbc/jtds"), mysql("lib/jdbc/mysql"), oracle("extensions/jdbc-driver/oracle"),
     postgresql("lib/jdbc/postgresql");
@@ -50,12 +49,12 @@ public class JdbcSettings {
   }
 
   public void checkAndComplete(File homeDir, Props props) {
-    String url = props.nonNullValue(DefaultSettings.JDBC_URL);
+    String url = props.nonNullValue(ProcessConstants.JDBC_URL);
     Provider provider = driverProvider(url);
     checkUrlParameters(provider, url);
     String driverPath = driverPath(homeDir, provider);
     if (driverPath != null) {
-      props.set(PROPERTY_DRIVER_PATH, driverPath);
+      props.set(ProcessConstants.JDBC_DRIVER_PATH, driverPath);
     }
   }
 
index f736658db7b28d85d006f9fbb4f62e853cf96fba..1873448fb96d6c24d274caaf028c49bf3f79ea33 100644 (file)
@@ -22,6 +22,7 @@ package org.sonar.application;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.sonar.process.ConfigurationUtils;
+import org.sonar.process.ProcessConstants;
 import org.sonar.process.Props;
 
 import java.io.File;
@@ -53,7 +54,7 @@ class PropsBuilder {
   Props build() throws IOException {
     Properties p = loadPropertiesFile(homeDir);
     p.putAll(rawProperties);
-    p.setProperty("sonar.path.home", homeDir.getAbsolutePath());
+    p.setProperty(ProcessConstants.PATH_HOME, homeDir.getAbsolutePath());
     p = ConfigurationUtils.interpolateVariables(p, System.getenv());
 
     // the difference between Properties and Props is that the latter
@@ -63,9 +64,9 @@ class PropsBuilder {
     DefaultSettings.init(props);
 
     // init file system
-    initExistingDir(props, "sonar.path.data", "data");
-    initExistingDir(props, "sonar.path.web", "web");
-    initExistingDir(props, "sonar.path.logs", "logs");
+    initExistingDir(props, ProcessConstants.PATH_DATA, "data");
+    initExistingDir(props, ProcessConstants.PATH_WEB, "web");
+    initExistingDir(props, ProcessConstants.PATH_LOGS, "logs");
     initTempDir(props);
 
     // check JDBC properties and set path to driver
@@ -94,7 +95,7 @@ class PropsBuilder {
   }
 
   private void initTempDir(Props props) throws IOException {
-    File dir = configureDir(props, "sonar.path.temp", "temp");
+    File dir = configureDir(props, ProcessConstants.PATH_TEMP, "temp");
     FileUtils.deleteQuietly(dir);
     FileUtils.forceMkdir(dir);
   }
index 32d1f2969c40783496814d934c3a6db6f356b229..c419e846ac1a0738b8ce6f0637b6cf70bc6fa404 100644 (file)
@@ -24,6 +24,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 import org.mockito.ArgumentCaptor;
+import org.sonar.process.ProcessConstants;
 import org.sonar.process.Props;
 import org.sonar.process.monitor.JavaCommand;
 import org.sonar.process.monitor.Monitor;
@@ -122,9 +123,9 @@ public class AppTest {
   private Props initDefaultProps() throws IOException {
     Props props = new Props(new Properties());
     DefaultSettings.init(props);
-    props.set("sonar.path.home", temp.newFolder().getAbsolutePath());
-    props.set("sonar.path.temp", temp.newFolder().getAbsolutePath());
-    props.set("sonar.path.logs", temp.newFolder().getAbsolutePath());
+    props.set(ProcessConstants.PATH_HOME, temp.newFolder().getAbsolutePath());
+    props.set(ProcessConstants.PATH_TEMP, temp.newFolder().getAbsolutePath());
+    props.set(ProcessConstants.PATH_LOGS, temp.newFolder().getAbsolutePath());
     return props;
   }
 }
index ad603c4e45357e1382281296ae0870870d0ab84b..edca761aa987dce39e3218aa0d3517964cc07a91 100644 (file)
@@ -24,6 +24,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 import org.sonar.process.MessageException;
+import org.sonar.process.ProcessConstants;
 import org.sonar.process.Props;
 
 import java.io.File;
@@ -89,7 +90,7 @@ public class JdbcSettingsTest {
     Props props = new Props(new Properties());
     props.set("sonar.jdbc.url", "jdbc:oracle:thin:@localhost/XE");
     settings.checkAndComplete(home, props);
-    assertThat(props.nonNullValueAsFile(JdbcSettings.PROPERTY_DRIVER_PATH)).isEqualTo(driverFile);
+    assertThat(props.nonNullValueAsFile(ProcessConstants.JDBC_DRIVER_PATH)).isEqualTo(driverFile);
   }
 
   @Test
@@ -98,7 +99,7 @@ public class JdbcSettingsTest {
     Props props = new Props(new Properties());
     props.set("sonar.jdbc.url", "jdbc:h2:tcp://localhost:9092/sonar");
     settings.checkAndComplete(home, props);
-    assertThat(props.value(JdbcSettings.PROPERTY_DRIVER_PATH)).isNull();
+    assertThat(props.value(ProcessConstants.JDBC_DRIVER_PATH)).isNull();
   }
 
   @Test
@@ -110,7 +111,7 @@ public class JdbcSettingsTest {
     Props props = new Props(new Properties());
     props.set("sonar.jdbc.url", "jdbc:postgresql://localhost/sonar");
     settings.checkAndComplete(home, props);
-    assertThat(props.nonNullValueAsFile(JdbcSettings.PROPERTY_DRIVER_PATH)).isEqualTo(driverFile);
+    assertThat(props.nonNullValueAsFile(ProcessConstants.JDBC_DRIVER_PATH)).isEqualTo(driverFile);
   }
 
   @Test
@@ -122,7 +123,7 @@ public class JdbcSettingsTest {
     Props props = new Props(new Properties());
     props.set("sonar.jdbc.url", "jdbc:jtds:sqlserver://localhost/sonar;SelectMethod=Cursor");
     settings.checkAndComplete(home, props);
-    assertThat(props.nonNullValueAsFile(JdbcSettings.PROPERTY_DRIVER_PATH)).isEqualTo(driverFile);
+    assertThat(props.nonNullValueAsFile(ProcessConstants.JDBC_DRIVER_PATH)).isEqualTo(driverFile);
   }
 
   @Test