aboutsummaryrefslogtreecommitdiffstats
path: root/it/it-plugins
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2015-07-27 12:25:42 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2015-07-27 13:48:01 +0200
commit60a09b339533429a7eebecc75c21f36a45ee06ee (patch)
tree32f32771858b51aea12c69f3d073d8aa1bb0b33a /it/it-plugins
parent5050ad482cc23da9593fabf5e57863665f39aabd (diff)
downloadsonarqube-60a09b339533429a7eebecc75c21f36a45ee06ee.tar.gz
sonarqube-60a09b339533429a7eebecc75c21f36a45ee06ee.zip
Move server category test from it-sonar
Diffstat (limited to 'it/it-plugins')
-rw-r--r--it/it-plugins/global-property-change-plugin/pom.xml39
-rw-r--r--it/it-plugins/global-property-change-plugin/src/main/java/FakeGlobalPropertyChange.java12
-rw-r--r--it/it-plugins/global-property-change-plugin/src/main/java/GlobalPropertyChangePlugin.java9
-rw-r--r--it/it-plugins/license-plugin/pom.xml38
-rw-r--r--it/it-plugins/license-plugin/src/main/java/LicensePlugin.java24
-rw-r--r--it/it-plugins/pom.xml5
-rw-r--r--it/it-plugins/property-relocation-plugin/pom.xml39
-rw-r--r--it/it-plugins/property-relocation-plugin/src/main/java/CheckProperties.java16
-rw-r--r--it/it-plugins/property-relocation-plugin/src/main/java/PropertyRelocationPlugin.java14
-rw-r--r--it/it-plugins/server-plugin/pom.xml39
-rw-r--r--it/it-plugins/server-plugin/src/main/java/ServerPlugin.java14
-rw-r--r--it/it-plugins/server-plugin/src/main/java/TempFolderExtension.java40
-rw-r--r--it/it-plugins/server-plugin/src/main/java/WidgetDisplayingProperties.java22
-rw-r--r--it/it-plugins/server-plugin/src/main/resources/widgets/widget-displaying-properties.html.erb12
-rw-r--r--it/it-plugins/settings-plugin/pom.xml40
-rw-r--r--it/it-plugins/settings-plugin/src/main/java/PropertyTypes.java16
-rw-r--r--it/it-plugins/settings-plugin/src/main/java/ServerExtensionWithProperties.java24
-rw-r--r--it/it-plugins/settings-plugin/src/main/java/SettingsPlugin.java9
18 files changed, 412 insertions, 0 deletions
diff --git a/it/it-plugins/global-property-change-plugin/pom.xml b/it/it-plugins/global-property-change-plugin/pom.xml
new file mode 100644
index 00000000000..dd98ded898c
--- /dev/null
+++ b/it/it-plugins/global-property-change-plugin/pom.xml
@@ -0,0 +1,39 @@
+<?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.it</groupId>
+ <artifactId>it-plugins</artifactId>
+ <version>5.2-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>global-property-change-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>sonar-plugin</packaging>
+ <description>Plugins :: Global Property Change</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.12.1</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>GlobalPropertyChangePlugin</pluginClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/it/it-plugins/global-property-change-plugin/src/main/java/FakeGlobalPropertyChange.java b/it/it-plugins/global-property-change-plugin/src/main/java/FakeGlobalPropertyChange.java
new file mode 100644
index 00000000000..ed0c697c5b7
--- /dev/null
+++ b/it/it-plugins/global-property-change-plugin/src/main/java/FakeGlobalPropertyChange.java
@@ -0,0 +1,12 @@
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.config.GlobalPropertyChangeHandler;
+
+@Properties(@Property(key = "globalPropertyChange.received", name = "Check that extension has correctly been notified by global property change", category = "fake"))
+public final class FakeGlobalPropertyChange extends GlobalPropertyChangeHandler {
+
+ @Override
+ public void onChange(PropertyChange propertyChange) {
+ System.out.println("Received change: " + propertyChange);
+ }
+}
diff --git a/it/it-plugins/global-property-change-plugin/src/main/java/GlobalPropertyChangePlugin.java b/it/it-plugins/global-property-change-plugin/src/main/java/GlobalPropertyChangePlugin.java
new file mode 100644
index 00000000000..3f27d04f9db
--- /dev/null
+++ b/it/it-plugins/global-property-change-plugin/src/main/java/GlobalPropertyChangePlugin.java
@@ -0,0 +1,9 @@
+import java.util.Arrays;
+import java.util.List;
+import org.sonar.api.SonarPlugin;
+
+public class GlobalPropertyChangePlugin extends SonarPlugin {
+ public List getExtensions() {
+ return Arrays.asList(FakeGlobalPropertyChange.class);
+ }
+}
diff --git a/it/it-plugins/license-plugin/pom.xml b/it/it-plugins/license-plugin/pom.xml
new file mode 100644
index 00000000000..e2480fb86b7
--- /dev/null
+++ b/it/it-plugins/license-plugin/pom.xml
@@ -0,0 +1,38 @@
+<?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.it</groupId>
+ <artifactId>it-plugins</artifactId>
+ <version>5.2-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>license-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>sonar-plugin</packaging>
+ <description>Plugins :: License</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.12.1</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>LicensePlugin</pluginClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/it/it-plugins/license-plugin/src/main/java/LicensePlugin.java b/it/it-plugins/license-plugin/src/main/java/LicensePlugin.java
new file mode 100644
index 00000000000..b7d589dac1d
--- /dev/null
+++ b/it/it-plugins/license-plugin/src/main/java/LicensePlugin.java
@@ -0,0 +1,24 @@
+import java.util.Collections;
+import java.util.List;
+import org.sonar.api.CoreProperties;
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.PropertyType;
+import org.sonar.api.SonarPlugin;
+
+@Properties({
+ @Property(
+ key = "untyped.license.secured",
+ name = "Property without license type",
+ category = CoreProperties.CATEGORY_GENERAL),
+ @Property(
+ key = "typed.license.secured",
+ name = "Typed property",
+ category = CoreProperties.CATEGORY_GENERAL,
+ type = PropertyType.LICENSE)
+})
+public class LicensePlugin extends SonarPlugin {
+ public List getExtensions() {
+ return Collections.emptyList();
+ }
+}
diff --git a/it/it-plugins/pom.xml b/it/it-plugins/pom.xml
index ef5117becb0..d93f4a945e8 100644
--- a/it/it-plugins/pom.xml
+++ b/it/it-plugins/pom.xml
@@ -30,8 +30,13 @@
</properties>
<modules>
+ <module>global-property-change-plugin</module>
<module>l10n-fr-pack</module>
+ <module>license-plugin</module>
+ <module>property-relocation-plugin</module>
<module>property-sets-plugin</module>
+ <module>server-plugin</module>
+ <module>settings-plugin</module>
<module>sonar-fake-plugin</module>
<module>sonar-subcategories-plugin</module>
</modules>
diff --git a/it/it-plugins/property-relocation-plugin/pom.xml b/it/it-plugins/property-relocation-plugin/pom.xml
new file mode 100644
index 00000000000..1f3e0d353a6
--- /dev/null
+++ b/it/it-plugins/property-relocation-plugin/pom.xml
@@ -0,0 +1,39 @@
+<?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.it</groupId>
+ <artifactId>it-plugins</artifactId>
+ <version>5.2-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>property-relocation-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>sonar-plugin</packaging>
+ <description>Plugins :: Property Relocation</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.12.1</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>PropertyRelocationPlugin</pluginClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/it/it-plugins/property-relocation-plugin/src/main/java/CheckProperties.java b/it/it-plugins/property-relocation-plugin/src/main/java/CheckProperties.java
new file mode 100644
index 00000000000..ef0a850440b
--- /dev/null
+++ b/it/it-plugins/property-relocation-plugin/src/main/java/CheckProperties.java
@@ -0,0 +1,16 @@
+import org.sonar.api.BatchExtension;
+import org.sonar.api.config.Settings;
+
+public class CheckProperties implements BatchExtension {
+ private Settings settings;
+
+ public CheckProperties(Settings settings) {
+ this.settings = settings;
+ }
+
+ public void start() {
+ if (settings.getBoolean("sonar.newKey") != true) {
+ throw new IllegalStateException("Property not found: sonar.newKey");
+ }
+ }
+}
diff --git a/it/it-plugins/property-relocation-plugin/src/main/java/PropertyRelocationPlugin.java b/it/it-plugins/property-relocation-plugin/src/main/java/PropertyRelocationPlugin.java
new file mode 100644
index 00000000000..f2e1e654215
--- /dev/null
+++ b/it/it-plugins/property-relocation-plugin/src/main/java/PropertyRelocationPlugin.java
@@ -0,0 +1,14 @@
+import java.util.Arrays;
+import java.util.List;
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.SonarPlugin;
+
+@Properties({
+ @Property(key = "sonar.newKey", deprecatedKey = "sonar.deprecatedKey", name = "New Key", category = "general")
+})
+public class PropertyRelocationPlugin extends SonarPlugin {
+ public List getExtensions() {
+ return Arrays.asList(CheckProperties.class);
+ }
+}
diff --git a/it/it-plugins/server-plugin/pom.xml b/it/it-plugins/server-plugin/pom.xml
new file mode 100644
index 00000000000..82c49fae573
--- /dev/null
+++ b/it/it-plugins/server-plugin/pom.xml
@@ -0,0 +1,39 @@
+<?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.it</groupId>
+ <artifactId>it-plugins</artifactId>
+ <version>5.2-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>server-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>sonar-plugin</packaging>
+ <name>SonarQube Integration Tests :: Plugins :: Server</name>
+ <description>Main plugin for Server tests</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.12.1</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>ServerPlugin</pluginClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/it/it-plugins/server-plugin/src/main/java/ServerPlugin.java b/it/it-plugins/server-plugin/src/main/java/ServerPlugin.java
new file mode 100644
index 00000000000..41271c1b628
--- /dev/null
+++ b/it/it-plugins/server-plugin/src/main/java/ServerPlugin.java
@@ -0,0 +1,14 @@
+import java.util.Arrays;
+import java.util.List;
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.SonarPlugin;
+
+@Properties({
+ @Property(key = "some-property", name = "Some Property", defaultValue = "aDefaultValue", global = true, project = false)
+})
+public class ServerPlugin extends SonarPlugin {
+ public List getExtensions() {
+ return Arrays.asList(WidgetDisplayingProperties.class, TempFolderExtension.class);
+ }
+}
diff --git a/it/it-plugins/server-plugin/src/main/java/TempFolderExtension.java b/it/it-plugins/server-plugin/src/main/java/TempFolderExtension.java
new file mode 100644
index 00000000000..a8ac1c854e9
--- /dev/null
+++ b/it/it-plugins/server-plugin/src/main/java/TempFolderExtension.java
@@ -0,0 +1,40 @@
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.PropertyType;
+import org.sonar.api.ServerExtension;
+import org.sonar.api.config.Settings;
+import org.sonar.api.utils.TempFolder;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
+
+@Properties({
+ @Property(
+ key = TempFolderExtension.CREATE_TEMP_FILES,
+ type = PropertyType.BOOLEAN,
+ name = "Property to decide if it should create temp files",
+ defaultValue = "false")
+})
+public class TempFolderExtension implements ServerExtension {
+
+ private static final Logger LOG = Loggers.get(TempFolderExtension.class);
+
+ public static final String CREATE_TEMP_FILES = "sonar.createTempFiles";
+
+ private Settings settings;
+
+ private TempFolder tempFolder;
+
+ public TempFolderExtension(Settings settings, TempFolder tempFolder) {
+ this.settings = settings;
+ this.tempFolder = tempFolder;
+ start();
+ }
+
+ public void start() {
+ if (settings.getBoolean(CREATE_TEMP_FILES)) {
+ LOG.info("Creating temp directory: " + tempFolder.newDir("sonar-it").getAbsolutePath());
+ LOG.info("Creating temp file: " + tempFolder.newFile("sonar-it", ".txt").getAbsolutePath());
+ }
+ }
+
+}
diff --git a/it/it-plugins/server-plugin/src/main/java/WidgetDisplayingProperties.java b/it/it-plugins/server-plugin/src/main/java/WidgetDisplayingProperties.java
new file mode 100644
index 00000000000..94f92639720
--- /dev/null
+++ b/it/it-plugins/server-plugin/src/main/java/WidgetDisplayingProperties.java
@@ -0,0 +1,22 @@
+import org.sonar.api.web.AbstractRubyTemplate;
+import org.sonar.api.web.RubyRailsWidget;
+import org.sonar.api.web.WidgetScope;
+
+import static org.sonar.api.web.WidgetScope.GLOBAL;
+
+@WidgetScope(GLOBAL)
+public class WidgetDisplayingProperties extends AbstractRubyTemplate implements RubyRailsWidget {
+
+ public String getId() {
+ return "widget-displaying-properties";
+ }
+
+ public String getTitle() {
+ return "Widget Displaying Properties";
+ }
+
+ @Override
+ protected String getTemplatePath() {
+ return "/widgets/widget-displaying-properties.html.erb";
+ }
+}
diff --git a/it/it-plugins/server-plugin/src/main/resources/widgets/widget-displaying-properties.html.erb b/it/it-plugins/server-plugin/src/main/resources/widgets/widget-displaying-properties.html.erb
new file mode 100644
index 00000000000..b98754d9605
--- /dev/null
+++ b/it/it-plugins/server-plugin/src/main/resources/widgets/widget-displaying-properties.html.erb
@@ -0,0 +1,12 @@
+<table>
+ <thead>
+ <tr>
+ <th>Property</th>
+ <th>Value</th>
+ </tr>
+ </thead>
+ <tr>
+ <td>some-property</td>
+ <td id="some-property"><%= configuration('some-property') -%></td>
+ </tr>
+</table>
diff --git a/it/it-plugins/settings-plugin/pom.xml b/it/it-plugins/settings-plugin/pom.xml
new file mode 100644
index 00000000000..9196eae40fc
--- /dev/null
+++ b/it/it-plugins/settings-plugin/pom.xml
@@ -0,0 +1,40 @@
+<?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.it</groupId>
+ <artifactId>it-plugins</artifactId>
+ <version>5.2-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>settings-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>sonar-plugin</packaging>
+ <description>Plugins :: Settings</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.12.1</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>SettingsPlugin</pluginClass>
+ <pluginName>Settings</pluginName>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/it/it-plugins/settings-plugin/src/main/java/PropertyTypes.java b/it/it-plugins/settings-plugin/src/main/java/PropertyTypes.java
new file mode 100644
index 00000000000..eb2738f07a9
--- /dev/null
+++ b/it/it-plugins/settings-plugin/src/main/java/PropertyTypes.java
@@ -0,0 +1,16 @@
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.PropertyType;
+import org.sonar.api.ServerExtension;
+
+@Properties({
+ @Property(key = "boolean", name = "Boolean", type=PropertyType.BOOLEAN),
+ @Property(key = "integer", name = "Integer", type=PropertyType.INTEGER),
+ @Property(key = "float", name = "Float", type=PropertyType.FLOAT),
+ @Property(key = "password", name = "Password", type=PropertyType.PASSWORD, defaultValue = "sonar"),
+ @Property(key = "text", name = "Text", type=PropertyType.TEXT),
+ @Property(key = "metric", name = "Metric", type=PropertyType.METRIC),
+ @Property(key = "single_select_list", name = "Single Select List", type=PropertyType.SINGLE_SELECT_LIST, options = {"de", "en", "nl"})
+})
+public class PropertyTypes implements ServerExtension {
+}
diff --git a/it/it-plugins/settings-plugin/src/main/java/ServerExtensionWithProperties.java b/it/it-plugins/settings-plugin/src/main/java/ServerExtensionWithProperties.java
new file mode 100644
index 00000000000..d4ecd07d124
--- /dev/null
+++ b/it/it-plugins/settings-plugin/src/main/java/ServerExtensionWithProperties.java
@@ -0,0 +1,24 @@
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.ServerExtension;
+import org.sonar.api.config.Settings;
+
+@Properties({
+ @Property(key = "settings.extension.hidden", name = "Hidden Property", description = "Hidden Property defined on extension but not plugin", global = false, project = false, module = false, defaultValue = "teahupoo"),
+ @Property(key = "settings.extension.global", name = "Global Property", global = true, project = false, module = false)
+})
+public final class ServerExtensionWithProperties implements ServerExtension {
+
+ private Settings settings;
+
+ public ServerExtensionWithProperties(Settings settings) {
+ this.settings = settings;
+ }
+
+ public void start() {
+ System.out.println("Test that the default value of properties are automatically injected by the component Settings");
+ if (!"teahupoo".equals(settings.getString("settings.extension.hidden"))) {
+ throw new IllegalStateException("The property settings.extension.hidden is not registered");
+ }
+ }
+}
diff --git a/it/it-plugins/settings-plugin/src/main/java/SettingsPlugin.java b/it/it-plugins/settings-plugin/src/main/java/SettingsPlugin.java
new file mode 100644
index 00000000000..e89b7bfb555
--- /dev/null
+++ b/it/it-plugins/settings-plugin/src/main/java/SettingsPlugin.java
@@ -0,0 +1,9 @@
+import java.util.Arrays;
+import java.util.List;
+import org.sonar.api.SonarPlugin;
+
+public class SettingsPlugin extends SonarPlugin {
+ public List getExtensions() {
+ return Arrays.asList(ServerExtensionWithProperties.class, PropertyTypes.class);
+ }
+}