aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2018-06-07 17:24:49 +0200
committerSonarTech <sonartech@sonarsource.com>2018-06-12 20:21:04 +0200
commit7de21fcb50fd438fbb847c57397b142bb538872b (patch)
tree75449f305603862b4c5f9338992527d9d13da63b
parentbf6c9991631f6303fb5905c1a0061f4bf8a9e2ee (diff)
downloadsonarqube-7de21fcb50fd438fbb847c57397b142bb538872b.tar.gz
sonarqube-7de21fcb50fd438fbb847c57397b142bb538872b.zip
SONAR-10690 make fake-billing-plugin a core extension
-rw-r--r--settings.gradle2
-rw-r--r--tests/build.gradle2
-rw-r--r--tests/plugins/core-extension-fake-billing/build.gradle4
-rw-r--r--tests/plugins/core-extension-fake-billing/src/main/java/FakeBillingCoreExtension.java (renamed from tests/plugins/fake-billing-plugin/src/main/java/FakeBillingPlugin.java)25
-rw-r--r--tests/plugins/core-extension-fake-billing/src/main/java/FakeBillingValidations.java (renamed from tests/plugins/fake-billing-plugin/src/main/java/FakeBillingValidations.java)0
-rw-r--r--tests/plugins/core-extension-fake-billing/src/main/resources/META-INF/services/org.sonar.core.extension.CoreExtension1
-rw-r--r--tests/plugins/core-extension-fake-billing/src/main/resources/org/sonar/l10n/billing.properties (renamed from tests/plugins/fake-billing-plugin/src/main/resources/org/sonar/l10n/billing.properties)0
-rw-r--r--tests/plugins/fake-billing-plugin/build.gradle19
-rw-r--r--tests/src/test/java/org/sonarqube/tests/organization/BillingTest.java2
-rw-r--r--tests/src/test/java/org/sonarqube/tests/organization/OrganizationSuite.java9
10 files changed, 23 insertions, 41 deletions
diff --git a/settings.gradle b/settings.gradle
index 10d2f730941..c94cf11a2d1 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -40,7 +40,7 @@ include 'tests:plugins:batch-plugin'
include 'tests:plugins:blue-green-plugin-v1'
include 'tests:plugins:blue-green-plugin-v2'
include 'tests:plugins:extension-lifecycle-plugin'
-include 'tests:plugins:fake-billing-plugin'
+include 'tests:plugins:core-extension-fake-billing'
include 'tests:plugins:core-extension-it-tests'
include 'tests:plugins:foo-plugin-v1'
include 'tests:plugins:foo-plugin-v2'
diff --git a/tests/build.gradle b/tests/build.gradle
index da55a4f03cf..fc5da403ddb 100644
--- a/tests/build.gradle
+++ b/tests/build.gradle
@@ -19,7 +19,7 @@ def pluginsForITs = [
':tests:plugins:blue-green-plugin-v1',
':tests:plugins:blue-green-plugin-v2',
':tests:plugins:extension-lifecycle-plugin',
- ':tests:plugins:fake-billing-plugin',
+ ':tests:plugins:core-extension-fake-billing',
':tests:plugins:core-extension-it-tests',
':tests:plugins:foo-plugin-v1',
':tests:plugins:foo-plugin-v2',
diff --git a/tests/plugins/core-extension-fake-billing/build.gradle b/tests/plugins/core-extension-fake-billing/build.gradle
new file mode 100644
index 00000000000..3dc8a9030bb
--- /dev/null
+++ b/tests/plugins/core-extension-fake-billing/build.gradle
@@ -0,0 +1,4 @@
+dependencies {
+ compileOnly project(path: ':sonar-plugin-api', configuration: 'shadow')
+ compileOnly project(':server:sonar-server')
+}
diff --git a/tests/plugins/fake-billing-plugin/src/main/java/FakeBillingPlugin.java b/tests/plugins/core-extension-fake-billing/src/main/java/FakeBillingCoreExtension.java
index 97a4e8053d6..6ef26f790f3 100644
--- a/tests/plugins/fake-billing-plugin/src/main/java/FakeBillingPlugin.java
+++ b/tests/plugins/core-extension-fake-billing/src/main/java/FakeBillingCoreExtension.java
@@ -38,24 +38,25 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import org.sonar.api.Plugin;
+import org.sonar.api.SonarQubeSide;
+import org.sonar.core.extension.CoreExtension;
-public class FakeBillingPlugin implements Plugin {
+import static org.sonar.api.SonarQubeSide.COMPUTE_ENGINE;
+import static org.sonar.api.SonarQubeSide.SERVER;
+public class FakeBillingCoreExtension implements CoreExtension {
@Override
- public void define(Context context) {
+ public String getName() {
+ return "fake-billing";
+ }
+
+ @Override
+ public void load(Context context) {
+ SonarQubeSide sonarQubeSide = context.getRuntime().getSonarQubeSide();
// Nothing should be loaded when the plugin is running within by the scanner
- if (isRunningInSQ()) {
+ if (sonarQubeSide == SERVER || sonarQubeSide == COMPUTE_ENGINE) {
context.addExtension(FakeBillingValidations.class);
}
}
- private static boolean isRunningInSQ() {
- try {
- Class.forName("org.sonar.server.plugins.privileged.CoreExtensionBridge");
- return true;
- } catch (ClassNotFoundException e) {
- return false;
- }
- }
}
diff --git a/tests/plugins/fake-billing-plugin/src/main/java/FakeBillingValidations.java b/tests/plugins/core-extension-fake-billing/src/main/java/FakeBillingValidations.java
index 16c178c4233..16c178c4233 100644
--- a/tests/plugins/fake-billing-plugin/src/main/java/FakeBillingValidations.java
+++ b/tests/plugins/core-extension-fake-billing/src/main/java/FakeBillingValidations.java
diff --git a/tests/plugins/core-extension-fake-billing/src/main/resources/META-INF/services/org.sonar.core.extension.CoreExtension b/tests/plugins/core-extension-fake-billing/src/main/resources/META-INF/services/org.sonar.core.extension.CoreExtension
new file mode 100644
index 00000000000..f8adf894e60
--- /dev/null
+++ b/tests/plugins/core-extension-fake-billing/src/main/resources/META-INF/services/org.sonar.core.extension.CoreExtension
@@ -0,0 +1 @@
+FakeBillingCoreExtension
diff --git a/tests/plugins/fake-billing-plugin/src/main/resources/org/sonar/l10n/billing.properties b/tests/plugins/core-extension-fake-billing/src/main/resources/org/sonar/l10n/billing.properties
index f8ac8fcaef5..f8ac8fcaef5 100644
--- a/tests/plugins/fake-billing-plugin/src/main/resources/org/sonar/l10n/billing.properties
+++ b/tests/plugins/core-extension-fake-billing/src/main/resources/org/sonar/l10n/billing.properties
diff --git a/tests/plugins/fake-billing-plugin/build.gradle b/tests/plugins/fake-billing-plugin/build.gradle
deleted file mode 100644
index 47f55fe4d63..00000000000
--- a/tests/plugins/fake-billing-plugin/build.gradle
+++ /dev/null
@@ -1,19 +0,0 @@
-dependencies {
- compileOnly project(path: ':sonar-plugin-api', configuration: 'shadow')
- compileOnly project(':server:sonar-server')
-}
-
-jar {
- manifest {
- attributes(
- 'Plugin-Key': 'billing',
- 'Plugin-Version': version,
- 'Plugin-Class': 'FakeBillingPlugin',
- 'Plugin-ChildFirstClassLoader': 'false',
- 'Sonar-Version': version,
- 'SonarLint-Supported': 'false',
- 'Plugin-Name': 'Plugins :: Fake Billing Plugin',
- 'Plugin-License': 'GNU LGPL 3'
- )
- }
-}
diff --git a/tests/src/test/java/org/sonarqube/tests/organization/BillingTest.java b/tests/src/test/java/org/sonarqube/tests/organization/BillingTest.java
index 713762a7e2d..a66254b5ebd 100644
--- a/tests/src/test/java/org/sonarqube/tests/organization/BillingTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/organization/BillingTest.java
@@ -25,7 +25,6 @@ import com.sonar.orchestrator.build.SonarScanner;
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;
-import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.sonarqube.qa.util.Tester;
@@ -46,7 +45,6 @@ import static util.ItUtils.expectHttpError;
import static util.ItUtils.newProjectKey;
import static util.ItUtils.projectDir;
-@Ignore("FIXME IT disabled because it relies on a privileged plugin (fake-billing-plugin)")
public class BillingTest {
private static final String PROPERTY_PREVENT_ANALYSIS = "sonar.billing.preventProjectAnalysis";
diff --git a/tests/src/test/java/org/sonarqube/tests/organization/OrganizationSuite.java b/tests/src/test/java/org/sonarqube/tests/organization/OrganizationSuite.java
index a2b6c311e43..0d2d51231e2 100644
--- a/tests/src/test/java/org/sonarqube/tests/organization/OrganizationSuite.java
+++ b/tests/src/test/java/org/sonarqube/tests/organization/OrganizationSuite.java
@@ -24,6 +24,7 @@ import org.junit.ClassRule;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
+import static util.ItUtils.installCoreExtension;
import static util.ItUtils.newOrchestratorBuilder;
import static util.ItUtils.pluginArtifact;
import static util.ItUtils.xooPlugin;
@@ -43,12 +44,8 @@ public class OrganizationSuite {
@ClassRule
public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder(
builder -> builder
-
.addPlugin(xooPlugin())
- .addPlugin(pluginArtifact("fake-billing-plugin"))
.addPlugin(pluginArtifact("ui-extensions-plugin"))
-
- .setServerProperty("sonar.sonarcloud.enabled", "true")
-
- );
+ .setServerProperty("sonar.sonarcloud.enabled", "true"),
+ server -> installCoreExtension(server, "core-extension-fake-billing"));
}