]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9722 Add telemetry data to WS api/system/info
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Fri, 25 Aug 2017 16:33:04 +0000 (18:33 +0200)
committerTeryk Bellahsene <teryk@users.noreply.github.com>
Wed, 30 Aug 2017 14:24:53 +0000 (16:24 +0200)
server/sonar-server/src/main/java/org/sonar/server/platform/ws/InfoAction.java
server/sonar-server/src/main/java/org/sonar/server/telemetry/TelemetryDaemon.java
server/sonar-server/src/main/java/org/sonar/server/telemetry/TelemetryData.java
server/sonar-server/src/main/java/org/sonar/server/telemetry/TelemetryDataJsonWriter.java [new file with mode: 0644]
server/sonar-server/src/main/resources/org/sonar/server/platform/ws/example-system-info.json [deleted file]
server/sonar-server/src/main/resources/org/sonar/server/platform/ws/info-example.json [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/platform/ws/InfoActionTest.java
server/sonar-server/src/test/java/org/sonar/server/platform/ws/SystemWsTest.java
server/sonar-server/src/test/java/org/sonar/server/telemetry/TelemetryDaemonTest.java

index 4b49b83825ced9a8bacf6c6d6e722fb680f8fb52..3f543c4e8f34a3db5f6152b94d769bbfa5183c1c 100644 (file)
@@ -28,8 +28,11 @@ import org.sonar.api.utils.text.JsonWriter;
 import org.sonar.ce.http.CeHttpClient;
 import org.sonar.process.systeminfo.protobuf.ProtobufSystemInfo;
 import org.sonar.server.platform.monitoring.Monitor;
+import org.sonar.server.telemetry.TelemetryDataLoader;
 import org.sonar.server.user.UserSession;
 
+import static org.sonar.server.telemetry.TelemetryDataJsonWriter.writeTelemetryData;
+
 /**
  * Implementation of the {@code info} action for the System WebService.
  */
@@ -38,10 +41,12 @@ public class InfoAction implements SystemWsAction {
   private final UserSession userSession;
   private final CeHttpClient ceHttpClient;
   private final Monitor[] monitors;
+  private final TelemetryDataLoader statistics;
 
-  public InfoAction(UserSession userSession, CeHttpClient ceHttpClient, Monitor... monitors) {
+  public InfoAction(UserSession userSession, CeHttpClient ceHttpClient, TelemetryDataLoader statistics, Monitor... monitors) {
     this.userSession = userSession;
     this.ceHttpClient = ceHttpClient;
+    this.statistics = statistics;
     this.monitors = monitors;
   }
 
@@ -53,7 +58,7 @@ public class InfoAction implements SystemWsAction {
         "Since 5.5, this web service becomes internal in order to more easily update result.")
       .setSince("5.1")
       .setInternal(true)
-      .setResponseExample(getClass().getResource("/org/sonar/server/platform/ws/example-system-info.json"))
+      .setResponseExample(getClass().getResource("/org/sonar/server/platform/ws/info-example.json"))
       .setHandler(this);
   }
 
@@ -88,9 +93,15 @@ public class InfoAction implements SystemWsAction {
         json.endObject();
       }
     }
+    writeStatistics(json);
     json.endObject();
   }
 
