diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2019-04-30 10:52:55 -0500 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2019-05-06 11:01:03 +0200 |
commit | a517a4c1b6afe3c3c202801249dcbea41cfdec4c (patch) | |
tree | b3ffb242da45497fb6f3583123f1f7b58d7eb46c /server | |
parent | 140aa8271a5af00a84154698b18dc254d5f7bae9 (diff) | |
download | sonarqube-a517a4c1b6afe3c3c202801249dcbea41cfdec4c.tar.gz sonarqube-a517a4c1b6afe3c3c202801249dcbea41cfdec4c.zip |
SONAR-11969 Make Edition available for analyzers in the Scanner API
Diffstat (limited to 'server')
7 files changed, 26 insertions, 15 deletions
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java index cc7445e259b..313ac49cdce 100644 --- a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java +++ b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java @@ -23,10 +23,11 @@ import com.google.common.annotations.VisibleForTesting; import java.time.Clock; import java.util.List; import javax.annotation.CheckForNull; +import org.sonar.api.SonarEdition; import org.sonar.api.SonarQubeSide; import org.sonar.api.SonarQubeVersion; import org.sonar.api.config.EmailSettings; -import org.sonar.api.internal.ApiVersion; +import org.sonar.api.internal.MetadataLoader; import org.sonar.api.internal.SonarRuntimeImpl; import org.sonar.api.profiles.AnnotationProfileParser; import org.sonar.api.profiles.XMLProfileParser; @@ -265,13 +266,14 @@ public class ComputeEngineContainerImpl implements ComputeEngineContainer { } private static void populateLevel1(ComponentContainer container, Props props, ComputeEngineStatus computeEngineStatus) { - Version apiVersion = ApiVersion.load(System2.INSTANCE); + Version apiVersion = MetadataLoader.loadVersion(System2.INSTANCE); + SonarEdition edition = MetadataLoader.loadEdition(System2.INSTANCE); container.add( props.rawProperties(), ThreadLocalSettings.class, new ConfigurationProvider(), new SonarQubeVersion(apiVersion), - SonarRuntimeImpl.forSonarQube(ApiVersion.load(System2.INSTANCE), SonarQubeSide.COMPUTE_ENGINE), + SonarRuntimeImpl.forSonarQube(apiVersion, SonarQubeSide.COMPUTE_ENGINE, edition), CeProcessLogging.class, UuidFactoryImpl.INSTANCE, NetworkUtilsImpl.INSTANCE, diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/platform/StartupMetadataProviderTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/platform/StartupMetadataProviderTest.java index e761789a5ca..deaca33baf2 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/platform/StartupMetadataProviderTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/platform/StartupMetadataProviderTest.java @@ -19,6 +19,7 @@ */ package org.sonar.server.platform; +import org.sonar.api.SonarEdition; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -54,7 +55,7 @@ public class StartupMetadataProviderTest { @Test public void generate_SERVER_STARTIME_but_do_not_persist_it_if_server_is_startup_leader() { when(system.now()).thenReturn(A_DATE); - SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.create(6, 1), SonarQubeSide.SERVER); + SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.create(6, 1), SonarQubeSide.SERVER, SonarEdition.COMMUNITY); when(webServer.isStartupLeader()).thenReturn(true); StartupMetadata metadata = underTest.provide(system, runtime, webServer, dbTester.getDbClient()); @@ -69,7 +70,7 @@ public class StartupMetadataProviderTest { @Test public void load_from_database_if_server_is_startup_follower() { - SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.create(6, 1), SonarQubeSide.SERVER); + SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.create(6, 1), SonarQubeSide.SERVER, SonarEdition.COMMUNITY); when(webServer.isStartupLeader()).thenReturn(false); testLoadingFromDatabase(runtime, false); @@ -77,21 +78,21 @@ public class StartupMetadataProviderTest { @Test public void load_from_database_if_compute_engine_of_startup_leader_server() { - SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.create(6, 1), SonarQubeSide.COMPUTE_ENGINE); + SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.create(6, 1), SonarQubeSide.COMPUTE_ENGINE, SonarEdition.COMMUNITY); testLoadingFromDatabase(runtime, true); } @Test public void load_from_database_if_compute_engine_of_startup_follower_server() { - SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.create(6, 1), SonarQubeSide.COMPUTE_ENGINE); + SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.create(6, 1), SonarQubeSide.COMPUTE_ENGINE, SonarEdition.COMMUNITY); testLoadingFromDatabase(runtime, false); } @Test public void fail_to_load_from_database_if_properties_are_not_persisted() { - SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.create(6, 1), SonarQubeSide.COMPUTE_ENGINE); + SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.create(6, 1), SonarQubeSide.COMPUTE_ENGINE, SonarEdition.COMMUNITY); when(webServer.isStartupLeader()).thenReturn(false); expectedException.expect(IllegalStateException.class); diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/util/OkHttpClientProviderTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/util/OkHttpClientProviderTest.java index 32ed25b0663..b5c880269bb 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/util/OkHttpClientProviderTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/util/OkHttpClientProviderTest.java @@ -28,6 +28,7 @@ import okhttp3.Response; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; +import org.sonar.api.SonarEdition; import org.junit.Rule; import org.junit.Test; import org.sonar.api.SonarQubeSide; @@ -41,7 +42,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class OkHttpClientProviderTest { private MapSettings settings = new MapSettings(); - private SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.parse("6.2"), SonarQubeSide.SERVER); + private SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.parse("6.2"), SonarQubeSide.SERVER, SonarEdition.COMMUNITY); private final OkHttpClientProvider underTest = new OkHttpClientProvider(); @Rule diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/webhook/WebhookCallerImplTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/webhook/WebhookCallerImplTest.java index 0368eac7575..ee8b5cf1e03 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/webhook/WebhookCallerImplTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/webhook/WebhookCallerImplTest.java @@ -29,6 +29,7 @@ import org.junit.Test; import org.junit.rules.DisableOnDebug; import org.junit.rules.TestRule; import org.junit.rules.Timeout; +import org.sonar.api.SonarEdition; import org.sonar.api.SonarQubeSide; import org.sonar.api.SonarRuntime; import org.sonar.api.config.internal.MapSettings; @@ -233,7 +234,7 @@ public class WebhookCallerImplTest { } private WebhookCaller newSender() { - SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.parse("6.2"), SonarQubeSide.SERVER); + SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.parse("6.2"), SonarQubeSide.SERVER, SonarEdition.COMMUNITY); return new WebhookCallerImpl(system, new OkHttpClientProvider().provide(new MapSettings().asConfig(), runtime)); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java index b15e0d6a2ff..a706b694741 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java @@ -22,9 +22,10 @@ package org.sonar.server.platform.platformlevel; import java.time.Clock; import java.util.Properties; import javax.annotation.Nullable; +import org.sonar.api.SonarEdition; import org.sonar.api.SonarQubeSide; import org.sonar.api.SonarQubeVersion; -import org.sonar.api.internal.ApiVersion; +import org.sonar.api.internal.MetadataLoader; import org.sonar.api.internal.SonarRuntimeImpl; import org.sonar.api.utils.System2; import org.sonar.api.utils.Version; @@ -82,10 +83,12 @@ public class PlatformLevel1 extends PlatformLevel { public void configureLevel() { add(platform, properties); addExtraRootComponents(); - Version apiVersion = ApiVersion.load(System2.INSTANCE); + Version apiVersion = MetadataLoader.loadVersion(System2.INSTANCE); + SonarEdition edition = MetadataLoader.loadEdition(System2.INSTANCE); + add( new SonarQubeVersion(apiVersion), - SonarRuntimeImpl.forSonarQube(apiVersion, SonarQubeSide.SERVER), + SonarRuntimeImpl.forSonarQube(apiVersion, SonarQubeSide.SERVER, edition), ThreadLocalSettings.class, new ConfigurationProvider(), LogServerVersion.class, diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/serverid/ServerIdManagerTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/serverid/ServerIdManagerTest.java index 1947b81d17f..0875ad0fcb2 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/platform/serverid/ServerIdManagerTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/platform/serverid/ServerIdManagerTest.java @@ -22,6 +22,7 @@ package org.sonar.server.platform.serverid; import com.tngtech.java.junit.dataprovider.DataProvider; import com.tngtech.java.junit.dataprovider.DataProviderRunner; import com.tngtech.java.junit.dataprovider.UseDataProvider; +import org.sonar.api.SonarEdition; import org.junit.After; import org.junit.Rule; import org.junit.Test; @@ -355,7 +356,8 @@ public class ServerIdManagerTest { } private void test(SonarQubeSide side) { - underTest = new ServerIdManager(serverIdChecksum, serverIdFactory, dbClient, SonarRuntimeImpl.forSonarQube(Version.create(6, 7), side), webServer); + underTest = new ServerIdManager(serverIdChecksum, serverIdFactory, dbClient, SonarRuntimeImpl + .forSonarQube(Version.create(6, 7), side, SonarEdition.COMMUNITY), webServer); underTest.start(); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/ws/WebServiceFilterTest.java b/server/sonar-server/src/test/java/org/sonar/server/ws/WebServiceFilterTest.java index 42e2136f6e0..1e58673735d 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/ws/WebServiceFilterTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/ws/WebServiceFilterTest.java @@ -25,6 +25,7 @@ import javax.servlet.FilterChain; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.sonar.api.SonarEdition; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -58,7 +59,7 @@ public class WebServiceFilterTest { private HttpServletResponse response = mock(HttpServletResponse.class); private FilterChain chain = mock(FilterChain.class); private ServletOutputStream responseOutput = mock(ServletOutputStream.class); - private SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.parse(RUNTIME_VERSION), SonarQubeSide.SERVER); + private SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.parse(RUNTIME_VERSION), SonarQubeSide.SERVER, SonarEdition.COMMUNITY); private WebServiceFilter underTest; @Before |