From 3cdc4c315d27543c7ba94e11879aaf6be7380db6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Thu, 31 Aug 2017 18:34:54 +0200 Subject: [PATCH] =?utf8?q?SONAR=E2=88=929721=20fix=20InfoAction=20class=20?= =?utf8?q?dependency=20on=20web=20followers?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../platformlevel/PlatformLevel4.java | 4 +- .../server/platform/ws/InfoActionModule.java | 31 +++++++++++++++ .../server/telemetry/TelemetryModule.java | 4 +- .../platform/ws/InfoActionModuleTest.java | 38 +++++++++++++++++++ .../server/telemetry/TelemetryModuleTest.java | 5 ++- 5 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 server/sonar-server/src/main/java/org/sonar/server/platform/ws/InfoActionModule.java create mode 100644 server/sonar-server/src/test/java/org/sonar/server/platform/ws/InfoActionModuleTest.java diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java index 57f67a4874a..2f6b37b75e0 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java @@ -115,7 +115,7 @@ import org.sonar.server.platform.web.WebPagesFilter; import org.sonar.server.platform.web.requestid.HttpRequestIdModule; import org.sonar.server.platform.ws.ChangeLogLevelAction; import org.sonar.server.platform.ws.DbMigrationStatusAction; -import org.sonar.server.platform.ws.InfoAction; +import org.sonar.server.platform.ws.InfoActionModule; import org.sonar.server.platform.ws.L10nWs; import org.sonar.server.platform.ws.LogsAction; import org.sonar.server.platform.ws.MigrateDbAction; @@ -472,7 +472,7 @@ public class PlatformLevel4 extends PlatformLevel { // System ServerLogging.class, RestartAction.class, - InfoAction.class, + InfoActionModule.class, PingAction.class, UpgradesAction.class, StatusAction.class, diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/ws/InfoActionModule.java b/server/sonar-server/src/main/java/org/sonar/server/platform/ws/InfoActionModule.java new file mode 100644 index 00000000000..78bff02585c --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/ws/InfoActionModule.java @@ -0,0 +1,31 @@ +/* + * 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.platform.ws; + +import org.sonar.core.platform.Module; +import org.sonar.server.telemetry.TelemetryDataLoader; + +public class InfoActionModule extends Module { + @Override + protected void configureModule() { + add(TelemetryDataLoader.class, + InfoAction.class); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/telemetry/TelemetryModule.java b/server/sonar-server/src/main/java/org/sonar/server/telemetry/TelemetryModule.java index bb2e4a9b298..447f11e5a0e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/telemetry/TelemetryModule.java +++ b/server/sonar-server/src/main/java/org/sonar/server/telemetry/TelemetryModule.java @@ -24,9 +24,7 @@ import org.sonar.core.platform.Module; public class TelemetryModule extends Module { @Override protected void configureModule() { - add( - TelemetryDataLoader.class, - TelemetryDaemon.class, + add(TelemetryDaemon.class, TelemetryClient.class); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/ws/InfoActionModuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/ws/InfoActionModuleTest.java new file mode 100644 index 00000000000..674b61c572d --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/platform/ws/InfoActionModuleTest.java @@ -0,0 +1,38 @@ +/* + * 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.platform.ws; + +import org.junit.Test; +import org.sonar.core.platform.ComponentContainer; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.sonar.core.platform.ComponentContainer.COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER; + +public class InfoActionModuleTest { + @Test + public void verify_count_of_added_components() { + ComponentContainer container = new ComponentContainer(); + + new InfoActionModule().configure(container); + + assertThat(container.size()).isEqualTo(2 + COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER); + } + +} diff --git a/server/sonar-server/src/test/java/org/sonar/server/telemetry/TelemetryModuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/telemetry/TelemetryModuleTest.java index 57c07eb666f..3edc6524aa8 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/telemetry/TelemetryModuleTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/telemetry/TelemetryModuleTest.java @@ -23,12 +23,15 @@ import org.junit.Test; import org.sonar.core.platform.ComponentContainer; import static org.assertj.core.api.Assertions.assertThat; +import static org.sonar.core.platform.ComponentContainer.COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER; public class TelemetryModuleTest { @Test public void verify_count_of_added_components() { ComponentContainer container = new ComponentContainer(); + new TelemetryModule().configure(container); - assertThat(container.size()).isEqualTo(3 + 2); + + assertThat(container.size()).isEqualTo(2 + COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER); } } -- 2.39.5