aboutsummaryrefslogtreecommitdiffstats
path: root/tests/plugins
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-07-05 14:30:14 +0200
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-07-17 10:52:47 +0200
commitdc3144cba269380b55d015a57b03e4e466bd091d (patch)
tree2c0a691758843606edfc30a69be1cdd570c87385 /tests/plugins
parentcffa304e688ed72619b3a88f1e4fcb1cd14f04d4 (diff)
downloadsonarqube-dc3144cba269380b55d015a57b03e4e466bd091d.tar.gz
sonarqube-dc3144cba269380b55d015a57b03e4e466bd091d.zip
SONAR-9507 add IT
Diffstat (limited to 'tests/plugins')
-rw-r--r--tests/plugins/fake-governance-plugin/pom.xml44
-rw-r--r--tests/plugins/fake-governance-plugin/src/main/java/FakeGovernancePlugin.java42
-rw-r--r--tests/plugins/fake-governance-plugin/src/main/java/FakeWorkerCountProviderImpl.java40
-rw-r--r--tests/plugins/fake-governance-plugin/src/main/resources/org/sonar/l10n/billing.properties2
-rw-r--r--tests/plugins/pom.xml1
5 files changed, 129 insertions, 0 deletions
diff --git a/tests/plugins/fake-governance-plugin/pom.xml b/tests/plugins/fake-governance-plugin/pom.xml
new file mode 100644
index 00000000000..7f81da99349
--- /dev/null
+++ b/tests/plugins/fake-governance-plugin/pom.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.sonarsource.sonarqube.tests</groupId>
+ <artifactId>plugins</artifactId>
+ <version>6.5-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>fake-governance-plugin</artifactId>
+ <packaging>sonar-plugin</packaging>
+ <description>Plugins :: Fake Governance Plugin</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-server</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.15</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>FakeGovernancePlugin</pluginClass>
+ <pluginKey>governance</pluginKey>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tests/plugins/fake-governance-plugin/src/main/java/FakeGovernancePlugin.java b/tests/plugins/fake-governance-plugin/src/main/java/FakeGovernancePlugin.java
new file mode 100644
index 00000000000..2d9c47cc854
--- /dev/null
+++ b/tests/plugins/fake-governance-plugin/src/main/java/FakeGovernancePlugin.java
@@ -0,0 +1,42 @@
+
+/*
+ * 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.
+ */
+
+import org.sonar.api.Plugin;
+
+public class FakeGovernancePlugin implements Plugin {
+
+ @Override
+ public void define(Context context) {
+ // Nothing should be loaded when the plugin is running within by the scanner
+ if (isRunningInSQ()) {
+ context.addExtension(FakeWorkerCountProviderImpl.class);
+ }
+ }
+
+ private static boolean isRunningInSQ() {
+ try {
+ Class.forName("org.sonar.plugin.PrivilegedPluginBridge");
+ return true;
+ } catch (ClassNotFoundException e) {
+ return false;
+ }
+ }
+}
diff --git a/tests/plugins/fake-governance-plugin/src/main/java/FakeWorkerCountProviderImpl.java b/tests/plugins/fake-governance-plugin/src/main/java/FakeWorkerCountProviderImpl.java
new file mode 100644
index 00000000000..ad737c42eb0
--- /dev/null
+++ b/tests/plugins/fake-governance-plugin/src/main/java/FakeWorkerCountProviderImpl.java
@@ -0,0 +1,40 @@
+
+/*
+ * 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.
+ */
+
+import org.sonar.api.config.Configuration;
+import org.sonar.ce.configuration.WorkerCountProvider;
+
+public class FakeWorkerCountProviderImpl implements WorkerCountProvider {
+
+ private static final String PROPERTY_WORKER_COUNT = "fakeGovernance.workerCount";
+
+ private final Configuration configuration;
+
+ public FakeWorkerCountProviderImpl(Configuration configuration) {
+ this.configuration = configuration;
+ }
+
+ @Override
+ public int get() {
+ return configuration.get(PROPERTY_WORKER_COUNT).map(Integer::valueOf).orElse(1);
+ }
+
+}
diff --git a/tests/plugins/fake-governance-plugin/src/main/resources/org/sonar/l10n/billing.properties b/tests/plugins/fake-governance-plugin/src/main/resources/org/sonar/l10n/billing.properties
new file mode 100644
index 00000000000..f8ac8fcaef5
--- /dev/null
+++ b/tests/plugins/fake-governance-plugin/src/main/resources/org/sonar/l10n/billing.properties
@@ -0,0 +1,2 @@
+billing.upgrade_box.header=The fake billing plugin is installed
+billing.upgrade_box.text=It shows how to change the wording and hide the "Upgrade" button. \ No newline at end of file
diff --git a/tests/plugins/pom.xml b/tests/plugins/pom.xml
index 52aa4a5d611..b5f3af0d112 100644
--- a/tests/plugins/pom.xml
+++ b/tests/plugins/pom.xml
@@ -41,6 +41,7 @@
<module>batch-plugin</module>
<module>extension-lifecycle-plugin</module>
<module>fake-billing-plugin</module>
+ <module>fake-governance-plugin</module>
<module>foo-plugin-v1</module>
<module>foo-plugin-v2</module>
<module>global-property-change-plugin</module>