+  private void writeStatistics(JsonWriter json) {
+    json.name("Statistics");
+    writeTelemetryData(json, statistics.load());
+  }
+
   private static void writeAttribute(JsonWriter json, ProtobufSystemInfo.Attribute attribute) {
     switch (attribute.getValueCase()) {
       case BOOLEAN_VALUE:
index a32c66e04c63c63f4c5324087f9113d2aab88803..73b5890662a6d5f5a87243712aced55730626301 100644 (file)
@@ -36,13 +36,12 @@ import org.sonar.api.utils.log.Loggers;
 import org.sonar.api.utils.text.JsonWriter;
 import org.sonar.server.property.InternalProperties;
 
-import static org.sonar.api.measures.CoreMetrics.LINES_KEY;
-import static org.sonar.api.measures.CoreMetrics.NCLOC_KEY;
 import static org.sonar.api.utils.DateUtils.formatDate;
 import static org.sonar.api.utils.DateUtils.parseDate;
 import static org.sonar.core.config.TelemetryProperties.PROP_ENABLE;
 import static org.sonar.core.config.TelemetryProperties.PROP_FREQUENCY;
 import static org.sonar.core.config.TelemetryProperties.PROP_URL;
+import static org.sonar.server.telemetry.TelemetryDataJsonWriter.writeTelemetryData;
 
 @ServerSide
 public class TelemetryDaemon implements Startable {
@@ -133,24 +132,11 @@ public class TelemetryDaemon implements Startable {
 
   private void uploadStatistics() throws IOException {
     TelemetryData statistics = dataLoader.load();
-    StringWriter json = new StringWriter();
-    try (JsonWriter writer = JsonWriter.of(json)) {
-      writer.beginObject();
-      writer.prop("id", statistics.getServerId());
-      writer.prop("version", statistics.getVersion());
-      writer.name("plugins");
-      writer.valueObject(statistics.getPlugins());
-      writer.prop("userCount", statistics.getUserCount());
-      writer.prop("projectCount", statistics.getProjectCount());
-      writer.prop(LINES_KEY, statistics.getLines());
-      writer.prop(NCLOC_KEY, statistics.getNcloc());
-      writer.name("projectCountByLanguage");
-      writer.valueObject(statistics.getProjectCountByLanguage());
-      writer.name("nclocByLanguage");
-      writer.valueObject(statistics.getNclocByLanguage());
-      writer.endObject();
+    StringWriter jsonString = new StringWriter();
+    try (JsonWriter json = JsonWriter.of(jsonString)) {
+      writeTelemetryData(json, statistics);
     }
-    telemetryClient.upload(json.toString());
+    telemetryClient.upload(jsonString.toString());
   }
 
   private boolean shouldUploadStatistics(long now) {
index 1d9cb633bb8d6d34fb6837e0150daaff1e863683..58b1cda637627d079ca296390e93d93110804e6f 100644 (file)
@@ -84,7 +84,7 @@ public class TelemetryData {
     return nclocByLanguage;
   }
 
-  static Builder builder() {
+  public static Builder builder() {
     return new Builder();
   }
 
diff --git a/server/sonar-server/src/main/java/org/sonar/server/telemetry/TelemetryDataJsonWriter.java b/server/sonar-server/src/main/java/org/sonar/server/telemetry/TelemetryDataJsonWriter.java
new file mode 100644 (file)
index 0000000..dba9dc4
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.telemetry;
+
+import org.sonar.api.utils.text.JsonWriter;
+
+import static org.sonar.api.measures.CoreMetrics.LINES_KEY;
+import static org.sonar.api.measures.CoreMetrics.NCLOC_KEY;
+
+public class TelemetryDataJsonWriter {
+  private TelemetryDataJsonWriter() {
+    // static methods
+  }
+
+  public static void writeTelemetryData(JsonWriter json, TelemetryData statistics) {
+    json.beginObject();
+    json.prop("id", statistics.getServerId());
+    json.prop("version", statistics.getVersion());
+    json.name("plugins");
+    json.valueObject(statistics.getPlugins());
+    json.prop("userCount", statistics.getUserCount());
+    json.prop("projectCount", statistics.getProjectCount());
+    json.prop(LINES_KEY, statistics.getLines());
+    json.prop(NCLOC_KEY, statistics.getNcloc());
+    json.name("projectCountByLanguage");
+    json.valueObject(statistics.getProjectCountByLanguage());
+    json.name("nclocByLanguage");
+    json.valueObject(statistics.getNclocByLanguage());
+    json.endObject();
+  }
+}
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/platform/ws/example-system-info.json b/server/sonar-server/src/main/resources/org/sonar/server/platform/ws/example-system-info.json
deleted file mode 100644 (file)
index a7f679e..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-{
-  "System": {
-    "System Date": "2015-02-23T18:54:23+0100",
-    "Start Time": "2015-02-23T18:53:22+0100",
-    "JVM Vendor": "Oracle Corporation",
-    "JVM Name": "Java HotSpot(TM) 64-Bit Server VM",
-    "JVM Version": "24.71-b01",
-    "Processors": 8,
-    "System Classpath": "./lib/common/commons-codec-1.8.jar:./lib/common/commons-io-2.4.jar:./lib/common/commons-lang-2.6.jar:./lib/common/elasticsearch-1.4.2.jar:./lib/common/logback-classic-1.1.2.jar:./lib/common/logback-core-1.1.2.jar:./lib/common/lucene-analyzers-common-4.10.2.jar:./lib/common/lucene-core-4.10.2.jar:./lib/common/lucene-grouping-4.10.2.jar:./lib/common/lucene-highlighter-4.10.2.jar:./lib/common/lucene-join-4.10.2.jar:./lib/common/lucene-memory-4.10.2.jar:./lib/common/lucene-misc-4.10.2.jar:./lib/common/lucene-queries-4.10.2.jar:./lib/common/lucene-queryparser-4.10.2.jar:./lib/common/lucene-sandbox-4.10.2.jar:./lib/common/lucene-suggest-4.10.2.jar:./lib/common/slf4j-api-1.7.10.jar:./lib/common/sonar-process-5.1-tests.jar:./lib/common/sonar-process-5.1.jar:./lib/common/sonar-process-monitor-5.1.jar:./lib/server/antlr-2.7.6.jar:./lib/server/blueprints-core-2.2.0.jar:./lib/server/commons-beanutils-1.8.3.jar:./lib/server/commons-collections-3.2.2.jar:./lib/server/commons-csv-1.0.jar:./lib/server/commons-dbcp-1.4.jar:./lib/server/commons-dbutils-1.5.jar:./lib/server/commons-pool-1.5.4.jar:./lib/server/dom4j-1.6.1.jar:./lib/server/ejb3-persistence-1.0.2.GA.jar:./lib/server/geronimo-spec-jta-1.0-M1.jar:./lib/server/gson-2.3.1.jar:./lib/server/guava-10.0.1.jar:./lib/server/hibernate-annotations-3.4.0.GA.jar:./lib/server/hibernate-commons-annotations-3.1.0.GA.jar:./lib/server/hibernate-core-3.3.2.GA.jar:./lib/server/hibernate-entitymanager-3.4.0.GA.jar:./lib/server/javassist-3.4.GA.jar:./lib/server/jcl-over-slf4j-1.7.10.jar:./lib/server/jcommon-1.0.12.jar:./lib/server/jfreechart-1.0.9.jar:./lib/server/jruby-complete-1.7.9.jar:./lib/server/jruby-rack-1.1.13.2.jar:./lib/server/json-simple-1.1.1.jar:./lib/server/jul-to-slf4j-1.7.10.jar:./lib/server/log4j-over-slf4j-1.7.10.jar:./lib/server/logback-access-1.1.2.jar:./lib/server/lz4-1.3.0.jar:./lib/server/mybatis-3.2.7.jar:./lib/server/picocontainer-2.14.3.jar:./lib/server/plexus-classworlds-2.5.1.jar:./lib/server/protobuf-java-2.6.1.jar:./lib/server/sonar-batch-protocol-5.1.jar:./lib/server/sonar-channel-4.1.jar:./lib/server/sonar-check-api-5.1.jar:./lib/server/sonar-colorizer-5.1.jar:./lib/server/sonar-core-5.1.jar:./lib/server/sonar-deprecated-5.1.jar:./lib/server/sonar-duplications-5.1.jar:./lib/server/sonar-graph-5.1.jar:./lib/server/sonar-home-5.1.jar:./lib/server/sonar-java-api-5.1.jar:./lib/server/sonar-markdown-5.1.jar:./lib/server/sonar-plugin-api-5.1.jar:./lib/server/sonar-server-5.1.jar:./lib/server/sonar-squid-4.1.jar:./lib/server/sonar-update-center-common-1.11.jar:./lib/server/stax-api-1.0-2.jar:./lib/server/stax2-api-3.1.4.jar:./lib/server/staxmate-2.0.1.jar:./lib/server/tomcat-embed-core-8.0.18.jar:./lib/server/tomcat-embed-el-8.0.18.jar:./lib/server/tomcat-embed-jasper-8.0.18.jar:./lib/server/tomcat-embed-logging-juli-8.0.18.jar:./lib/server/woodstox-core-lgpl-4.4.0.jar:./lib/server/xml-apis-1.4.01.jar:/Users/foo/dev/core/sonarqube/sonar-application/target/sonarqube-5.1/lib/jdbc/h2/h2-1.3.176.jar",
-    "BootClassPath": "/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/sunrsasign.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/classes",
-    "Library Path": "/Users/foo/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.",
-    "Total Memory": "323 MB",
-    "Free Memory": "173 MB",
-    "Max Memory": "716 MB",
-    "Heap": "init = 134217728(131072K) used = 150395872(146870K) committed = 323485696(315904K) max = 716177408(699392K)",
-    "Non Heap": "init = 24576000(24000K) used = 91012976(88879K) committed = 114163712(111488K) max = 218103808(212992K)",
-    "System Load Average": "394.9% (last minute)",
-    "Loaded Classes": 15392,
-    "Total Loaded Classes": 15392,
-    "Unloaded Classes": 0,
-    "Threads": 52,
-    "Threads Peak": 52,
-    "Daemon Thread": 40
-  },
-  "SonarQube": {
-    "Version": "5.1",
-    "External User Authentication": "",
-    "Automatic User Creation": true,
-    "Allow Users to Sign Up": false,
-    "Force authentication": false,
-    "Home Dir": "/Users/foo/dev/core/sonarqube/sonar-application/target/sonarqube-5.1",
-    "Data Dir": "/Users/foo/dev/core/sonarqube/sonar-application/target/sonarqube-5.1/data",
-    "Logs Dir": "/Users/foo/dev/core/sonarqube/sonar-application/target/sonarqube-5.1/logs",
-    "Temp Dir": "/Users/foo/dev/core/sonarqube/sonar-application/target/sonarqube-5.1/temp"
-  },
-  "ElasticSearch": {
-    "State": "GREEN",
-    "Indices": {
-      "sourcelines": {
-        "Docs": 0,
-        "Shards": 1,
-        "Store Size": "115 bytes"
-      },
-      "users": {
-        "Docs": 1,
-        "Shards": 1,
-        "Store Size": "3 KB"
-      },
-      "logs": {
-        "Docs": 1104,
-        "Shards": 1,
-        "Store Size": "162 KB"
-      },
-      "views": {
-        "Docs": 0,
-        "Shards": 1,
-        "Store Size": "115 bytes"
-      },
-      "issues": {
-        "Docs": 0,
-        "Shards": 1,
-        "Store Size": "115 bytes"
-      },
-      "rules": {
-        "Docs": 1491,
-        "Shards": 1,
-        "Store Size": "2 MB"
-      }
-    },
-    "Number of Nodes": 1,
-    "Nodes": {
-      "6DYkdNuvT6abEdShyEK5ow": {
-        "Address": "inet[/10.150.0.193:9001]",
-        "Type": "Master",
-        "Disk Usage": "465 GB",
-        "Disk Available": "67 GB",
-        "Store Size": "2 MB",
-        "Open Files": 212,
-        "JVM Heap Usage": "8.0%",
-        "JVM Heap Used": "79 MB",
-        "JVM Heap Max": "989 MB",
-        "JVM Non Heap Used": "40 MB",
-        "JVM Threads": 104,
-        "Field Cache Memory": "0 bytes",
-        "Filter Cache Memory": "0 bytes",
-        "ID Cache Memory": "51 KB",
-        "Query Cache Memory": "0 bytes"
-      }
-    }
-  },
-  "Plugins": {
-    "scmgit": {
-      "Name": "Git",
-      "Version": "1.0-RC1"
-    },
-    "findbugs": {
-      "Name": "Findbugs",
-      "Version": "3.1"
-    },
-    "scmsvn": {
-      "Name": "SVN",
-      "Version": "1.0-RC1"
-    },
-    "java": {
-      "Name": "Java",
-      "Version": "2.9.1"
-    }
-  },
-  "JvmProperties": {
-    "awt.toolkit": "sun.lwawt.macosx.LWCToolkit",
-    "catalina.base": "/Users/foo/dev/core/sonarqube/sonar-application/target/sonarqube-5.1/temp/tc",
-    "catalina.home": "/Users/foo/dev/core/sonarqube/sonar-application/target/sonarqube-5.1/temp/tc",
-    "catalina.useNaming": "false",
-    "file.encoding": "UTF-8",
-    "file.encoding.pkg": "sun.io",
-    "file.separator": "/",
-    "ftp.nonProxyHosts": "local|*.local|169.254/16|*.169.254/16",
-    "gopherProxySet": "false",
-    "http.agent": "SonarQube 5.1",
-    "http.nonProxyHosts": "local|*.local|169.254/16|*.169.254/16",
-    "java.awt.graphicsenv": "sun.awt.CGraphicsEnvironment",
-    "java.awt.headless": "true",
-    "java.awt.printerjob": "sun.lwawt.macosx.CPrinterJob",
-    "java.class.path": "./lib/common/commons-codec-1.8.jar:./lib/common/commons-io-2.4.jar:./lib/common/commons-lang-2.6.jar:./lib/common/elasticsearch-1.4.2.jar:./lib/common/logback-classic-1.1.2.jar:./lib/common/logback-core-1.1.2.jar:./lib/common/lucene-analyzers-common-4.10.2.jar:./lib/common/lucene-core-4.10.2.jar:./lib/common/lucene-grouping-4.10.2.jar:./lib/common/lucene-highlighter-4.10.2.jar:./lib/common/lucene-join-4.10.2.jar:./lib/common/lucene-memory-4.10.2.jar:./lib/common/lucene-misc-4.10.2.jar:./lib/common/lucene-queries-4.10.2.jar:./lib/common/lucene-queryparser-4.10.2.jar:./lib/common/lucene-sandbox-4.10.2.jar:./lib/common/lucene-suggest-4.10.2.jar:./lib/common/slf4j-api-1.7.10.jar:./lib/common/sonar-process-5.1-tests.jar:./lib/common/sonar-process-5.1.jar:./lib/common/sonar-process-monitor-5.1.jar:./lib/server/antlr-2.7.6.jar:./lib/server/blueprints-core-2.2.0.jar:./lib/server/commons-beanutils-1.8.3.jar:./lib/server/commons-collections-3.2.2.jar:./lib/server/commons-csv-1.0.jar:./lib/server/commons-dbcp-1.4.jar:./lib/server/commons-dbutils-1.5.jar:./lib/server/commons-pool-1.5.4.jar:./lib/server/dom4j-1.6.1.jar:./lib/server/ejb3-persistence-1.0.2.GA.jar:./lib/server/geronimo-spec-jta-1.0-M1.jar:./lib/server/gson-2.3.1.jar:./lib/server/guava-10.0.1.jar:./lib/server/hibernate-annotations-3.4.0.GA.jar:./lib/server/hibernate-commons-annotations-3.1.0.GA.jar:./lib/server/hibernate-core-3.3.2.GA.jar:./lib/server/hibernate-entitymanager-3.4.0.GA.jar:./lib/server/javassist-3.4.GA.jar:./lib/server/jcl-over-slf4j-1.7.10.jar:./lib/server/jcommon-1.0.12.jar:./lib/server/jfreechart-1.0.9.jar:./lib/server/jruby-complete-1.7.9.jar:./lib/server/jruby-rack-1.1.13.2.jar:./lib/server/json-simple-1.1.1.jar:./lib/server/jul-to-slf4j-1.7.10.jar:./lib/server/log4j-over-slf4j-1.7.10.jar:./lib/server/logback-access-1.1.2.jar:./lib/server/lz4-1.3.0.jar:./lib/server/mybatis-3.2.7.jar:./lib/server/picocontainer-2.14.3.jar:./lib/server/plexus-classworlds-2.5.1.jar:./lib/server/protobuf-java-2.6.1.jar:./lib/server/sonar-batch-protocol-5.1.jar:./lib/server/sonar-channel-4.1.jar:./lib/server/sonar-check-api-5.1.jar:./lib/server/sonar-colorizer-5.1.jar:./lib/server/sonar-core-5.1.jar:./lib/server/sonar-deprecated-5.1.jar:./lib/server/sonar-duplications-5.1.jar:./lib/server/sonar-graph-5.1.jar:./lib/server/sonar-home-5.1.jar:./lib/server/sonar-java-api-5.1.jar:./lib/server/sonar-markdown-5.1.jar:./lib/server/sonar-plugin-api-5.1.jar:./lib/server/sonar-server-5.1.jar:./lib/server/sonar-squid-4.1.jar:./lib/server/sonar-update-center-common-1.11.jar:./lib/server/stax-api-1.0-2.jar:./lib/server/stax2-api-3.1.4.jar:./lib/server/staxmate-2.0.1.jar:./lib/server/tomcat-embed-core-8.0.18.jar:./lib/server/tomcat-embed-el-8.0.18.jar:./lib/server/tomcat-embed-jasper-8.0.18.jar:./lib/server/tomcat-embed-logging-juli-8.0.18.jar:./lib/server/woodstox-core-lgpl-4.4.0.jar:./lib/server/xml-apis-1.4.01.jar:/Users/foo/dev/core/sonarqube/sonar-application/target/sonarqube-5.1/lib/jdbc/h2/h2-1.3.176.jar",
-    "java.class.version": "51.0",
-    "java.endorsed.dirs": "/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/endorsed",
-    "java.ext.dirs": "/Users/foo/Library/Java/Extensions:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/ext:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java",
-    "java.home": "/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre",
-    "java.io.tmpdir": "/Users/foo/dev/core/sonarqube/sonar-application/target/sonarqube-5.1/temp",
-    "java.library.path": "/Users/foo/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.",
-    "java.net.preferIPv4Stack": "true",
-    "java.runtime.name": "Java(TM) SE Runtime Environment",
-    "java.runtime.version": "1.7.0_71-b14",
-    "java.specification.name": "Java Platform API Specification",
-    "java.specification.vendor": "Oracle Corporation",
-    "java.specification.version": "1.7",
-    "java.vendor": "Oracle Corporation",
-    "java.vendor.url": "http://java.oracle.com/",
-    "java.vendor.url.bug": "http://bugreport.sun.com/bugreport/",
-    "java.version": "1.7.0_71",
-    "java.vm.info": "mixed mode",
-    "java.vm.name": "Java HotSpot(TM) 64-Bit Server VM",
-    "java.vm.specification.name": "Java Virtual Machine Specification",
-    "java.vm.specification.vendor": "Oracle Corporation",
-    "java.vm.specification.version": "1.7",
-    "java.vm.vendor": "Oracle Corporation",
-    "java.vm.version": "24.71-b01",
-    "line.separator": "\n",
-    "org.apache.catalina.startup.EXIT_ON_INIT_FAILURE": "true",
-    "org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH": "true",
-    "os.arch": "x86_64",
-    "os.name": "Mac OS X",
-    "os.version": "10.9.5",
-    "path.separator": ":",
-    "socksNonProxyHosts": "local|*.local|169.254/16|*.169.254/16",
-    "sun.arch.data.model": "64",
-    "sun.boot.class.path": "/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/sunrsasign.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/classes",
-    "sun.boot.library.path": "/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib",
-    "sun.cpu.endian": "little",
-    "sun.cpu.isalist": "",
-    "sun.io.unicode.encoding": "UnicodeBig",
-    "sun.java.command": "org.sonar.server.app.WebServer /var/folders/ny/2lkywbzs63xc1n1k7rzprjj40000gn/T/sq-process8077706653824090037properties",
-    "sun.java.launcher": "SUN_STANDARD",
-    "sun.jnu.encoding": "UTF-8",
-    "sun.management.compiler": "HotSpot 64-Bit Tiered Compilers",
-    "sun.nio.ch.bugLevel": "",
-    "sun.os.patch.level": "unknown",
-    "user.country": "US",
-    "user.country.format": "FR",
-    "user.dir": "/Users/foo/dev/core/sonarqube/sonar-application/target/sonarqube-5.1",
-    "user.home": "/Users/foo",
-    "user.language": "en",
-    "user.name": "foo",
-    "user.timezone": "Europe/Paris"
-  },
-  "Database": {
-    "Database": "H2",
-    "Database Version": "1.3.176 (2014-04-05)",
-    "Username": "SONAR",
-    "URL": "jdbc:h2:tcp://localhost:9092/sonar",
-    "Driver": "H2 JDBC Driver",
-    "Driver Version": "1.3.176 (2014-04-05)",
-    "Version Status": "UP_TO_DATE",
-    "Pool Active Connections": 2,
-    "Pool Max Connections": 50,
-    "Pool Initial Size": 0,
-    "Pool Idle Connections": 2,
-    "Pool Min Idle Connections": 2,
-    "Pool Max Idle Connections": 5,
-    "Pool Max Wait (ms)": 5000,
-    "Pool Remove Abandoned": false,
-    "Pool Remove Abandoned Timeout (seconds)": 300
-  }
-}
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/platform/ws/info-example.json b/server/sonar-server/src/main/resources/org/sonar/server/platform/ws/info-example.json
new file mode 100644 (file)
index 0000000..f7bb420
--- /dev/null
@@ -0,0 +1,218 @@
+{
+  "System": {
+    "System Date": "2015-02-23T18:54:23+0100",
+    "Start Time": "2015-02-23T18:53:22+0100",
+    "JVM Vendor": "Oracle Corporation",
+    "JVM Name": "Java HotSpot(TM) 64-Bit Server VM",
+    "JVM Version": "24.71-b01",
+    "Processors": 8,
+    "System Classpath": "./lib/common/commons-codec-1.8.jar:./lib/common/commons-io-2.4.jar:./lib/common/commons-lang-2.6.jar:./lib/common/elasticsearch-1.4.2.jar:./lib/common/logback-classic-1.1.2.jar:./lib/common/logback-core-1.1.2.jar:./lib/common/lucene-analyzers-common-4.10.2.jar:./lib/common/lucene-core-4.10.2.jar:./lib/common/lucene-grouping-4.10.2.jar:./lib/common/lucene-highlighter-4.10.2.jar:./lib/common/lucene-join-4.10.2.jar:./lib/common/lucene-memory-4.10.2.jar:./lib/common/lucene-misc-4.10.2.jar:./lib/common/lucene-queries-4.10.2.jar:./lib/common/lucene-queryparser-4.10.2.jar:./lib/common/lucene-sandbox-4.10.2.jar:./lib/common/lucene-suggest-4.10.2.jar:./lib/common/slf4j-api-1.7.10.jar:./lib/common/sonar-process-5.1-tests.jar:./lib/common/sonar-process-5.1.jar:./lib/common/sonar-process-monitor-5.1.jar:./lib/server/antlr-2.7.6.jar:./lib/server/blueprints-core-2.2.0.jar:./lib/server/commons-beanutils-1.8.3.jar:./lib/server/commons-collections-3.2.2.jar:./lib/server/commons-csv-1.0.jar:./lib/server/commons-dbcp-1.4.jar:./lib/server/commons-dbutils-1.5.jar:./lib/server/commons-pool-1.5.4.jar:./lib/server/dom4j-1.6.1.jar:./lib/server/ejb3-persistence-1.0.2.GA.jar:./lib/server/geronimo-spec-jta-1.0-M1.jar:./lib/server/gson-2.3.1.jar:./lib/server/guava-10.0.1.jar:./lib/server/hibernate-annotations-3.4.0.GA.jar:./lib/server/hibernate-commons-annotations-3.1.0.GA.jar:./lib/server/hibernate-core-3.3.2.GA.jar:./lib/server/hibernate-entitymanager-3.4.0.GA.jar:./lib/server/javassist-3.4.GA.jar:./lib/server/jcl-over-slf4j-1.7.10.jar:./lib/server/jcommon-1.0.12.jar:./lib/server/jfreechart-1.0.9.jar:./lib/server/jruby-complete-1.7.9.jar:./lib/server/jruby-rack-1.1.13.2.jar:./lib/server/json-simple-1.1.1.jar:./lib/server/jul-to-slf4j-1.7.10.jar:./lib/server/log4j-over-slf4j-1.7.10.jar:./lib/server/logback-access-1.1.2.jar:./lib/server/lz4-1.3.0.jar:./lib/server/mybatis-3.2.7.jar:./lib/server/picocontainer-2.14.3.jar:./lib/server/plexus-classworlds-2.5.1.jar:./lib/server/protobuf-java-2.6.1.jar:./lib/server/sonar-batch-protocol-5.1.jar:./lib/server/sonar-channel-4.1.jar:./lib/server/sonar-check-api-5.1.jar:./lib/server/sonar-colorizer-5.1.jar:./lib/server/sonar-core-5.1.jar:./lib/server/sonar-deprecated-5.1.jar:./lib/server/sonar-duplications-5.1.jar:./lib/server/sonar-graph-5.1.jar:./lib/server/sonar-home-5.1.jar:./lib/server/sonar-java-api-5.1.jar:./lib/server/sonar-markdown-5.1.jar:./lib/server/sonar-plugin-api-5.1.jar:./lib/server/sonar-server-5.1.jar:./lib/server/sonar-squid-4.1.jar:./lib/server/sonar-update-center-common-1.11.jar:./lib/server/stax-api-1.0-2.jar:./lib/server/stax2-api-3.1.4.jar:./lib/server/staxmate-2.0.1.jar:./lib/server/tomcat-embed-core-8.0.18.jar:./lib/server/tomcat-embed-el-8.0.18.jar:./lib/server/tomcat-embed-jasper-8.0.18.jar:./lib/server/tomcat-embed-logging-juli-8.0.18.jar:./lib/server/woodstox-core-lgpl-4.4.0.jar:./lib/server/xml-apis-1.4.01.jar:/Users/foo/dev/core/sonarqube/sonar-application/target/sonarqube-5.1/lib/jdbc/h2/h2-1.3.176.jar",
+    "BootClassPath": "/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/sunrsasign.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/classes",
+    "Library Path": "/Users/foo/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.",
+    "Total Memory": "323 MB",
+    "Free Memory": "173 MB",
+    "Max Memory": "716 MB",
+    "Heap": "init = 134217728(131072K) used = 150395872(146870K) committed = 323485696(315904K) max = 716177408(699392K)",
+    "Non Heap": "init = 24576000(24000K) used = 91012976(88879K) committed = 114163712(111488K) max = 218103808(212992K)",
+    "System Load Average": "394.9% (last minute)",
+    "Loaded Classes": 15392,
+    "Total Loaded Classes": 15392,
+    "Unloaded Classes": 0,
+    "Threads": 52,
+    "Threads Peak": 52,
+    "Daemon Thread": 40
+  },
+  "SonarQube": {
+    "Version": "5.1",
+    "External User Authentication": "",
+    "Automatic User Creation": true,
+    "Allow Users to Sign Up": false,
+    "Force authentication": false,
+    "Home Dir": "/Users/foo/dev/core/sonarqube/sonar-application/target/sonarqube-5.1",
+    "Data Dir": "/Users/foo/dev/core/sonarqube/sonar-application/target/sonarqube-5.1/data",
+    "Logs Dir": "/Users/foo/dev/core/sonarqube/sonar-application/target/sonarqube-5.1/logs",
+    "Temp Dir": "/Users/foo/dev/core/sonarqube/sonar-application/target/sonarqube-5.1/temp"
+  },
+  "ElasticSearch": {
+    "State": "GREEN",
+    "Indices": {
+      "sourcelines": {
+        "Docs": 0,
+        "Shards": 1,
+        "Store Size": "115 bytes"
+      },
+      "users": {
+        "Docs": 1,
+        "Shards": 1,
+        "Store Size": "3 KB"
+      },
+      "logs": {
+        "Docs": 1104,
+        "Shards": 1,
+        "Store Size": "162 KB"
+      },
+      "views": {
+        "Docs": 0,
+        "Shards": 1,
+        "Store Size": "115 bytes"
+      },
+      "issues": {
+        "Docs": 0,
+        "Shards": 1,
+        "Store Size": "115 bytes"
+      },
+      "rules": {
+        "Docs": 1491,
+        "Shards": 1,
+        "Store Size": "2 MB"
+      }
+    },
+    "Number of Nodes": 1,
+    "Nodes": {
+      "6DYkdNuvT6abEdShyEK5ow": {
+        "Address": "inet[/10.150.0.193:9001]",
+        "Type": "Master",
+        "Disk Usage": "465 GB",
+        "Disk Available": "67 GB",
+        "Store Size": "2 MB",
+        "Open Files": 212,
+        "JVM Heap Usage": "8.0%",
+        "JVM Heap Used": "79 MB",
+        "JVM Heap Max": "989 MB",
+        "JVM Non Heap Used": "40 MB",
+        "JVM Threads": 104,
+        "Field Cache Memory": "0 bytes",
+        "Filter Cache Memory": "0 bytes",
+        "ID Cache Memory": "51 KB",
+        "Query Cache Memory": "0 bytes"
+      }
+    }
+  },
+  "Plugins": {
+    "scmgit": {
+      "Name": "Git",
+      "Version": "1.0-RC1"
+    },
+    "findbugs": {
+      "Name": "Findbugs",
+      "Version": "3.1"
+    },
+    "scmsvn": {
+      "Name": "SVN",
+      "Version": "1.0-RC1"
+    },
+    "java": {
+      "Name": "Java",
+      "Version": "2.9.1"
+    }
+  },
+  "JvmProperties": {
+    "awt.toolkit": "sun.lwawt.macosx.LWCToolkit",
+    "catalina.base": "/Users/foo/dev/core/sonarqube/sonar-application/target/sonarqube-5.1/temp/tc",
+    "catalina.home": "/Users/foo/dev/core/sonarqube/sonar-application/target/sonarqube-5.1/temp/tc",
+    "catalina.useNaming": "false",
+    "file.encoding": "UTF-8",
+    "file.encoding.pkg": "sun.io",
+    "file.separator": "/",
+    "ftp.nonProxyHosts": "local|*.local|169.254/16|*.169.254/16",
+    "gopherProxySet": "false",
+    "http.agent": "SonarQube 5.1",
+    "http.nonProxyHosts": "local|*.local|169.254/16|*.169.254/16",
+    "java.awt.graphicsenv": "sun.awt.CGraphicsEnvironment",
+    "java.awt.headless": "true",
+    "java.awt.printerjob": "sun.lwawt.macosx.CPrinterJob",
+    "java.class.path": "./lib/common/commons-codec-1.8.jar:./lib/common/commons-io-2.4.jar:./lib/common/commons-lang-2.6.jar:./lib/common/elasticsearch-1.4.2.jar:./lib/common/logback-classic-1.1.2.jar:./lib/common/logback-core-1.1.2.jar:./lib/common/lucene-analyzers-common-4.10.2.jar:./lib/common/lucene-core-4.10.2.jar:./lib/common/lucene-grouping-4.10.2.jar:./lib/common/lucene-highlighter-4.10.2.jar:./lib/common/lucene-join-4.10.2.jar:./lib/common/lucene-memory-4.10.2.jar:./lib/common/lucene-misc-4.10.2.jar:./lib/common/lucene-queries-4.10.2.jar:./lib/common/lucene-queryparser-4.10.2.jar:./lib/common/lucene-sandbox-4.10.2.jar:./lib/common/lucene-suggest-4.10.2.jar:./lib/common/slf4j-api-1.7.10.jar:./lib/common/sonar-process-5.1-tests.jar:./lib/common/sonar-process-5.1.jar:./lib/common/sonar-process-monitor-5.1.jar:./lib/server/antlr-2.7.6.jar:./lib/server/blueprints-core-2.2.0.jar:./lib/server/commons-beanutils-1.8.3.jar:./lib/server/commons-collections-3.2.2.jar:./lib/server/commons-csv-1.0.jar:./lib/server/commons-dbcp-1.4.jar:./lib/server/commons-dbutils-1.5.jar:./lib/server/commons-pool-1.5.4.jar:./lib/server/dom4j-1.6.1.jar:./lib/server/ejb3-persistence-1.0.2.GA.jar:./lib/server/geronimo-spec-jta-1.0-M1.jar:./lib/server/gson-2.3.1.jar:./lib/server/guava-10.0.1.jar:./lib/server/hibernate-annotations-3.4.0.GA.jar:./lib/server/hibernate-commons-annotations-3.1.0.GA.jar:./lib/server/hibernate-core-3.3.2.GA.jar:./lib/server/hibernate-entitymanager-3.4.0.GA.jar:./lib/server/javassist-3.4.GA.jar:./lib/server/jcl-over-slf4j-1.7.10.jar:./lib/server/jcommon-1.0.12.jar:./lib/server/jfreechart-1.0.9.jar:./lib/server/jruby-complete-1.7.9.jar:./lib/server/jruby-rack-1.1.13.2.jar:./lib/server/json-simple-1.1.1.jar:./lib/server/jul-to-slf4j-1.7.10.jar:./lib/server/log4j-over-slf4j-1.7.10.jar:./lib/server/logback-access-1.1.2.jar:./lib/server/lz4-1.3.0.jar:./lib/server/mybatis-3.2.7.jar:./lib/server/picocontainer-2.14.3.jar:./lib/server/plexus-classworlds-2.5.1.jar:./lib/server/protobuf-java-2.6.1.jar:./lib/server/sonar-batch-protocol-5.1.jar:./lib/server/sonar-channel-4.1.jar:./lib/server/sonar-check-api-5.1.jar:./lib/server/sonar-colorizer-5.1.jar:./lib/server/sonar-core-5.1.jar:./lib/server/sonar-deprecated-5.1.jar:./lib/server/sonar-duplications-5.1.jar:./lib/server/sonar-graph-5.1.jar:./lib/server/sonar-home-5.1.jar:./lib/server/sonar-java-api-5.1.jar:./lib/server/sonar-markdown-5.1.jar:./lib/server/sonar-plugin-api-5.1.jar:./lib/server/sonar-server-5.1.jar:./lib/server/sonar-squid-4.1.jar:./lib/server/sonar-update-center-common-1.11.jar:./lib/server/stax-api-1.0-2.jar:./lib/server/stax2-api-3.1.4.jar:./lib/server/staxmate-2.0.1.jar:./lib/server/tomcat-embed-core-8.0.18.jar:./lib/server/tomcat-embed-el-8.0.18.jar:./lib/server/tomcat-embed-jasper-8.0.18.jar:./lib/server/tomcat-embed-logging-juli-8.0.18.jar:./lib/server/woodstox-core-lgpl-4.4.0.jar:./lib/server/xml-apis-1.4.01.jar:/Users/foo/dev/core/sonarqube/sonar-application/target/sonarqube-5.1/lib/jdbc/h2/h2-1.3.176.jar",
+    "java.class.version": "51.0",
+    "java.endorsed.dirs": "/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/endorsed",
+    "java.ext.dirs": "/Users/foo/Library/Java/Extensions:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/ext:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java",
+    "java.home": "/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre",
+    "java.io.tmpdir": "/Users/foo/dev/core/sonarqube/sonar-application/target/sonarqube-5.1/temp",
+    "java.library.path": "/Users/foo/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.",
+    "java.net.preferIPv4Stack": "true",
+    "java.runtime.name": "Java(TM) SE Runtime Environment",
+    "java.runtime.version": "1.7.0_71-b14",
+    "java.specification.name": "Java Platform API Specification",
+    "java.specification.vendor": "Oracle Corporation",
+    "java.specification.version": "1.7",
+    "java.vendor": "Oracle Corporation",
+    "java.vendor.url": "http://java.oracle.com/",
+    "java.vendor.url.bug": "http://bugreport.sun.com/bugreport/",
+    "java.version": "1.7.0_71",
+    "java.vm.info": "mixed mode",
+    "java.vm.name": "Java HotSpot(TM) 64-Bit Server VM",
+    "java.vm.specification.name": "Java Virtual Machine Specification",
+    "java.vm.specification.vendor": "Oracle Corporation",
+    "java.vm.specification.version": "1.7",
+    "java.vm.vendor": "Oracle Corporation",
+    "java.vm.version": "24.71-b01",
+    "line.separator": "\n",
+    "org.apache.catalina.startup.EXIT_ON_INIT_FAILURE": "true",
+    "org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH": "true",
+    "os.arch": "x86_64",
+    "os.name": "Mac OS X",
+    "os.version": "10.9.5",
+    "path.separator": ":",
+    "socksNonProxyHosts": "local|*.local|169.254/16|*.169.254/16",
+    "sun.arch.data.model": "64",
+    "sun.boot.class.path": "/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/sunrsasign.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/classes",
+    "sun.boot.library.path": "/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib",
+    "sun.cpu.endian": "little",
+    "sun.cpu.isalist": "",
+    "sun.io.unicode.encoding": "UnicodeBig",
+    "sun.java.command": "org.sonar.server.app.WebServer /var/folders/ny/2lkywbzs63xc1n1k7rzprjj40000gn/T/sq-process8077706653824090037properties",
+    "sun.java.launcher": "SUN_STANDARD",
+    "sun.jnu.encoding": "UTF-8",
+    "sun.management.compiler": "HotSpot 64-Bit Tiered Compilers",
+    "sun.nio.ch.bugLevel": "",
+    "sun.os.patch.level": "unknown",
+    "user.country": "US",
+    "user.country.format": "FR",
+    "user.dir": "/Users/foo/dev/core/sonarqube/sonar-application/target/sonarqube-5.1",
+    "user.home": "/Users/foo",
+    "user.language": "en",
+    "user.name": "foo",
+    "user.timezone": "Europe/Paris"
+  },
+  "Database": {
+    "Database": "H2",
+    "Database Version": "1.3.176 (2014-04-05)",
+    "Username": "SONAR",
+    "URL": "jdbc:h2:tcp://localhost:9092/sonar",
+    "Driver": "H2 JDBC Driver",
+    "Driver Version": "1.3.176 (2014-04-05)",
+    "Version Status": "UP_TO_DATE",
+    "Pool Active Connections": 2,
+    "Pool Max Connections": 50,
+    "Pool Initial Size": 0,
+    "Pool Idle Connections": 2,
+    "Pool Min Idle Connections": 2,
+    "Pool Max Idle Connections": 5,
+    "Pool Max Wait (ms)": 5000,
+    "Pool Remove Abandoned": false,
+    "Pool Remove Abandoned Timeout (seconds)": 300
+  },
+  "Statistics": {
+    "id": "AU-TpxcB-iU5OvuD2FL7",
+    "version": "5.1",
+    "plugins": {
+      "scmgit": "1.0-RC1",
+      "findbugs": "3.1",
+      "scmsvn": "1.0-RC1",
+      "java": "2.9.1"
+    },
+    "userCount": 3,
+    "projectCount": 2,
+    "lines": 500,
+    "ncloc": 300,
+    "projectCountByLanguage": {
+      "java": 2,
+      "kotlin": 1,
+      "js": 1
+    },
+    "nclocByLanguage": {
+      "java": 500,
+      "kotlin": 2500,
+      "js": 50
+    }
+  }
+}
index 7182b0c34d7a215361fea4d402ec966e581d3050..b90037f812f959e79d62300e9782b750aee3e18d 100644 (file)
@@ -30,12 +30,15 @@ import org.sonar.ce.http.CeHttpClient;
 import org.sonar.ce.http.CeHttpClientImpl;
 import org.sonar.server.exceptions.ForbiddenException;
 import org.sonar.server.platform.monitoring.Monitor;
+import org.sonar.server.telemetry.TelemetryData;
+import org.sonar.server.telemetry.TelemetryDataLoader;
 import org.sonar.server.tester.UserSessionRule;
 import org.sonar.server.ws.TestResponse;
 import org.sonar.server.ws.WsActionTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 public class InfoActionTest {
@@ -48,23 +51,24 @@ public class InfoActionTest {
   private Monitor monitor1 = mock(Monitor.class);
   private Monitor monitor2 = mock(Monitor.class);
   private CeHttpClient ceHttpClient = mock(CeHttpClientImpl.class, Mockito.RETURNS_MOCKS);
+  private TelemetryDataLoader statistics = mock(TelemetryDataLoader.class);
 
-  private InfoAction underTest = new InfoAction(userSessionRule, ceHttpClient, monitor1, monitor2);
-  private WsActionTester actionTester = new WsActionTester(underTest);
+  private InfoAction underTest = new InfoAction(userSessionRule, ceHttpClient, statistics, monitor1, monitor2);
+  private WsActionTester ws = new WsActionTester(underTest);
 
   @Test
   public void test_definition() throws Exception {
-    assertThat(actionTester.getDef().key()).isEqualTo("info");
-    assertThat(actionTester.getDef().isInternal()).isTrue();
-    assertThat(actionTester.getDef().responseExampleAsString()).isNotEmpty();
-    assertThat(actionTester.getDef().params()).isEmpty();
+    assertThat(ws.getDef().key()).isEqualTo("info");
+    assertThat(ws.getDef().isInternal()).isTrue();
+    assertThat(ws.getDef().responseExampleAsString()).isNotEmpty();
+    assertThat(ws.getDef().params()).isEmpty();
   }
 
   @Test
   public void request_fails_with_ForbiddenException_when_user_is_not_logged_in() {
     expectedException.expect(ForbiddenException.class);
 
-    actionTester.newRequest().execute();
+    ws.newRequest().execute();
   }
 
   @Test
@@ -73,7 +77,7 @@ public class InfoActionTest {
 
     expectedException.expect(ForbiddenException.class);
 
-    actionTester.newRequest().execute();
+    ws.newRequest().execute();
   }
 
   @Test
@@ -90,10 +94,13 @@ public class InfoActionTest {
     when(monitor2.name()).thenReturn("Monitor Two");
     when(monitor2.attributes()).thenReturn(attributes2);
     when(ceHttpClient.retrieveSystemInfo()).thenReturn(Optional.empty());
+    when(statistics.load()).thenReturn(mock(TelemetryData.class));
 
-    TestResponse response = actionTester.newRequest().execute();
+    TestResponse response = ws.newRequest().execute();
     // response does not contain empty "Monitor Three"
-    assertThat(response.getInput()).isEqualTo("{\"Monitor One\":{\"foo\":\"bar\"},\"Monitor Two\":{\"one\":1,\"two\":2}}");
+    verify(statistics).load();
+    assertThat(response.getInput()).isEqualTo("{\"Monitor One\":{\"foo\":\"bar\"},\"Monitor Two\":{\"one\":1,\"two\":2}," +
+      "\"Statistics\":{\"plugins\":{},\"userCount\":0,\"projectCount\":0,\"lines\":0,\"ncloc\":0,\"projectCountByLanguage\":{},\"nclocByLanguage\":{}}}");
   }
 
   private void logInAsSystemAdministrator() {
index 99530152be3c69efddfe24bb89784b7ceecd1876..334902594670dbed70b6722d8325d9d3cfaa5d38 100644 (file)
@@ -27,6 +27,7 @@ import org.sonar.ce.http.CeHttpClientImpl;
 import org.sonar.server.app.ProcessCommandWrapper;
 import org.sonar.server.app.RestartFlagHolder;
 import org.sonar.server.platform.Platform;
+import org.sonar.server.telemetry.TelemetryDataLoader;
 import org.sonar.server.tester.AnonymousMockUserSession;
 import org.sonar.server.user.UserSession;
 
@@ -41,7 +42,7 @@ public class SystemWsTest {
   public void define() {
     RestartAction action1 = new RestartAction(mock(UserSession.class), mock(Configuration.class), mock(Platform.class), mock(ProcessCommandWrapper.class),
       mock(RestartFlagHolder.class));
-    InfoAction action2 = new InfoAction(new AnonymousMockUserSession(), ceHttpClient);
+    InfoAction action2 = new InfoAction(new AnonymousMockUserSession(), ceHttpClient, mock(TelemetryDataLoader.class));
     SystemWs ws = new SystemWs(action1, action2);
     WebService.Context context = new WebService.Context();
 
index 16dc742383dc5a79c8623788c2532f57d01eeb72..9c6c79f2ef1ae64639ae394cbc272fe6c812b1ed 100644 (file)
@@ -160,7 +160,7 @@ public class TelemetryDaemonTest {
     underTest.start();
 
     ArgumentCaptor<String> json = ArgumentCaptor.forClass(String.class);
-    verify(client, timeout(1_000).atLeastOnce()).upload(json.capture());
+    verify(client, timeout(1_500).atLeastOnce()).upload(json.capture());
     assertThat(json.getValue()).contains(id, version);
   }